| Index: src/builtins/arm/builtins-arm.cc
|
| diff --git a/src/builtins/arm/builtins-arm.cc b/src/builtins/arm/builtins-arm.cc
|
| index f20b3a64a3e769ba20c10bfbab62cace7d3ee607..779fba4ee8741b43aee3ae9f2d384518e5b0a6aa 100644
|
| --- a/src/builtins/arm/builtins-arm.cc
|
| +++ b/src/builtins/arm/builtins-arm.cc
|
| @@ -1148,7 +1148,7 @@ static void Generate_InterpreterPushArgs(MacroAssembler* masm,
|
| // static
|
| void Builtins::Generate_InterpreterPushArgsAndCallImpl(
|
| MacroAssembler* masm, TailCallMode tail_call_mode,
|
| - CallableType function_type) {
|
| + InterpreterPushArgsMode mode) {
|
| // ----------- S t a t e -------------
|
| // -- r0 : the number of arguments (not including the receiver)
|
| // -- r2 : the address of the first argument to be pushed. Subsequent
|
| @@ -1164,12 +1164,14 @@ void Builtins::Generate_InterpreterPushArgsAndCallImpl(
|
| Generate_InterpreterPushArgs(masm, r3, r2, r4, r5, &stack_overflow);
|
|
|
| // Call the target.
|
| - if (function_type == CallableType::kJSFunction) {
|
| + if (mode == InterpreterPushArgsMode::kJSFunction) {
|
| __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny,
|
| tail_call_mode),
|
| RelocInfo::CODE_TARGET);
|
| + } else if (mode == InterpreterPushArgsMode::kWithFinalSpread) {
|
| + __ Jump(masm->isolate()->builtins()->CallWithSpread(),
|
| + RelocInfo::CODE_TARGET);
|
| } else {
|
| - DCHECK_EQ(function_type, CallableType::kAny);
|
| __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny,
|
| tail_call_mode),
|
| RelocInfo::CODE_TARGET);
|
| @@ -1185,7 +1187,7 @@ void Builtins::Generate_InterpreterPushArgsAndCallImpl(
|
|
|
| // static
|
| void Builtins::Generate_InterpreterPushArgsAndConstructImpl(
|
| - MacroAssembler* masm, PushArgsConstructMode mode) {
|
| + MacroAssembler* masm, InterpreterPushArgsMode mode) {
|
| // ----------- S t a t e -------------
|
| // -- r0 : argument count (not including receiver)
|
| // -- r3 : new target
|
| @@ -1203,7 +1205,7 @@ void Builtins::Generate_InterpreterPushArgsAndConstructImpl(
|
| Generate_InterpreterPushArgs(masm, r0, r4, r5, r6, &stack_overflow);
|
|
|
| __ AssertUndefinedOrAllocationSite(r2, r5);
|
| - if (mode == PushArgsConstructMode::kJSFunction) {
|
| + if (mode == InterpreterPushArgsMode::kJSFunction) {
|
| __ AssertFunction(r1);
|
|
|
| // Tail call to the function-specific construct stub (still in the caller
|
| @@ -1212,12 +1214,12 @@ void Builtins::Generate_InterpreterPushArgsAndConstructImpl(
|
| __ ldr(r4, FieldMemOperand(r4, SharedFunctionInfo::kConstructStubOffset));
|
| // Jump to the construct function.
|
| __ add(pc, r4, Operand(Code::kHeaderSize - kHeapObjectTag));
|
| - } else if (mode == PushArgsConstructMode::kWithFinalSpread) {
|
| + } else if (mode == InterpreterPushArgsMode::kWithFinalSpread) {
|
| // Call the constructor with r0, r1, and r3 unmodified.
|
| __ Jump(masm->isolate()->builtins()->ConstructWithSpread(),
|
| RelocInfo::CODE_TARGET);
|
| } else {
|
| - DCHECK_EQ(PushArgsConstructMode::kOther, mode);
|
| + DCHECK_EQ(InterpreterPushArgsMode::kOther, mode);
|
| // Call the constructor with r0, r1, and r3 unmodified.
|
| __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
|
| }
|
| @@ -2617,129 +2619,7 @@ void Builtins::Generate_Call(MacroAssembler* masm, ConvertReceiverMode mode,
|
| }
|
| }
|
|
|
| -// static
|
| -void Builtins::Generate_ConstructFunction(MacroAssembler* masm) {
|
| - // ----------- S t a t e -------------
|
| - // -- r0 : the number of arguments (not including the receiver)
|
| - // -- r1 : the constructor to call (checked to be a JSFunction)
|
| - // -- r3 : the new target (checked to be a constructor)
|
| - // -----------------------------------
|
| - __ AssertFunction(r1);
|
| -
|
| - // Calling convention for function specific ConstructStubs require
|
| - // r2 to contain either an AllocationSite or undefined.
|
| - __ LoadRoot(r2, Heap::kUndefinedValueRootIndex);
|
| -
|
| - // Tail call to the function-specific construct stub (still in the caller
|
| - // context at this point).
|
| - __ ldr(r4, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset));
|
| - __ ldr(r4, FieldMemOperand(r4, SharedFunctionInfo::kConstructStubOffset));
|
| - __ add(pc, r4, Operand(Code::kHeaderSize - kHeapObjectTag));
|
| -}
|
| -
|
| -// static
|
| -void Builtins::Generate_ConstructBoundFunction(MacroAssembler* masm) {
|
| - // ----------- S t a t e -------------
|
| - // -- r0 : the number of arguments (not including the receiver)
|
| - // -- r1 : the function to call (checked to be a JSBoundFunction)
|
| - // -- r3 : the new target (checked to be a constructor)
|
| - // -----------------------------------
|
| - __ AssertBoundFunction(r1);
|
| -
|
| - // Push the [[BoundArguments]] onto the stack.
|
| - Generate_PushBoundArguments(masm);
|
| -
|
| - // Patch new.target to [[BoundTargetFunction]] if new.target equals target.
|
| - __ cmp(r1, r3);
|
| - __ ldr(r3, FieldMemOperand(r1, JSBoundFunction::kBoundTargetFunctionOffset),
|
| - eq);
|
| -
|
| - // Construct the [[BoundTargetFunction]] via the Construct builtin.
|
| - __ ldr(r1, FieldMemOperand(r1, JSBoundFunction::kBoundTargetFunctionOffset));
|
| - __ mov(ip, Operand(ExternalReference(Builtins::kConstruct, masm->isolate())));
|
| - __ ldr(ip, MemOperand(ip));
|
| - __ add(pc, ip, Operand(Code::kHeaderSize - kHeapObjectTag));
|
| -}
|
| -
|
| -// static
|
| -void Builtins::Generate_ConstructProxy(MacroAssembler* masm) {
|
| - // ----------- S t a t e -------------
|
| - // -- r0 : the number of arguments (not including the receiver)
|
| - // -- r1 : the constructor to call (checked to be a JSProxy)
|
| - // -- r3 : the new target (either the same as the constructor or
|
| - // the JSFunction on which new was invoked initially)
|
| - // -----------------------------------
|
| -
|
| - // Call into the Runtime for Proxy [[Construct]].
|
| - __ Push(r1);
|
| - __ Push(r3);
|
| - // Include the pushed new_target, constructor and the receiver.
|
| - __ add(r0, r0, Operand(3));
|
| - // Tail-call to the runtime.
|
| - __ JumpToExternalReference(
|
| - ExternalReference(Runtime::kJSProxyConstruct, masm->isolate()));
|
| -}
|
| -
|
| -// static
|
| -void Builtins::Generate_Construct(MacroAssembler* masm) {
|
| - // ----------- S t a t e -------------
|
| - // -- r0 : the number of arguments (not including the receiver)
|
| - // -- r1 : the constructor to call (can be any Object)
|
| - // -- r3 : the new target (either the same as the constructor or
|
| - // the JSFunction on which new was invoked initially)
|
| - // -----------------------------------
|
| -
|
| - // Check if target is a Smi.
|
| - Label non_constructor;
|
| - __ JumpIfSmi(r1, &non_constructor);
|
| -
|
| - // Dispatch based on instance type.
|
| - __ CompareObjectType(r1, r4, r5, JS_FUNCTION_TYPE);
|
| - __ Jump(masm->isolate()->builtins()->ConstructFunction(),
|
| - RelocInfo::CODE_TARGET, eq);
|
| -
|
| - // Check if target has a [[Construct]] internal method.
|
| - __ ldrb(r2, FieldMemOperand(r4, Map::kBitFieldOffset));
|
| - __ tst(r2, Operand(1 << Map::kIsConstructor));
|
| - __ b(eq, &non_constructor);
|
| -
|
| - // Only dispatch to bound functions after checking whether they are
|
| - // constructors.
|
| - __ cmp(r5, Operand(JS_BOUND_FUNCTION_TYPE));
|
| - __ Jump(masm->isolate()->builtins()->ConstructBoundFunction(),
|
| - RelocInfo::CODE_TARGET, eq);
|
| -
|
| - // Only dispatch to proxies after checking whether they are constructors.
|
| - __ cmp(r5, Operand(JS_PROXY_TYPE));
|
| - __ Jump(masm->isolate()->builtins()->ConstructProxy(), RelocInfo::CODE_TARGET,
|
| - eq);
|
| -
|
| - // Called Construct on an exotic Object with a [[Construct]] internal method.
|
| - {
|
| - // Overwrite the original receiver with the (original) target.
|
| - __ str(r1, MemOperand(sp, r0, LSL, kPointerSizeLog2));
|
| - // Let the "call_as_constructor_delegate" take care of the rest.
|
| - __ LoadNativeContextSlot(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, r1);
|
| - __ Jump(masm->isolate()->builtins()->CallFunction(),
|
| - RelocInfo::CODE_TARGET);
|
| - }
|
| -
|
| - // Called Construct on an Object that doesn't have a [[Construct]] internal
|
| - // method.
|
| - __ bind(&non_constructor);
|
| - __ Jump(masm->isolate()->builtins()->ConstructedNonConstructable(),
|
| - RelocInfo::CODE_TARGET);
|
| -}
|
| -
|
| -// static
|
| -void Builtins::Generate_ConstructWithSpread(MacroAssembler* masm) {
|
| - // ----------- S t a t e -------------
|
| - // -- r0 : the number of arguments (not including the receiver)
|
| - // -- r1 : the constructor to call (can be any Object)
|
| - // -- r3 : the new target (either the same as the constructor or
|
| - // the JSFunction on which new was invoked initially)
|
| - // -----------------------------------
|
| -
|
| +static void CheckSpreadAndPushToStack(MacroAssembler* masm) {
|
| Register argc = r0;
|
| Register constructor = r1;
|
| Register new_target = r3;
|
| @@ -2749,6 +2629,9 @@ void Builtins::Generate_ConstructWithSpread(MacroAssembler* masm) {
|
|
|
| Register spread = r4;
|
| Register spread_map = r5;
|
| +
|
| + Register spread_len = r5;
|
| +
|
| __ ldr(spread, MemOperand(sp, 0));
|
| __ ldr(spread_map, FieldMemOperand(spread, HeapObject::kMapOffset));
|
|
|
| @@ -2803,7 +2686,9 @@ void Builtins::Generate_ConstructWithSpread(MacroAssembler* masm) {
|
| __ b(ne, &runtime_call);
|
|
|
| __ bind(&no_protector_check);
|
| - // Load the FixedArray backing store.
|
| + // Load the FixedArray backing store, but use the length from the array.
|
| + __ ldr(spread_len, FieldMemOperand(spread, JSArray::kLengthOffset));
|
| + __ SmiUntag(spread_len);
|
| __ ldr(spread, FieldMemOperand(spread, JSArray::kElementsOffset));
|
| __ b(&push_args);
|
|
|
| @@ -2824,17 +2709,18 @@ void Builtins::Generate_ConstructWithSpread(MacroAssembler* masm) {
|
| __ SmiUntag(argc);
|
| }
|
|
|
| - Register spread_len = r5;
|
| - __ bind(&push_args);
|
| {
|
| - // Pop the spread argument off the stack.
|
| - __ Pop(scratch);
|
| // Calculate the new nargs including the result of the spread.
|
| __ ldr(spread_len, FieldMemOperand(spread, FixedArray::kLengthOffset));
|
| __ SmiUntag(spread_len);
|
| +
|
| + __ bind(&push_args);
|
| // argc += spread_len - 1. Subtract 1 for the spread itself.
|
| __ add(argc, argc, spread_len);
|
| __ sub(argc, argc, Operand(1));
|
| +
|
| + // Pop the spread argument off the stack.
|
| + __ Pop(scratch);
|
| }
|
|
|
| // Check for stack overflow.
|
| @@ -2867,8 +2753,147 @@ void Builtins::Generate_ConstructWithSpread(MacroAssembler* masm) {
|
| __ b(&loop);
|
| __ bind(&done);
|
| }
|
| +}
|
| +
|
| +// static
|
| +void Builtins::Generate_CallWithSpread(MacroAssembler* masm) {
|
| + // ----------- S t a t e -------------
|
| + // -- r0 : the number of arguments (not including the receiver)
|
| + // -- r1 : the constructor to call (can be any Object)
|
| + // -----------------------------------
|
| +
|
| + // CheckSpreadAndPushToStack will push r3 to save it.
|
| + __ LoadRoot(r3, Heap::kUndefinedValueRootIndex);
|
| + CheckSpreadAndPushToStack(masm);
|
| + __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny,
|
| + TailCallMode::kDisallow),
|
| + RelocInfo::CODE_TARGET);
|
| +}
|
| +
|
| +// static
|
| +void Builtins::Generate_ConstructFunction(MacroAssembler* masm) {
|
| + // ----------- S t a t e -------------
|
| + // -- r0 : the number of arguments (not including the receiver)
|
| + // -- r1 : the constructor to call (checked to be a JSFunction)
|
| + // -- r3 : the new target (checked to be a constructor)
|
| + // -----------------------------------
|
| + __ AssertFunction(r1);
|
| +
|
| + // Calling convention for function specific ConstructStubs require
|
| + // r2 to contain either an AllocationSite or undefined.
|
| + __ LoadRoot(r2, Heap::kUndefinedValueRootIndex);
|
| +
|
| + // Tail call to the function-specific construct stub (still in the caller
|
| + // context at this point).
|
| + __ ldr(r4, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset));
|
| + __ ldr(r4, FieldMemOperand(r4, SharedFunctionInfo::kConstructStubOffset));
|
| + __ add(pc, r4, Operand(Code::kHeaderSize - kHeapObjectTag));
|
| +}
|
| +
|
| +// static
|
| +void Builtins::Generate_ConstructBoundFunction(MacroAssembler* masm) {
|
| + // ----------- S t a t e -------------
|
| + // -- r0 : the number of arguments (not including the receiver)
|
| + // -- r1 : the function to call (checked to be a JSBoundFunction)
|
| + // -- r3 : the new target (checked to be a constructor)
|
| + // -----------------------------------
|
| + __ AssertBoundFunction(r1);
|
| +
|
| + // Push the [[BoundArguments]] onto the stack.
|
| + Generate_PushBoundArguments(masm);
|
| +
|
| + // Patch new.target to [[BoundTargetFunction]] if new.target equals target.
|
| + __ cmp(r1, r3);
|
| + __ ldr(r3, FieldMemOperand(r1, JSBoundFunction::kBoundTargetFunctionOffset),
|
| + eq);
|
| +
|
| + // Construct the [[BoundTargetFunction]] via the Construct builtin.
|
| + __ ldr(r1, FieldMemOperand(r1, JSBoundFunction::kBoundTargetFunctionOffset));
|
| + __ mov(ip, Operand(ExternalReference(Builtins::kConstruct, masm->isolate())));
|
| + __ ldr(ip, MemOperand(ip));
|
| + __ add(pc, ip, Operand(Code::kHeaderSize - kHeapObjectTag));
|
| +}
|
| +
|
| +// static
|
| +void Builtins::Generate_ConstructProxy(MacroAssembler* masm) {
|
| + // ----------- S t a t e -------------
|
| + // -- r0 : the number of arguments (not including the receiver)
|
| + // -- r1 : the constructor to call (checked to be a JSProxy)
|
| + // -- r3 : the new target (either the same as the constructor or
|
| + // the JSFunction on which new was invoked initially)
|
| + // -----------------------------------
|
| +
|
| + // Call into the Runtime for Proxy [[Construct]].
|
| + __ Push(r1);
|
| + __ Push(r3);
|
| + // Include the pushed new_target, constructor and the receiver.
|
| + __ add(r0, r0, Operand(3));
|
| + // Tail-call to the runtime.
|
| + __ JumpToExternalReference(
|
| + ExternalReference(Runtime::kJSProxyConstruct, masm->isolate()));
|
| +}
|
| +
|
| +// static
|
| +void Builtins::Generate_Construct(MacroAssembler* masm) {
|
| + // ----------- S t a t e -------------
|
| + // -- r0 : the number of arguments (not including the receiver)
|
| + // -- r1 : the constructor to call (can be any Object)
|
| + // -- r3 : the new target (either the same as the constructor or
|
| + // the JSFunction on which new was invoked initially)
|
| + // -----------------------------------
|
| +
|
| + // Check if target is a Smi.
|
| + Label non_constructor;
|
| + __ JumpIfSmi(r1, &non_constructor);
|
| +
|
| + // Dispatch based on instance type.
|
| + __ CompareObjectType(r1, r4, r5, JS_FUNCTION_TYPE);
|
| + __ Jump(masm->isolate()->builtins()->ConstructFunction(),
|
| + RelocInfo::CODE_TARGET, eq);
|
| +
|
| + // Check if target has a [[Construct]] internal method.
|
| + __ ldrb(r2, FieldMemOperand(r4, Map::kBitFieldOffset));
|
| + __ tst(r2, Operand(1 << Map::kIsConstructor));
|
| + __ b(eq, &non_constructor);
|
| +
|
| + // Only dispatch to bound functions after checking whether they are
|
| + // constructors.
|
| + __ cmp(r5, Operand(JS_BOUND_FUNCTION_TYPE));
|
| + __ Jump(masm->isolate()->builtins()->ConstructBoundFunction(),
|
| + RelocInfo::CODE_TARGET, eq);
|
| +
|
| + // Only dispatch to proxies after checking whether they are constructors.
|
| + __ cmp(r5, Operand(JS_PROXY_TYPE));
|
| + __ Jump(masm->isolate()->builtins()->ConstructProxy(), RelocInfo::CODE_TARGET,
|
| + eq);
|
| +
|
| + // Called Construct on an exotic Object with a [[Construct]] internal method.
|
| + {
|
| + // Overwrite the original receiver with the (original) target.
|
| + __ str(r1, MemOperand(sp, r0, LSL, kPointerSizeLog2));
|
| + // Let the "call_as_constructor_delegate" take care of the rest.
|
| + __ LoadNativeContextSlot(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, r1);
|
| + __ Jump(masm->isolate()->builtins()->CallFunction(),
|
| + RelocInfo::CODE_TARGET);
|
| + }
|
| +
|
| + // Called Construct on an Object that doesn't have a [[Construct]] internal
|
| + // method.
|
| + __ bind(&non_constructor);
|
| + __ Jump(masm->isolate()->builtins()->ConstructedNonConstructable(),
|
| + RelocInfo::CODE_TARGET);
|
| +}
|
| +
|
| +// static
|
| +void Builtins::Generate_ConstructWithSpread(MacroAssembler* masm) {
|
| + // ----------- S t a t e -------------
|
| + // -- r0 : the number of arguments (not including the receiver)
|
| + // -- r1 : the constructor to call (can be any Object)
|
| + // -- r3 : the new target (either the same as the constructor or
|
| + // the JSFunction on which new was invoked initially)
|
| + // -----------------------------------
|
|
|
| - // Dispatch.
|
| + CheckSpreadAndPushToStack(masm);
|
| __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
|
| }
|
|
|
|
|