| Index: src/x64/full-codegen-x64.cc
|
| diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc
|
| index 1949c316cb1d9de1dfedeff644ad81417106aa2b..954d043a9f532ef260064b349a4f56bd17e87b36 100644
|
| --- a/src/x64/full-codegen-x64.cc
|
| +++ b/src/x64/full-codegen-x64.cc
|
| @@ -2118,15 +2118,37 @@ void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) {
|
| ASSERT(prop != NULL);
|
| ASSERT(prop->key()->AsLiteral() != NULL);
|
|
|
| + // If the assignment starts a block of assignments to the same object,
|
| + // change to slow case to avoid the quadratic behavior of repeatedly
|
| + // adding fast properties.
|
| + if (expr->starts_initialization_block()) {
|
| + __ push(result_register());
|
| + __ push(Operand(rsp, kPointerSize)); // Receiver is now under value.
|
| + __ CallRuntime(Runtime::kToSlowProperties, 1);
|
| + __ pop(result_register());
|
| + }
|
| +
|
| // Record source code position before IC call.
|
| SetSourcePosition(expr->position());
|
| __ Move(rcx, prop->key()->AsLiteral()->handle());
|
| - __ pop(rdx);
|
| + if (expr->ends_initialization_block()) {
|
| + __ movq(rdx, Operand(rsp, 0));
|
| + } else {
|
| + __ pop(rdx);
|
| + }
|
| Handle<Code> ic = is_classic_mode()
|
| ? isolate()->builtins()->StoreIC_Initialize()
|
| : isolate()->builtins()->StoreIC_Initialize_Strict();
|
| CallIC(ic, RelocInfo::CODE_TARGET, expr->AssignmentFeedbackId());
|
|
|
| + // If the assignment ends an initialization block, revert to fast case.
|
| + if (expr->ends_initialization_block()) {
|
| + __ push(rax); // Result of assignment, saved even if not needed.
|
| + __ push(Operand(rsp, kPointerSize)); // Receiver is under value.
|
| + __ CallRuntime(Runtime::kToFastProperties, 1);
|
| + __ pop(rax);
|
| + __ Drop(1);
|
| + }
|
| PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
|
| context()->Plug(rax);
|
| }
|
| @@ -2135,8 +2157,23 @@ void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) {
|
| void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) {
|
| // Assignment to a property, using a keyed store IC.
|
|
|
| + // If the assignment starts a block of assignments to the same object,
|
| + // change to slow case to avoid the quadratic behavior of repeatedly
|
| + // adding fast properties.
|
| + if (expr->starts_initialization_block()) {
|
| + __ push(result_register());
|
| + // Receiver is now under the key and value.
|
| + __ push(Operand(rsp, 2 * kPointerSize));
|
| + __ CallRuntime(Runtime::kToSlowProperties, 1);
|
| + __ pop(result_register());
|
| + }
|
| +
|
| __ pop(rcx);
|
| - __ pop(rdx);
|
| + if (expr->ends_initialization_block()) {
|
| + __ movq(rdx, Operand(rsp, 0)); // Leave receiver on the stack for later.
|
| + } else {
|
| + __ pop(rdx);
|
| + }
|
| // Record source code position before IC call.
|
| SetSourcePosition(expr->position());
|
| Handle<Code> ic = is_classic_mode()
|
| @@ -2144,6 +2181,15 @@ void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) {
|
| : isolate()->builtins()->KeyedStoreIC_Initialize_Strict();
|
| CallIC(ic, RelocInfo::CODE_TARGET, expr->AssignmentFeedbackId());
|
|
|
| + // If the assignment ends an initialization block, revert to fast case.
|
| + if (expr->ends_initialization_block()) {
|
| + __ pop(rdx);
|
| + __ push(rax); // Result of assignment, saved even if not needed.
|
| + __ push(rdx);
|
| + __ CallRuntime(Runtime::kToFastProperties, 1);
|
| + __ pop(rax);
|
| + }
|
| +
|
| PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
|
| context()->Plug(rax);
|
| }
|
|
|