Index: src/x64/full-codegen-x64.cc |
=================================================================== |
--- src/x64/full-codegen-x64.cc (revision 5338) |
+++ src/x64/full-codegen-x64.cc (working copy) |
@@ -1218,7 +1218,10 @@ |
if (expr->is_compound()) { |
Location saved_location = location_; |
location_ = kAccumulator; |
- EmitBinaryOp(expr->binary_op(), Expression::kValue); |
+ OverwriteMode mode = expr->value()->ResultOverwriteAllowed() |
+ ? OVERWRITE_RIGHT |
+ : NO_OVERWRITE; |
+ EmitBinaryOp(expr->binary_op(), Expression::kValue, mode); |
location_ = saved_location; |
} |
@@ -1261,12 +1264,16 @@ |
void FullCodeGenerator::EmitBinaryOp(Token::Value op, |
- Expression::Context context) { |
- __ push(result_register()); |
- GenericBinaryOpStub stub(op, |
- NO_OVERWRITE, |
- NO_GENERIC_BINARY_FLAGS); |
- __ CallStub(&stub); |
+ Expression::Context context, |
+ OverwriteMode mode) { |
+ GenericBinaryOpStub stub(op, mode, NO_GENERIC_BINARY_FLAGS); |
+ if (stub.ArgsInRegistersSupported()) { |
+ __ pop(rdx); |
+ stub.GenerateCall(masm_, rdx, rax); |
+ } else { |
+ __ push(result_register()); |
+ __ CallStub(&stub); |
+ } |
Apply(context, rax); |
} |
@@ -2646,9 +2653,7 @@ |
case Token::SUB: { |
Comment cmt(masm_, "[ UnaryOperation (SUB)"); |
- bool can_overwrite = |
- (expr->expression()->AsBinaryOperation() != NULL && |
- expr->expression()->AsBinaryOperation()->ResultOverwriteAllowed()); |
+ bool can_overwrite = expr->expression()->ResultOverwriteAllowed(); |
UnaryOverwriteMode overwrite = |
can_overwrite ? UNARY_OVERWRITE : UNARY_NO_OVERWRITE; |
GenericUnaryOpStub stub(Token::SUB, overwrite); |
@@ -2662,9 +2667,7 @@ |
case Token::BIT_NOT: { |
Comment cmt(masm_, "[ UnaryOperation (BIT_NOT)"); |
- bool can_overwrite = |
- (expr->expression()->AsBinaryOperation() != NULL && |
- expr->expression()->AsBinaryOperation()->ResultOverwriteAllowed()); |
+ bool can_overwrite = expr->expression()->ResultOverwriteAllowed(); |
UnaryOverwriteMode overwrite = |
can_overwrite ? UNARY_OVERWRITE : UNARY_NO_OVERWRITE; |
GenericUnaryOpStub stub(Token::BIT_NOT, overwrite); |
@@ -2780,7 +2783,7 @@ |
// Inline smi case if we are in a loop. |
Label stub_call, done; |
- if (loop_depth() > 0) { |
+ if (ShouldInlineSmiCase(expr->op())) { |
if (expr->op() == Token::INC) { |
__ SmiAddConstant(rax, rax, Smi::FromInt(1)); |
} else { |
@@ -2995,7 +2998,7 @@ |
} |
VisitForValue(expr->left(), kStack); |
- switch (expr->op()) { |
+ switch (op) { |
case Token::IN: |
VisitForValue(expr->right(), kStack); |
__ InvokeBuiltin(Builtins::IN, CALL_FUNCTION); |
@@ -3017,7 +3020,7 @@ |
VisitForValue(expr->right(), kAccumulator); |
Condition cc = no_condition; |
bool strict = false; |
- switch (expr->op()) { |
+ switch (op) { |
case Token::EQ_STRICT: |
strict = true; |
// Fall through. |