| Index: src/ia32/builtins-ia32.cc
|
| diff --git a/src/ia32/builtins-ia32.cc b/src/ia32/builtins-ia32.cc
|
| index 9a01fb96f53f7ec7b72e5808c02fcf089ee8757e..c6d09d7875fec1f3c44a96586aa54994ad5b1c32 100644
|
| --- a/src/ia32/builtins-ia32.cc
|
| +++ b/src/ia32/builtins-ia32.cc
|
| @@ -953,200 +953,218 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) {
|
| }
|
|
|
|
|
| -static void Generate_PushAppliedArguments(MacroAssembler* masm,
|
| - const int vectorOffset,
|
| - const int argumentsOffset,
|
| - const int indexOffset,
|
| - const int limitOffset) {
|
| - // Copy all arguments from the array to the stack.
|
| - Label entry, loop;
|
| - Register receiver = LoadDescriptor::ReceiverRegister();
|
| - Register key = LoadDescriptor::NameRegister();
|
| - Register slot = LoadDescriptor::SlotRegister();
|
| - Register vector = LoadWithVectorDescriptor::VectorRegister();
|
| - __ mov(key, Operand(ebp, indexOffset));
|
| - __ jmp(&entry);
|
| - __ bind(&loop);
|
| - __ mov(receiver, Operand(ebp, argumentsOffset)); // load arguments
|
| -
|
| - // Use inline caching to speed up access to arguments.
|
| - int slot_index = TypeFeedbackVector::PushAppliedArgumentsIndex();
|
| - __ mov(slot, Immediate(Smi::FromInt(slot_index)));
|
| - __ mov(vector, Operand(ebp, vectorOffset));
|
| - Handle<Code> ic =
|
| - KeyedLoadICStub(masm->isolate(), LoadICState(kNoExtraICState)).GetCode();
|
| - __ call(ic, RelocInfo::CODE_TARGET);
|
| - // It is important that we do not have a test instruction after the
|
| - // call. A test instruction after the call is used to indicate that
|
| - // we have generated an inline version of the keyed load. In this
|
| - // case, we know that we are not generating a test instruction next.
|
| -
|
| - // Push the nth argument.
|
| - __ push(eax);
|
| -
|
| - // Update the index on the stack and in register key.
|
| - __ mov(key, Operand(ebp, indexOffset));
|
| - __ add(key, Immediate(1 << kSmiTagSize));
|
| - __ mov(Operand(ebp, indexOffset), key);
|
| -
|
| - __ bind(&entry);
|
| - __ cmp(key, Operand(ebp, limitOffset));
|
| - __ j(not_equal, &loop);
|
| -
|
| - // On exit, the pushed arguments count is in eax, untagged
|
| - __ Move(eax, key);
|
| - __ SmiUntag(eax);
|
| -}
|
| -
|
| -
|
| -// Used by FunctionApply and ReflectApply
|
| -static void Generate_ApplyHelper(MacroAssembler* masm, bool targetIsArgument) {
|
| - const int kFormalParameters = targetIsArgument ? 3 : 2;
|
| - const int kStackSize = kFormalParameters + 1;
|
| +void Builtins::Generate_FunctionApply(MacroAssembler* masm) {
|
| + // ----------- S t a t e -------------
|
| + // -- eax : argc
|
| + // -- esp[0] : return address
|
| + // -- esp[4] : argArray
|
| + // -- esp[8] : thisArg
|
| + // -- esp[12] : receiver
|
| + // -----------------------------------
|
|
|
| - // Stack at entry:
|
| - // esp : return address
|
| - // esp[4] : arguments
|
| - // esp[8] : receiver ("this")
|
| - // esp[12] : function
|
| + // 1. Load receiver into edi, argArray into eax (if present), remove all
|
| + // arguments from the stack (including the receiver), and push thisArg (if
|
| + // present) instead.
|
| {
|
| - FrameScope frame_scope(masm, StackFrame::INTERNAL);
|
| - // Stack frame:
|
| - // ebp : Old base pointer
|
| - // ebp[4] : return address
|
| - // ebp[8] : function arguments
|
| - // ebp[12] : receiver
|
| - // ebp[16] : function
|
| - static const int kArgumentsOffset = kFPOnStackSize + kPCOnStackSize;
|
| - static const int kReceiverOffset = kArgumentsOffset + kPointerSize;
|
| - static const int kFunctionOffset = kReceiverOffset + kPointerSize;
|
| - static const int kVectorOffset =
|
| - InternalFrameConstants::kCodeOffset - 1 * kPointerSize;
|
| -
|
| - // Push the vector.
|
| - __ mov(edi, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
|
| - __ mov(edi, FieldOperand(edi, SharedFunctionInfo::kFeedbackVectorOffset));
|
| - __ push(edi);
|
| -
|
| - __ push(Operand(ebp, kFunctionOffset)); // push this
|
| - __ push(Operand(ebp, kArgumentsOffset)); // push arguments
|
| - if (targetIsArgument) {
|
| - __ InvokeBuiltin(Context::REFLECT_APPLY_PREPARE_BUILTIN_INDEX,
|
| - CALL_FUNCTION);
|
| - } else {
|
| - __ InvokeBuiltin(Context::APPLY_PREPARE_BUILTIN_INDEX, CALL_FUNCTION);
|
| + Label no_arg_array, no_this_arg;
|
| + __ LoadRoot(edx, Heap::kUndefinedValueRootIndex);
|
| + __ mov(ebx, edx);
|
| + __ mov(edi, Operand(esp, eax, times_pointer_size, kPointerSize));
|
| + __ test(eax, eax);
|
| + __ j(zero, &no_this_arg, Label::kNear);
|
| + {
|
| + __ mov(edx, Operand(esp, eax, times_pointer_size, 0));
|
| + __ cmp(eax, Immediate(1));
|
| + __ j(equal, &no_arg_array, Label::kNear);
|
| + __ mov(ebx, Operand(esp, eax, times_pointer_size, -kPointerSize));
|
| + __ bind(&no_arg_array);
|
| }
|
| + __ bind(&no_this_arg);
|
| + __ PopReturnAddressTo(ecx);
|
| + __ lea(esp, Operand(esp, eax, times_pointer_size, kPointerSize));
|
| + __ Push(edx);
|
| + __ PushReturnAddressFrom(ecx);
|
| + __ Move(eax, ebx);
|
| + }
|
|
|
| - Generate_CheckStackOverflow(masm, kEaxIsSmiTagged);
|
| + // ----------- S t a t e -------------
|
| + // -- eax : argArray
|
| + // -- edi : receiver
|
| + // -- esp[0] : return address
|
| + // -- esp[4] : thisArg
|
| + // -----------------------------------
|
|
|
| - // Push current index and limit.
|
| - const int kLimitOffset = kVectorOffset - 1 * kPointerSize;
|
| - const int kIndexOffset = kLimitOffset - 1 * kPointerSize;
|
| - __ Push(eax); // limit
|
| - __ Push(Immediate(0)); // index
|
| - __ Push(Operand(ebp, kReceiverOffset)); // receiver
|
| + // 2. Make sure the receiver is actually callable.
|
| + Label receiver_not_callable;
|
| + __ JumpIfSmi(edi, &receiver_not_callable, Label::kNear);
|
| + __ mov(ecx, FieldOperand(edi, HeapObject::kMapOffset));
|
| + __ test_b(FieldOperand(ecx, Map::kBitFieldOffset), 1 << Map::kIsCallable);
|
| + __ j(zero, &receiver_not_callable, Label::kNear);
|
| +
|
| + // 3. Tail call with no arguments if argArray is null or undefined.
|
| + Label no_arguments;
|
| + __ JumpIfRoot(eax, Heap::kNullValueRootIndex, &no_arguments, Label::kNear);
|
| + __ JumpIfRoot(eax, Heap::kUndefinedValueRootIndex, &no_arguments,
|
| + Label::kNear);
|
|
|
| - // Loop over the arguments array, pushing each value to the stack
|
| - Generate_PushAppliedArguments(masm, kVectorOffset, kArgumentsOffset,
|
| - kIndexOffset, kLimitOffset);
|
| + // 4a. Apply the receiver to the given argArray (passing undefined for
|
| + // new.target).
|
| + __ LoadRoot(edx, Heap::kUndefinedValueRootIndex);
|
| + __ Jump(masm->isolate()->builtins()->Apply(), RelocInfo::CODE_TARGET);
|
|
|
| - // Call the callable.
|
| - // TODO(bmeurer): This should be a tail call according to ES6.
|
| - __ mov(edi, Operand(ebp, kFunctionOffset));
|
| - __ Call(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
|
| + // 4b. The argArray is either null or undefined, so we tail call without any
|
| + // arguments to the receiver.
|
| + __ bind(&no_arguments);
|
| + {
|
| + __ Set(eax, 0);
|
| + __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
|
| + }
|
|
|
| - // Leave internal frame.
|
| + // 4c. The receiver is not callable, throw an appropriate TypeError.
|
| + __ bind(&receiver_not_callable);
|
| + {
|
| + __ mov(Operand(esp, kPointerSize), edi);
|
| + __ TailCallRuntime(Runtime::kThrowApplyNonFunction, 1, 1);
|
| }
|
| - __ ret(kStackSize * kPointerSize); // remove this, receiver, and arguments
|
| }
|
|
|
|
|
| -// Used by ReflectConstruct
|
| -static void Generate_ConstructHelper(MacroAssembler* masm) {
|
| - const int kFormalParameters = 3;
|
| - const int kStackSize = kFormalParameters + 1;
|
| +void Builtins::Generate_ReflectApply(MacroAssembler* masm) {
|
| + // ----------- S t a t e -------------
|
| + // -- eax : argc
|
| + // -- esp[0] : return address
|
| + // -- esp[4] : argumentsList
|
| + // -- esp[8] : thisArgument
|
| + // -- esp[12] : target
|
| + // -- esp[16] : receiver
|
| + // -----------------------------------
|
|
|
| - // Stack at entry:
|
| - // esp : return address
|
| - // esp[4] : new target
|
| - // esp[8] : arguments
|
| - // esp[16] : constructor
|
| + // 1. Load target into edi (if present), argumentsList into eax (if present),
|
| + // remove all arguments from the stack (including the receiver), and push
|
| + // thisArgument (if present) instead.
|
| {
|
| - FrameScope frame_scope(masm, StackFrame::INTERNAL);
|
| - // Stack frame:
|
| - // ebp : Old base pointer
|
| - // ebp[4] : return address
|
| - // ebp[8] : new target
|
| - // ebp[12] : arguments
|
| - // ebp[16] : constructor
|
| - static const int kNewTargetOffset = kFPOnStackSize + kPCOnStackSize;
|
| - static const int kArgumentsOffset = kNewTargetOffset + kPointerSize;
|
| - static const int kFunctionOffset = kArgumentsOffset + kPointerSize;
|
| - static const int kVectorOffset =
|
| - InternalFrameConstants::kCodeOffset - 1 * kPointerSize;
|
| -
|
| - // Push the vector.
|
| - __ mov(edi, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
|
| - __ mov(edi, FieldOperand(edi, SharedFunctionInfo::kFeedbackVectorOffset));
|
| - __ push(edi);
|
| + Label done;
|
| + __ LoadRoot(edi, Heap::kUndefinedValueRootIndex);
|
| + __ mov(edx, edi);
|
| + __ mov(ebx, edi);
|
| + __ cmp(eax, Immediate(1));
|
| + __ j(below, &done, Label::kNear);
|
| + __ mov(edi, Operand(esp, eax, times_pointer_size, -0 * kPointerSize));
|
| + __ j(equal, &done, Label::kNear);
|
| + __ mov(edx, Operand(esp, eax, times_pointer_size, -1 * kPointerSize));
|
| + __ cmp(eax, Immediate(3));
|
| + __ j(below, &done, Label::kNear);
|
| + __ mov(ebx, Operand(esp, eax, times_pointer_size, -2 * kPointerSize));
|
| + __ bind(&done);
|
| + __ PopReturnAddressTo(ecx);
|
| + __ lea(esp, Operand(esp, eax, times_pointer_size, kPointerSize));
|
| + __ Push(edx);
|
| + __ PushReturnAddressFrom(ecx);
|
| + __ Move(eax, ebx);
|
| + }
|
|
|
| - // If newTarget is not supplied, set it to constructor
|
| - Label validate_arguments;
|
| - __ mov(eax, Operand(ebp, kNewTargetOffset));
|
| - __ CompareRoot(eax, Heap::kUndefinedValueRootIndex);
|
| - __ j(not_equal, &validate_arguments, Label::kNear);
|
| - __ mov(eax, Operand(ebp, kFunctionOffset));
|
| - __ mov(Operand(ebp, kNewTargetOffset), eax);
|
| -
|
| - // Validate arguments
|
| - __ bind(&validate_arguments);
|
| - __ push(Operand(ebp, kFunctionOffset));
|
| - __ push(Operand(ebp, kArgumentsOffset));
|
| - __ push(Operand(ebp, kNewTargetOffset));
|
| - __ InvokeBuiltin(Context::REFLECT_CONSTRUCT_PREPARE_BUILTIN_INDEX,
|
| - CALL_FUNCTION);
|
| -
|
| - Generate_CheckStackOverflow(masm, kEaxIsSmiTagged);
|
| -
|
| - // Push current index and limit.
|
| - const int kLimitOffset = kVectorOffset - 1 * kPointerSize;
|
| - const int kIndexOffset = kLimitOffset - 1 * kPointerSize;
|
| - __ Push(eax); // limit
|
| - __ push(Immediate(0)); // index
|
| - // Push the constructor function as callee.
|
| - __ push(Operand(ebp, kFunctionOffset));
|
| -
|
| - // Loop over the arguments array, pushing each value to the stack
|
| - Generate_PushAppliedArguments(masm, kVectorOffset, kArgumentsOffset,
|
| - kIndexOffset, kLimitOffset);
|
| -
|
| - // Use undefined feedback vector
|
| - __ LoadRoot(ebx, Heap::kUndefinedValueRootIndex);
|
| - __ mov(edi, Operand(ebp, kFunctionOffset));
|
| - __ mov(edx, Operand(ebp, kNewTargetOffset));
|
| + // ----------- S t a t e -------------
|
| + // -- eax : argumentsList
|
| + // -- edi : target
|
| + // -- esp[0] : return address
|
| + // -- esp[4] : thisArgument
|
| + // -----------------------------------
|
|
|
| - // Call the function.
|
| - __ Call(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
|
| + // 2. Make sure the target is actually callable.
|
| + Label target_not_callable;
|
| + __ JumpIfSmi(edi, &target_not_callable, Label::kNear);
|
| + __ mov(ecx, FieldOperand(edi, HeapObject::kMapOffset));
|
| + __ test_b(FieldOperand(ecx, Map::kBitFieldOffset), 1 << Map::kIsCallable);
|
| + __ j(zero, &target_not_callable, Label::kNear);
|
| +
|
| + // 3a. Apply the target to the given argumentsList (passing undefined for
|
| + // new.target).
|
| + __ LoadRoot(edx, Heap::kUndefinedValueRootIndex);
|
| + __ Jump(masm->isolate()->builtins()->Apply(), RelocInfo::CODE_TARGET);
|
|
|
| - // Leave internal frame.
|
| + // 3b. The target is not callable, throw an appropriate TypeError.
|
| + __ bind(&target_not_callable);
|
| + {
|
| + __ mov(Operand(esp, kPointerSize), edi);
|
| + __ TailCallRuntime(Runtime::kThrowApplyNonFunction, 1, 1);
|
| }
|
| - // remove this, target, arguments, and newTarget
|
| - __ ret(kStackSize * kPointerSize);
|
| }
|
|
|
|
|
| -void Builtins::Generate_FunctionApply(MacroAssembler* masm) {
|
| - Generate_ApplyHelper(masm, false);
|
| -}
|
| +void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
|
| + // ----------- S t a t e -------------
|
| + // -- eax : argc
|
| + // -- esp[0] : return address
|
| + // -- esp[4] : new.target (optional)
|
| + // -- esp[8] : argumentsList
|
| + // -- esp[12] : target
|
| + // -- esp[16] : receiver
|
| + // -----------------------------------
|
|
|
| + // 1. Load target into edi (if present), argumentsList into eax (if present),
|
| + // new.target into edx (if present, otherwise use target), remove all
|
| + // arguments from the stack (including the receiver), and push thisArgument
|
| + // (if present) instead.
|
| + {
|
| + Label done;
|
| + __ LoadRoot(edi, Heap::kUndefinedValueRootIndex);
|
| + __ mov(edx, edi);
|
| + __ mov(ebx, edi);
|
| + __ cmp(eax, Immediate(1));
|
| + __ j(below, &done, Label::kNear);
|
| + __ mov(edi, Operand(esp, eax, times_pointer_size, -0 * kPointerSize));
|
| + __ mov(edx, edi);
|
| + __ j(equal, &done, Label::kNear);
|
| + __ mov(ebx, Operand(esp, eax, times_pointer_size, -1 * kPointerSize));
|
| + __ cmp(eax, Immediate(3));
|
| + __ j(below, &done, Label::kNear);
|
| + __ mov(edx, Operand(esp, eax, times_pointer_size, -2 * kPointerSize));
|
| + __ bind(&done);
|
| + __ PopReturnAddressTo(ecx);
|
| + __ lea(esp, Operand(esp, eax, times_pointer_size, kPointerSize));
|
| + __ PushRoot(Heap::kUndefinedValueRootIndex);
|
| + __ PushReturnAddressFrom(ecx);
|
| + __ Move(eax, ebx);
|
| + }
|
|
|
| -void Builtins::Generate_ReflectApply(MacroAssembler* masm) {
|
| - Generate_ApplyHelper(masm, true);
|
| -}
|
| + // ----------- S t a t e -------------
|
| + // -- eax : argumentsList
|
| + // -- edx : new.target
|
| + // -- edi : target
|
| + // -- esp[0] : return address
|
| + // -- esp[4] : receiver (undefined)
|
| + // -----------------------------------
|
|
|
| + // 2. Make sure the target is actually a constructor.
|
| + Label target_not_constructor;
|
| + __ JumpIfSmi(edi, &target_not_constructor, Label::kNear);
|
| + __ mov(ecx, FieldOperand(edi, HeapObject::kMapOffset));
|
| + __ test_b(FieldOperand(ecx, Map::kBitFieldOffset), 1 << Map::kIsConstructor);
|
| + __ j(zero, &target_not_constructor, Label::kNear);
|
|
|
| -void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
|
| - Generate_ConstructHelper(masm);
|
| + // 3. Make sure the target is actually a constructor.
|
| + Label new_target_not_constructor;
|
| + __ JumpIfSmi(edx, &new_target_not_constructor, Label::kNear);
|
| + __ mov(ecx, FieldOperand(edx, HeapObject::kMapOffset));
|
| + __ test_b(FieldOperand(ecx, Map::kBitFieldOffset), 1 << Map::kIsConstructor);
|
| + __ j(zero, &new_target_not_constructor, Label::kNear);
|
| +
|
| + // 4a. Construct the target with the given new.target and argumentsList.
|
| + __ Jump(masm->isolate()->builtins()->Apply(), RelocInfo::CODE_TARGET);
|
| +
|
| + // 4b. The target is not a constructor, throw an appropriate TypeError.
|
| + __ bind(&target_not_constructor);
|
| + {
|
| + __ mov(Operand(esp, kPointerSize), edi);
|
| + __ TailCallRuntime(Runtime::kThrowCalledNonCallable, 1, 1);
|
| + }
|
| +
|
| + // 4c. The new.target is not a constructor, throw an appropriate TypeError.
|
| + __ bind(&new_target_not_constructor);
|
| + {
|
| + __ mov(Operand(esp, kPointerSize), edx);
|
| + __ TailCallRuntime(Runtime::kThrowCalledNonCallable, 1, 1);
|
| + }
|
| }
|
|
|
|
|
| @@ -1419,6 +1437,139 @@ static void LeaveArgumentsAdaptorFrame(MacroAssembler* masm) {
|
|
|
|
|
| // static
|
| +void Builtins::Generate_Apply(MacroAssembler* masm) {
|
| + // ----------- S t a t e -------------
|
| + // -- eax : argumentsList
|
| + // -- edi : target
|
| + // -- edx : new.target (checked to be constructor or undefined)
|
| + // -- esp[0] : return address.
|
| + // -- esp[4] : thisArgument
|
| + // -----------------------------------
|
| +
|
| + // Create the list of arguments from the array-like argumentsList.
|
| + {
|
| + Label create_arguments, create_array, create_runtime, done_create;
|
| + __ JumpIfSmi(eax, &create_runtime);
|
| +
|
| + // Load the map of argumentsList into ecx.
|
| + __ mov(ecx, FieldOperand(eax, HeapObject::kMapOffset));
|
| +
|
| + // Load native context into ebx.
|
| + __ mov(ebx, NativeContextOperand());
|
| +
|
| + // Check if argumentsList is an (unmodified) arguments object.
|
| + __ cmp(ecx, ContextOperand(ebx, Context::SLOPPY_ARGUMENTS_MAP_INDEX));
|
| + __ j(equal, &create_arguments);
|
| + __ cmp(ecx, ContextOperand(ebx, Context::STRICT_ARGUMENTS_MAP_INDEX));
|
| + __ j(equal, &create_arguments);
|
| +
|
| + // Check if argumentsList is a fast JSArray.
|
| + __ CmpInstanceType(ecx, JS_ARRAY_TYPE);
|
| + __ j(equal, &create_array);
|
| +
|
| + // Ask the runtime to create the list (actually a FixedArray).
|
| + __ bind(&create_runtime);
|
| + {
|
| + FrameScope scope(masm, StackFrame::INTERNAL);
|
| + __ Push(edi);
|
| + __ Push(edx);
|
| + __ Push(eax);
|
| + __ CallRuntime(Runtime::kCreateListFromArrayLike, 1);
|
| + __ Pop(edx);
|
| + __ Pop(edi);
|
| + __ mov(ebx, FieldOperand(eax, FixedArray::kLengthOffset));
|
| + __ SmiUntag(ebx);
|
| + }
|
| + __ jmp(&done_create);
|
| +
|
| + // Try to create the list from an arguments object.
|
| + __ bind(&create_arguments);
|
| + __ mov(ebx,
|
| + FieldOperand(eax, JSObject::kHeaderSize +
|
| + Heap::kArgumentsLengthIndex * kPointerSize));
|
| + __ mov(ecx, FieldOperand(eax, JSObject::kElementsOffset));
|
| + __ cmp(ebx, FieldOperand(ecx, FixedArray::kLengthOffset));
|
| + __ j(not_equal, &create_runtime);
|
| + __ SmiUntag(ebx);
|
| + __ mov(eax, ecx);
|
| + __ jmp(&done_create);
|
| +
|
| + // Try to create the list from a JSArray object.
|
| + __ bind(&create_array);
|
| + __ mov(ecx, FieldOperand(ecx, Map::kBitField2Offset));
|
| + __ DecodeField<Map::ElementsKindBits>(ecx);
|
| + STATIC_ASSERT(FAST_SMI_ELEMENTS == 0);
|
| + STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == 1);
|
| + STATIC_ASSERT(FAST_ELEMENTS == 2);
|
| + __ cmp(ecx, Immediate(FAST_ELEMENTS));
|
| + __ j(above, &create_runtime);
|
| + __ cmp(ecx, Immediate(FAST_HOLEY_SMI_ELEMENTS));
|
| + __ j(equal, &create_runtime);
|
| + __ mov(ebx, FieldOperand(eax, JSArray::kLengthOffset));
|
| + __ SmiUntag(ebx);
|
| + __ mov(eax, FieldOperand(eax, JSArray::kElementsOffset));
|
| +
|
| + __ bind(&done_create);
|
| + }
|
| +
|
| + // Check for stack overflow.
|
| + {
|
| + // Check the stack for overflow. We are not trying to catch interruptions
|
| + // (i.e. debug break and preemption) here, so check the "real stack limit".
|
| + Label done;
|
| + ExternalReference real_stack_limit =
|
| + ExternalReference::address_of_real_stack_limit(masm->isolate());
|
| + __ mov(ecx, Operand::StaticVariable(real_stack_limit));
|
| + // Make ecx the space we have left. The stack might already be overflowed
|
| + // here which will cause ecx to become negative.
|
| + __ neg(ecx);
|
| + __ add(ecx, esp);
|
| + __ sar(ecx, kPointerSizeLog2);
|
| + // Check if the arguments will overflow the stack.
|
| + __ cmp(ecx, ebx);
|
| + __ j(greater, &done, Label::kNear); // Signed comparison.
|
| + __ TailCallRuntime(Runtime::kThrowStackOverflow, 1, 1);
|
| + __ bind(&done);
|
| + }
|
| +
|
| + // ----------- S t a t e -------------
|
| + // -- edi : target
|
| + // -- eax : args (a FixedArray built from argumentsList)
|
| + // -- ebx : len (number of elements to push from args)
|
| + // -- edx : new.target (checked to be constructor or undefined)
|
| + // -- esp[0] : return address.
|
| + // -- esp[4] : thisArgument
|
| + // -----------------------------------
|
| +
|
| + // Push arguments onto the stack (thisArgument is already on the stack).
|
| + {
|
| + __ movd(xmm0, edx);
|
| + __ PopReturnAddressTo(edx);
|
| + __ Move(ecx, Immediate(0));
|
| + Label done, loop;
|
| + __ bind(&loop);
|
| + __ cmp(ecx, ebx);
|
| + __ j(equal, &done, Label::kNear);
|
| + __ Push(
|
| + FieldOperand(eax, ecx, times_pointer_size, FixedArray::kHeaderSize));
|
| + __ inc(ecx);
|
| + __ jmp(&loop);
|
| + __ bind(&done);
|
| + __ PushReturnAddressFrom(edx);
|
| + __ movd(edx, xmm0);
|
| + __ Move(eax, ebx);
|
| + }
|
| +
|
| + // Dispatch to Call or Construct depending on whether new.target is undefined.
|
| + {
|
| + __ CompareRoot(edx, Heap::kUndefinedValueRootIndex);
|
| + __ j(equal, masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
|
| + __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
|
| + }
|
| +}
|
| +
|
| +
|
| +// static
|
| void Builtins::Generate_CallFunction(MacroAssembler* masm,
|
| ConvertReceiverMode mode) {
|
| // ----------- S t a t e -------------
|
|
|