Chromium Code Reviews| Index: src/ia32/builtins-ia32.cc |
| diff --git a/src/ia32/builtins-ia32.cc b/src/ia32/builtins-ia32.cc |
| index 5767489660dd57e6d3fc572ca1b1d250dde53722..8e7e83a0b2034ecd4c5a46ca716293ce1605b5bf 100644 |
| --- a/src/ia32/builtins-ia32.cc |
| +++ b/src/ia32/builtins-ia32.cc |
| @@ -107,6 +107,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
| // -- eax: number of arguments |
| // -- edi: constructor function |
| // -- ebx: allocation site or undefined |
| + // -- edx: original constructor |
| // ----------------------------------- |
| // Should never create mementos for api functions. |
| @@ -128,9 +129,50 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
| // Push the function to invoke on the stack. |
| __ push(edi); |
| + __ cmp(edx, edi); |
| + Label normal_new; |
| + Label count_incremented; |
| + Label allocated; |
| + __ j(equal, &normal_new); |
| + |
| + // Original constructor and function are different. |
| + { |
| + int offset = 0; |
| + if (create_memento) { |
| + // Get the cell or allocation site. |
| + __ mov(edi, Operand(esp, kPointerSize * 2)); |
| + __ push(edi); |
| + offset = kPointerSize; |
| + } |
| + |
| + // Must restore esi (context) and edi (constructor) before calling |
| + // runtime. |
| + __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
| + __ mov(edi, Operand(esp, offset)); |
| + __ push(edx); |
| + __ push(edi); |
| + if (create_memento) { |
| + __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 3); |
| + } else { |
| + __ CallRuntime(Runtime::kNewObject, 2); |
| + } |
| + __ mov(ebx, eax); // store result in ebx |
| + |
| + // If we ended up using the runtime, and we want a memento, then the |
| + // runtime call made it for us, and we shouldn't do create count |
|
arv (Not doing code reviews)
2015/01/21 19:18:55
this sentence could use some polish
Dmitry Lomov (no reviews)
2015/01/22 11:59:00
Done, also removed code duplication.
|
| + // increment. |
| + if (create_memento) { |
| + __ jmp(&count_incremented); |
| + } else { |
| + __ jmp(&allocated); |
| + } |
| + } |
| + |
| + __ bind(&normal_new); |
| + |
| // Try to allocate the object without transitioning into C code. If any of |
| // the preconditions is not met, the code bails out to the runtime call. |
| - Label rt_call, allocated; |
| + Label rt_call; |
| if (FLAG_inline_new) { |
| Label undo_allocation; |
| ExternalReference debug_step_in_fp = |
| @@ -355,19 +397,19 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
| // Must restore esi (context) and edi (constructor) before calling runtime. |
| __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
| __ mov(edi, Operand(esp, offset)); |
| + __ push(edi); |
| // edi: function (constructor) |
| __ push(edi); |
| if (create_memento) { |
| - __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 2); |
| + __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 3); |
| } else { |
| - __ CallRuntime(Runtime::kNewObject, 1); |
| + __ CallRuntime(Runtime::kNewObject, 2); |
| } |
| __ mov(ebx, eax); // store result in ebx |
| // If we ended up using the runtime, and we want a memento, then the |
| // runtime call made it for us, and we shouldn't do create count |
| // increment. |
| - Label count_incremented; |
| if (create_memento) { |
| __ jmp(&count_incremented); |
| } |