Drive by comment.

http://codereview.chromium.org/554032/diff/5004/4014
File src/ia32/full-codegen-ia32.cc (right):

http://codereview.chromium.org/554032/diff/5004/4014#newcode1722
src/ia32/full-codegen-ia32.cc:1722: // If either operand is constant
null we do a fast compare
This is kind of a hack for this particular case.  I'm worried these
hacks will multiply on us.

Better to handle more generally the case of trivial subexpressions.

1. Define Expression::IsTrivial to return true for literals, false for
everything else.

2. Redefine FullCodeGenerator::Move(Register, Literal*) to work on any
trivial expression.

3. Write:

case Token::EQ:
  cc = equal;
  if (expr->right()->IsTrivial()) {
    VisitForValue(expr->left, kAccumulator);
    Move(edx, expr->right());
    if (expr->right()->AsLiteral() != NULL && ...->IsNull()) {
      null_check = kConstantNullComparison;
    }
  } else if (expr->left()->IsTrivial()) {
    VisitForValue(expr->right(), kAccumulator);
    Move(edx, expr->left());
    if (...->IsNull()) null_check = ...;
  } else {
    VisitForValue(expr->left(), kStack);
    VisitForValue(expr->right(), kAccumulator);
    __ pop(edx);
  }

http://codereview.chromium.org/554032/diff/5004/4014#newcode1732
src/ia32/full-codegen-ia32.cc:1732: __ xchg(eax, edx);
Do we care about the order of arguments in the case that one is literal
null?

http://codereview.chromium.org/554032

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to