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

Unified Diff: src/fast-codegen.cc

Issue 342073: Refactor the somewhat complicated code generation for assignments into... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 1 month 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 3192)
+++ src/fast-codegen.cc (working copy)
@@ -424,6 +424,47 @@
}
+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());
+
+ Expression* rhs = expr->value();
+ // Left-hand side can only be a property, a global or a (parameter or
+ // local) slot.
+ Variable* var = expr->target()->AsVariableProxy()->AsVariable();
+ Property* prop = expr->target()->AsProperty();
+ if (var != NULL) {
+ Visit(rhs);
+ ASSERT_EQ(Expression::kValue, rhs->context());
+ EmitVariableAssignment(expr->context(), var);
+ } else if (prop != NULL) {
+ // Assignment to a property.
+ Visit(prop->obj());
+ ASSERT_EQ(Expression::kValue, prop->obj()->context());
+ // Use the expression context of the key subexpression to detect whether
+ // we have decided to us a named or keyed IC.
+ if (prop->key()->context() == Expression::kUninitialized) {
+ ASSERT(prop->key()->AsLiteral() != NULL);
+ Visit(rhs);
+ ASSERT_EQ(Expression::kValue, rhs->context());
+ EmitNamedPropertyAssignment(expr->context(),
+ prop->key()->AsLiteral()->handle());
+ } else {
+ Visit(prop->key());
+ ASSERT_EQ(Expression::kValue, prop->key()->context());
+ Visit(rhs);
+ ASSERT_EQ(Expression::kValue, rhs->context());
+ EmitKeyedPropertyAssignment(expr->context());
+ }
+ } else {
+ UNREACHABLE();
+ }
+}
+
+
void FastCodeGenerator::VisitCatchExtensionObject(CatchExtensionObject* expr) {
UNREACHABLE();
}
« 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