Index: src/ia32/code-stubs-ia32.cc |
diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc |
index 9d7a66850ece98ef11976ce2771ffe4d0782e542..c685d223ccc8791903928e76f7f6d989b2c47786 100644 |
--- a/src/ia32/code-stubs-ia32.cc |
+++ b/src/ia32/code-stubs-ia32.cc |
@@ -2178,26 +2178,32 @@ void CallConstructStub::Generate(MacroAssembler* masm) { |
// eax: number of arguments |
// ecx: object map |
// esp[0]: original receiver (for IsSuperConstructorCall) |
- Label do_call; |
__ bind(&slow); |
- __ CmpInstanceType(ecx, JS_FUNCTION_PROXY_TYPE); |
- __ j(not_equal, &non_function_call); |
- __ GetBuiltinEntry(edx, |
- Context::CALL_FUNCTION_PROXY_AS_CONSTRUCTOR_BUILTIN_INDEX); |
- __ jmp(&do_call); |
- |
- __ bind(&non_function_call); |
- __ GetBuiltinEntry(edx, |
- Context::CALL_NON_FUNCTION_AS_CONSTRUCTOR_BUILTIN_INDEX); |
- __ bind(&do_call); |
- if (IsSuperConstructorCall()) { |
- __ Drop(1); |
+ { |
+ __ CmpInstanceType(ecx, JS_FUNCTION_PROXY_TYPE); |
+ __ j(not_equal, &non_function_call, Label::kNear); |
+ if (IsSuperConstructorCall()) __ Drop(1); |
+ // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. |
+ __ mov(edi, FieldOperand(edi, JSFunctionProxy::kConstructTrapOffset)); |
+ __ Jump(isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
+ |
+ __ bind(&non_function_call); |
+ if (IsSuperConstructorCall()) __ Drop(1); |
+ { |
+ // Determine the delegate for the target (if any). |
+ FrameScope scope(masm, StackFrame::INTERNAL); |
+ __ SmiTag(eax); |
+ __ Push(eax); |
+ __ Push(edi); |
+ __ CallRuntime(Runtime::kGetConstructorDelegate, 1); |
+ __ mov(edi, eax); |
+ __ Pop(eax); |
+ __ SmiUntag(eax); |
+ } |
+ // The delegate is always a regular function. |
+ __ AssertFunction(edi); |
+ __ Jump(isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET); |
} |
- // Set expected number of arguments to zero (not changing eax). |
- __ Move(ebx, Immediate(0)); |
- Handle<Code> arguments_adaptor = |
- isolate()->builtins()->ArgumentsAdaptorTrampoline(); |
- __ jmp(arguments_adaptor, RelocInfo::CODE_TARGET); |
} |