Index: src/x64/full-codegen-x64.cc |
diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc |
index 6739cc84a24248a23fd864e8cc78f3d7770f5639..9699c9ed48ba7a52c380caa4ef355c9c95bd009d 100644 |
--- a/src/x64/full-codegen-x64.cc |
+++ b/src/x64/full-codegen-x64.cc |
@@ -1377,6 +1377,15 @@ void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { |
} |
+void FullCodeGenerator::EmitAccessor(Expression* expression) { |
+ if (expression == NULL) { |
+ __ PushRoot(Heap::kNullValueRootIndex); |
+ } else { |
+ VisitForStackValue(expression); |
+ } |
+} |
+ |
+ |
void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
Comment cmnt(masm_, "[ ObjectLiteral"); |
Handle<FixedArray> constant_properties = expr->constant_properties(); |
@@ -1411,6 +1420,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
// marked expressions, no store code is emitted. |
expr->CalculateEmitStore(); |
+ AccessorTable accessor_table(isolate()->zone()); |
for (int i = 0; i < expr->properties()->length(); i++) { |
ObjectLiteral::Property* property = expr->properties()->at(i); |
if (property->IsCompileTimeValue()) continue; |
@@ -1455,23 +1465,28 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
__ Drop(3); |
} |
break; |
- case ObjectLiteral::Property::SETTER: |
case ObjectLiteral::Property::GETTER: |
- __ push(Operand(rsp, 0)); // Duplicate receiver. |
- VisitForStackValue(key); |
- if (property->kind() == ObjectLiteral::Property::GETTER) { |
- VisitForStackValue(value); |
- __ PushRoot(Heap::kNullValueRootIndex); |
- } else { |
- __ PushRoot(Heap::kNullValueRootIndex); |
- VisitForStackValue(value); |
- } |
- __ Push(Smi::FromInt(NONE)); |
- __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5); |
+ accessor_table.find(key)->second->getter = value; |
+ break; |
+ case ObjectLiteral::Property::SETTER: |
+ accessor_table.find(key)->second->setter = value; |
break; |
} |
} |
+ // Emit code to define accessors, using only a single call to the runtime for |
+ // each pair of corresponding getters and setters. |
+ for (AccessorTable::Iterator it = accessor_table.begin(); |
+ it != accessor_table.end(); |
+ ++it) { |
+ __ push(Operand(rsp, 0)); // Duplicate receiver. |
+ VisitForStackValue(it->first); |
+ EmitAccessor(it->second->getter); |
+ EmitAccessor(it->second->setter); |
+ __ Push(Smi::FromInt(NONE)); |
+ __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5); |
+ } |
+ |
if (expr->has_function()) { |
ASSERT(result_saved); |
__ push(Operand(rsp, 0)); |