| Index: src/arm64/builtins-arm64.cc
|
| diff --git a/src/arm64/builtins-arm64.cc b/src/arm64/builtins-arm64.cc
|
| index afa3b077f1da228a2acfa44e2fca13e64013ca36..433119801761b43f02cfb997a2268249e4284262 100644
|
| --- a/src/arm64/builtins-arm64.cc
|
| +++ b/src/arm64/builtins-arm64.cc
|
| @@ -1693,6 +1693,21 @@ void Builtins::Generate_ConstructFunction(MacroAssembler* masm) {
|
|
|
|
|
| // static
|
| +void Builtins::Generate_ConstructProxy(MacroAssembler* masm) {
|
| + // ----------- S t a t e -------------
|
| + // -- x0 : the number of arguments (not including the receiver)
|
| + // -- x1 : the constructor to call (checked to be a JSFunctionProxy)
|
| + // -- x3 : the original constructor (either the same as the constructor or
|
| + // the JSFunction on which new was invoked initially)
|
| + // -----------------------------------
|
| +
|
| + // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies.
|
| + __ Ldr(x1, FieldMemOperand(x1, JSFunctionProxy::kConstructTrapOffset));
|
| + __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
|
| +}
|
| +
|
| +
|
| +// static
|
| void Builtins::Generate_Construct(MacroAssembler* masm) {
|
| // ----------- S t a t e -------------
|
| // -- x0 : the number of arguments (not including the receiver)
|
| @@ -1701,34 +1716,34 @@ void Builtins::Generate_Construct(MacroAssembler* masm) {
|
| // the JSFunction on which new was invoked initially)
|
| // -----------------------------------
|
|
|
| - Label non_callable, non_function;
|
| - __ JumpIfSmi(x1, &non_callable);
|
| - __ CompareObjectType(x1, x4, x5, JS_FUNCTION_TYPE);
|
| + // Check if target has a [[Construct]] internal method.
|
| + Label non_constructor;
|
| + __ JumpIfSmi(x1, &non_constructor);
|
| + __ Ldr(x4, FieldMemOperand(x1, HeapObject::kMapOffset));
|
| + __ Ldrb(x2, FieldMemOperand(x4, Map::kBitFieldOffset));
|
| + __ TestAndBranchIfAllClear(x2, 1 << Map::kIsConstructor, &non_constructor);
|
| +
|
| + // Dispatch based on instance type.
|
| + __ CompareInstanceType(x4, x5, JS_FUNCTION_TYPE);
|
| __ Jump(masm->isolate()->builtins()->ConstructFunction(),
|
| RelocInfo::CODE_TARGET, eq);
|
| __ Cmp(x5, JS_FUNCTION_PROXY_TYPE);
|
| - __ B(ne, &non_function);
|
| -
|
| - // 1. Construct of function proxy.
|
| - // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies.
|
| - __ Ldr(x1, FieldMemOperand(x1, JSFunctionProxy::kConstructTrapOffset));
|
| - __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
|
| + __ Jump(masm->isolate()->builtins()->ConstructProxy(), RelocInfo::CODE_TARGET,
|
| + eq);
|
|
|
| - // 2. Construct of something that else, which might have a [[Construct]]
|
| - // internal method (if not we raise an exception).
|
| - __ Bind(&non_function);
|
| - // Check if target has a [[Call]] internal method.
|
| - // TODO(bmeurer): This shoud use IsConstructor once available.
|
| - __ Ldrb(x4, FieldMemOperand(x4, Map::kBitFieldOffset));
|
| - __ TestAndBranchIfAllClear(x4, 1 << Map::kIsCallable, &non_callable);
|
| - // Overwrite the original receiver with the (original) target.
|
| - __ Poke(x1, Operand(x0, LSL, kXRegSizeLog2));
|
| - // Let the "call_as_constructor_delegate" take care of the rest.
|
| - __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, x1);
|
| - __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET);
|
| + // Called Construct on an exotic Object with a [[Construct]] internal method.
|
| + {
|
| + // Overwrite the original receiver with the (original) target.
|
| + __ Poke(x1, Operand(x0, LSL, kXRegSizeLog2));
|
| + // Let the "call_as_constructor_delegate" take care of the rest.
|
| + __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, x1);
|
| + __ Jump(masm->isolate()->builtins()->CallFunction(),
|
| + RelocInfo::CODE_TARGET);
|
| + }
|
|
|
| - // 3. Construct of something that is not callable.
|
| - __ bind(&non_callable);
|
| + // Called Construct on an Object that doesn't have a [[Construct]] internal
|
| + // method.
|
| + __ bind(&non_constructor);
|
| {
|
| FrameScope scope(masm, StackFrame::INTERNAL);
|
| __ Push(x1);
|
|
|