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

Unified Diff: src/x64/fast-codegen-x64.cc

Issue 347001: Support for property assignment in the fast compiler.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 2 months 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/ia32/fast-codegen-ia32.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/x64/fast-codegen-x64.cc
===================================================================
--- src/x64/fast-codegen-x64.cc (revision 3178)
+++ src/x64/fast-codegen-x64.cc (working copy)
@@ -454,14 +454,44 @@
Comment cmnt(masm_, "[ Assignment");
ASSERT(expr->op() == Token::ASSIGN || expr->op() == Token::INIT_VAR);
- // Left-hand side can only be a global or a (parameter or local) slot.
+ // Record the source position for the assignment.
+ SetSourcePosition(expr->position());
+
+ // Left-hand side can only be a property, a global or
+ // a (parameter or local) slot.
Variable* var = expr->target()->AsVariableProxy()->AsVariable();
- ASSERT(var != NULL);
- ASSERT(var->is_global() || var->slot() != NULL);
-
Expression* rhs = expr->value();
- Location destination = expr->location();
- if (var->is_global()) {
+ if (var == NULL) {
+ // Assignment to a property.
+ ASSERT(expr->target()->AsProperty() != NULL);
+ Property* prop = expr->target()->AsProperty();
+ Visit(prop->obj());
+ Literal* literal_key = prop->key()->AsLiteral();
+ uint32_t dummy;
+ if (literal_key != NULL &&
+ literal_key->handle()->IsSymbol() &&
+ !String::cast(*(literal_key->handle()))->AsArrayIndex(&dummy)) {
+ // NAMED property assignment
+ Visit(rhs);
+ Move(rax, rhs->location());
+ __ Move(rcx, literal_key->handle());
+ Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize));
+ __ call(ic, RelocInfo::CODE_TARGET);
+ __ nop();
+ } else {
+ // KEYED property assignment
+ Visit(prop->key());
+ Visit(rhs);
+ Move(rax, rhs->location());
+ Handle<Code> ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize));
+ __ call(ic, RelocInfo::CODE_TARGET);
+ __ nop();
+ // Drop key from the stack
+ __ addq(rsp, Immediate(kPointerSize));
+ }
+ // Overwrite the receiver on the stack with the result if needed.
+ DropAndMove(expr->location(), rax);
+ } else if (var->is_global()) {
// Assignment to a global variable, use inline caching. Right-hand-side
// value is passed in rax, variable name in rcx, and the global object
// on the stack.
@@ -530,7 +560,7 @@
__ Move(rcx, key->AsLiteral()->handle());
Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize));
__ call(ic, RelocInfo::CODE_TARGET);
- // By emitting a nop we make sure that we do not have a "test eax,..."
+ // By emitting a nop we make sure that we do not have a "test rax,..."
// instruction after the call it is treated specially by the LoadIC code.
__ nop();
} else {
@@ -538,22 +568,13 @@
Visit(expr->key());
Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize));
__ call(ic, RelocInfo::CODE_TARGET);
- // By emitting a nop we make sure that we do not have a "test ..."
+ // By emitting a nop we make sure that we do not have a "test rax,..."
// instruction after the call it is treated specially by the LoadIC code.
__ nop();
// Drop key left on the stack by IC.
__ addq(rsp, Immediate(kPointerSize));
}
- switch (expr->location().type()) {
- case Location::kUninitialized:
- UNREACHABLE();
- case Location::kValue:
- __ movq(Operand(rsp, 0), rax);
- break;
- case Location::kEffect:
- __ addq(rsp, Immediate(kPointerSize));
- break;
- }
+ DropAndMove(expr->location(), rax);
}
« no previous file with comments | « src/ia32/fast-codegen-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698