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

Unified Diff: src/fast-codegen.cc

Issue 456024: Refactor code for generating assignments in the fast 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/compiler.cc ('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 3421)
+++ src/fast-codegen.cc (working copy)
@@ -505,35 +505,41 @@
// Record source code position of the (possible) IC call.
SetSourcePosition(expr->position());
+ // Left-hand side can only be a property, a global or a (parameter or local)
+ // slot. Variables with rewrite to .arguments are treated as KEYED_PROPERTY.
+ enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY };
+ LhsKind assign_type = VARIABLE;
+ Property* prop = expr->target()->AsProperty();
+ // In case of a property we use the uninitialized expression context
+ // of the key to detect a named property.
+ if (prop != NULL) {
+ assign_type = (prop->key()->context() == Expression::kUninitialized)
+ ? NAMED_PROPERTY
+ : KEYED_PROPERTY;
+ }
+
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);
- } 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);
+ ASSERT_EQ(Expression::kValue, rhs->context());
+
+ switch (assign_type) {
+ case VARIABLE:
Visit(rhs);
- ASSERT_EQ(Expression::kValue, rhs->context());
+ EmitVariableAssignment(expr);
+ break;
+ case NAMED_PROPERTY:
+ Visit(prop->obj());
+ ASSERT_EQ(Expression::kValue, prop->obj()->context());
+ Visit(rhs);
EmitNamedPropertyAssignment(expr);
- } else {
+ 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);
- ASSERT_EQ(Expression::kValue, rhs->context());
EmitKeyedPropertyAssignment(expr);
- }
- } else {
- UNREACHABLE();
+ break;
}
}
« no previous file with comments | « src/compiler.cc ('k') | src/ia32/fast-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698