| Index: src/fast-codegen.cc
|
| ===================================================================
|
| --- src/fast-codegen.cc (revision 3626)
|
| +++ src/fast-codegen.cc (working copy)
|
| @@ -75,39 +75,6 @@
|
| }
|
|
|
|
|
| -void FastCodeGenerator::Apply(Expression::Context context, Register reg) {
|
| - switch (context) {
|
| - case Expression::kUninitialized:
|
| - UNREACHABLE();
|
| - case Expression::kEffect:
|
| - break;
|
| - case Expression::kValue:
|
| - __ push(reg);
|
| - break;
|
| - case Expression::kTest:
|
| - TestAndBranch(reg, true_label_, false_label_);
|
| - break;
|
| - case Expression::kValueTest: {
|
| - Label discard;
|
| - __ push(reg);
|
| - TestAndBranch(reg, true_label_, &discard);
|
| - __ bind(&discard);
|
| - __ Drop(1);
|
| - __ jmp(false_label_);
|
| - break;
|
| - }
|
| - case Expression::kTestValue: {
|
| - Label discard;
|
| - __ push(reg);
|
| - TestAndBranch(reg, &discard, false_label_);
|
| - __ bind(&discard);
|
| - __ Drop(1);
|
| - __ jmp(true_label_);
|
| - }
|
| - }
|
| -}
|
| -
|
| -
|
| void FastCodeGenerator::VisitDeclarations(
|
| ZoneList<Declaration*>* declarations) {
|
| int length = declarations->length();
|
| @@ -345,14 +312,7 @@
|
| Comment cmnt(masm_, "[ ReturnStatement");
|
| SetStatementPosition(stmt);
|
| Expression* expr = stmt->expression();
|
| - // Complete the statement based on the type of the subexpression.
|
| - if (expr->AsLiteral() != NULL) {
|
| - __ Move(result_register(), expr->AsLiteral()->handle());
|
| - } else {
|
| - ASSERT_EQ(Expression::kValue, expr->context());
|
| - Visit(expr);
|
| - __ pop(result_register());
|
| - }
|
| + VisitForValue(expr, kAccumulator);
|
|
|
| // Exit all nested statements.
|
| NestedStatement* current = nesting_stack_;
|
| @@ -371,7 +331,7 @@
|
| Comment cmnt(masm_, "[ WithEnterStatement");
|
| SetStatementPosition(stmt);
|
|
|
| - Visit(stmt->expression());
|
| + VisitForValue(stmt->expression(), kStack);
|
| if (stmt->is_catch_block()) {
|
| __ CallRuntime(Runtime::kPushCatchContext, 1);
|
| } else {
|
| @@ -658,21 +618,19 @@
|
| // Nothing to do here.
|
| break;
|
| case NAMED_PROPERTY:
|
| - Visit(prop->obj());
|
| - ASSERT_EQ(Expression::kValue, prop->obj()->context());
|
| + VisitForValue(prop->obj(), kStack);
|
| break;
|
| case KEYED_PROPERTY:
|
| - Visit(prop->obj());
|
| - ASSERT_EQ(Expression::kValue, prop->obj()->context());
|
| - Visit(prop->key());
|
| - ASSERT_EQ(Expression::kValue, prop->key()->context());
|
| + VisitForValue(prop->obj(), kStack);
|
| + VisitForValue(prop->key(), kStack);
|
| break;
|
| }
|
|
|
| // If we have a compound assignment: Get value of LHS expression and
|
| // store in on top of the stack.
|
| - // Note: Relies on kValue context being 'stack'.
|
| if (expr->is_compound()) {
|
| + Location saved_location = location_;
|
| + location_ = kStack;
|
| switch (assign_type) {
|
| case VARIABLE:
|
| EmitVariableLoad(expr->target()->AsVariableProxy()->var(),
|
| @@ -687,16 +645,19 @@
|
| __ push(result_register());
|
| break;
|
| }
|
| + location_ = saved_location;
|
| }
|
|
|
| // Evaluate RHS expression.
|
| Expression* rhs = expr->value();
|
| - ASSERT_EQ(Expression::kValue, rhs->context());
|
| - Visit(rhs);
|
| + VisitForValue(rhs, kAccumulator);
|
|
|
| // If we have a compount assignment: Apply operator.
|
| if (expr->is_compound()) {
|
| - EmitCompoundAssignmentOp(expr->binary_op(), Expression::kValue);
|
| + Location saved_location = location_;
|
| + location_ = kAccumulator;
|
| + EmitBinaryOp(expr->binary_op(), Expression::kValue);
|
| + location_ = saved_location;
|
| }
|
|
|
| // Record source position before possible IC call.
|
| @@ -723,11 +684,8 @@
|
| // assign the exception value to the catch variable.
|
| Comment cmnt(masm_, "[ CatchExtensionObject");
|
|
|
| - // Push key string.
|
| - ASSERT_EQ(Expression::kValue, expr->key()->context());
|
| - Visit(expr->key());
|
| - ASSERT_EQ(Expression::kValue, expr->value()->context());
|
| - Visit(expr->value());
|
| + VisitForValue(expr->key(), kStack);
|
| + VisitForValue(expr->value(), kStack);
|
|
|
| // Create catch extension object.
|
| __ CallRuntime(Runtime::kCreateCatchExtensionObject, 2);
|
| @@ -738,8 +696,7 @@
|
|
|
| void FastCodeGenerator::VisitThrow(Throw* expr) {
|
| Comment cmnt(masm_, "[ Throw");
|
| - Visit(expr->exception());
|
| - // Exception is on stack.
|
| + VisitForValue(expr->exception(), kStack);
|
| __ CallRuntime(Runtime::kThrow, 1);
|
| // Never returns here.
|
| }
|
|
|