Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Unified Diff: src/fast-codegen.cc

Issue 486008: Adding compound assignments to the top-level compiler. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/fast-codegen.h ('k') | src/ia32/fast-codegen-ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/fast-codegen.cc
===================================================================
--- src/fast-codegen.cc (revision 3445)
+++ src/fast-codegen.cc (working copy)
@@ -500,7 +500,6 @@
void FastCodeGenerator::VisitAssignment(Assignment* expr) {
Comment cmnt(masm_, "[ Assignment");
- ASSERT(expr->op() == Token::ASSIGN || expr->op() == Token::INIT_VAR);
// Record source code position of the (possible) IC call.
SetSourcePosition(expr->position());
@@ -518,26 +517,60 @@
: KEYED_PROPERTY;
}
- Expression* rhs = expr->value();
- ASSERT_EQ(Expression::kValue, rhs->context());
-
+ // Evaluate LHS expression.
switch (assign_type) {
case VARIABLE:
- Visit(rhs);
- EmitVariableAssignment(expr);
+ // Nothing to do here.
break;
case NAMED_PROPERTY:
Visit(prop->obj());
ASSERT_EQ(Expression::kValue, prop->obj()->context());
- Visit(rhs);
- EmitNamedPropertyAssignment(expr);
break;
case KEYED_PROPERTY:
Visit(prop->obj());
ASSERT_EQ(Expression::kValue, prop->obj()->context());
Visit(prop->key());
ASSERT_EQ(Expression::kValue, prop->key()->context());
- Visit(rhs);
+ 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()) {
+ switch (assign_type) {
+ case VARIABLE:
+ EmitVariableLoad(expr->target()->AsVariableProxy()->var(),
+ Expression::kValue);
+ break;
+ case NAMED_PROPERTY:
+ EmitNamedPropertyLoad(prop, Expression::kValue);
+ break;
+ case KEYED_PROPERTY:
+ EmitKeyedPropertyLoad(Expression::kValue);
+ break;
+ }
+ }
+
+ // Evaluate RHS expression.
+ Expression* rhs = expr->value();
+ ASSERT_EQ(Expression::kValue, rhs->context());
+ Visit(rhs);
+
+ // If we have a compount assignment: Apply operator.
+ if (expr->is_compound()) {
+ EmitCompoundAssignmentOp(expr->binary_op(), Expression::kValue);
+ }
+
+ // Store the value.
+ switch (assign_type) {
+ case VARIABLE:
+ EmitVariableAssignment(expr);
+ break;
+ case NAMED_PROPERTY:
+ EmitNamedPropertyAssignment(expr);
+ break;
+ case KEYED_PROPERTY:
EmitKeyedPropertyAssignment(expr);
break;
}
« no previous file with comments | « src/fast-codegen.h ('k') | src/ia32/fast-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698