Index: src/builtins/arm/builtins-arm.cc |
diff --git a/src/builtins/arm/builtins-arm.cc b/src/builtins/arm/builtins-arm.cc |
index b85468993a0a86216496542fcb6c39aeb762bea3..1b8e04e37e06632becc836b3da2960556d4f2f31 100644 |
--- a/src/builtins/arm/builtins-arm.cc |
+++ b/src/builtins/arm/builtins-arm.cc |
@@ -1770,24 +1770,23 @@ void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) { |
// -- sp[8] : receiver |
// ----------------------------------- |
- // 1. Load receiver into r1, argArray into r0 (if present), remove all |
+ // 1. Load receiver into r1, argArray into r2 (if present), remove all |
// arguments from the stack (including the receiver), and push thisArg (if |
// present) instead. |
{ |
- __ LoadRoot(r2, Heap::kUndefinedValueRootIndex); |
- __ mov(r3, r2); |
+ __ LoadRoot(r5, Heap::kUndefinedValueRootIndex); |
+ __ mov(r2, r5); |
__ ldr(r1, MemOperand(sp, r0, LSL, kPointerSizeLog2)); // receiver |
__ sub(r4, r0, Operand(1), SetCC); |
- __ ldr(r2, MemOperand(sp, r4, LSL, kPointerSizeLog2), ge); // thisArg |
+ __ ldr(r5, MemOperand(sp, r4, LSL, kPointerSizeLog2), ge); // thisArg |
__ sub(r4, r4, Operand(1), SetCC, ge); |
- __ ldr(r3, MemOperand(sp, r4, LSL, kPointerSizeLog2), ge); // argArray |
+ __ ldr(r2, MemOperand(sp, r4, LSL, kPointerSizeLog2), ge); // argArray |
__ add(sp, sp, Operand(r0, LSL, kPointerSizeLog2)); |
- __ str(r2, MemOperand(sp, 0)); |
- __ mov(r0, r3); |
+ __ str(r5, MemOperand(sp, 0)); |
} |
// ----------- S t a t e ------------- |
- // -- r0 : argArray |
+ // -- r2 : argArray |
// -- r1 : receiver |
// -- sp[0] : thisArg |
// ----------------------------------- |
@@ -1802,13 +1801,12 @@ void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) { |
// 3. Tail call with no arguments if argArray is null or undefined. |
Label no_arguments; |
- __ JumpIfRoot(r0, Heap::kNullValueRootIndex, &no_arguments); |
- __ JumpIfRoot(r0, Heap::kUndefinedValueRootIndex, &no_arguments); |
+ __ JumpIfRoot(r2, Heap::kNullValueRootIndex, &no_arguments); |
+ __ JumpIfRoot(r2, Heap::kUndefinedValueRootIndex, &no_arguments); |
- // 4a. Apply the receiver to the given argArray (passing undefined for |
- // new.target). |
- __ LoadRoot(r3, Heap::kUndefinedValueRootIndex); |
- __ Jump(masm->isolate()->builtins()->Apply(), RelocInfo::CODE_TARGET); |
+ // 4a. Apply the receiver to the given argArray. |
+ __ Jump(masm->isolate()->builtins()->CallWithArrayLike(), |
+ RelocInfo::CODE_TARGET); |
// 4b. The argArray is either null or undefined, so we tail call without any |
// arguments to the receiver. |
@@ -1878,26 +1876,25 @@ void Builtins::Generate_ReflectApply(MacroAssembler* masm) { |
// -- sp[12] : receiver |
// ----------------------------------- |
- // 1. Load target into r1 (if present), argumentsList into r0 (if present), |
+ // 1. Load target into r1 (if present), argumentsList into r2 (if present), |
// remove all arguments from the stack (including the receiver), and push |
// thisArgument (if present) instead. |
{ |
__ LoadRoot(r1, Heap::kUndefinedValueRootIndex); |
+ __ mov(r5, r1); |
__ mov(r2, r1); |
- __ mov(r3, r1); |
__ sub(r4, r0, Operand(1), SetCC); |
__ ldr(r1, MemOperand(sp, r4, LSL, kPointerSizeLog2), ge); // target |
__ sub(r4, r4, Operand(1), SetCC, ge); |
- __ ldr(r2, MemOperand(sp, r4, LSL, kPointerSizeLog2), ge); // thisArgument |
+ __ ldr(r5, MemOperand(sp, r4, LSL, kPointerSizeLog2), ge); // thisArgument |
__ sub(r4, r4, Operand(1), SetCC, ge); |
- __ ldr(r3, MemOperand(sp, r4, LSL, kPointerSizeLog2), ge); // argumentsList |
+ __ ldr(r2, MemOperand(sp, r4, LSL, kPointerSizeLog2), ge); // argumentsList |
__ add(sp, sp, Operand(r0, LSL, kPointerSizeLog2)); |
- __ str(r2, MemOperand(sp, 0)); |
- __ mov(r0, r3); |
+ __ str(r5, MemOperand(sp, 0)); |
} |
// ----------- S t a t e ------------- |
- // -- r0 : argumentsList |
+ // -- r2 : argumentsList |
// -- r1 : target |
// -- sp[0] : thisArgument |
// ----------------------------------- |
@@ -1910,10 +1907,9 @@ void Builtins::Generate_ReflectApply(MacroAssembler* masm) { |
__ tst(r4, Operand(1 << Map::kIsCallable)); |
__ b(eq, &target_not_callable); |
- // 3a. Apply the target to the given argumentsList (passing undefined for |
- // new.target). |
- __ LoadRoot(r3, Heap::kUndefinedValueRootIndex); |
- __ Jump(masm->isolate()->builtins()->Apply(), RelocInfo::CODE_TARGET); |
+ // 3a. Apply the target to the given argumentsList. |
+ __ Jump(masm->isolate()->builtins()->CallWithArrayLike(), |
+ RelocInfo::CODE_TARGET); |
// 3b. The target is not callable, throw an appropriate TypeError. |
__ bind(&target_not_callable); |
@@ -1932,7 +1928,7 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) { |
// -- sp[12] : receiver |
// ----------------------------------- |
- // 1. Load target into r1 (if present), argumentsList into r0 (if present), |
+ // 1. Load target into r1 (if present), argumentsList into r2 (if present), |
// new.target into r3 (if present, otherwise use target), remove all |
// arguments from the stack (including the receiver), and push thisArgument |
// (if present) instead. |
@@ -1948,11 +1944,10 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) { |
__ sub(r4, r4, Operand(1), SetCC, ge); |
__ ldr(r3, MemOperand(sp, r4, LSL, kPointerSizeLog2), ge); // new.target |
__ add(sp, sp, Operand(r0, LSL, kPointerSizeLog2)); |
- __ mov(r0, r2); |
} |
// ----------- S t a t e ------------- |
- // -- r0 : argumentsList |
+ // -- r2 : argumentsList |
// -- r3 : new.target |
// -- r1 : target |
// -- sp[0] : receiver (undefined) |
@@ -1975,7 +1970,8 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) { |
__ b(eq, &new_target_not_constructor); |
// 4a. Construct the target with the given new.target and argumentsList. |
- __ Jump(masm->isolate()->builtins()->Apply(), RelocInfo::CODE_TARGET); |
+ __ Jump(masm->isolate()->builtins()->ConstructWithArrayLike(), |
+ RelocInfo::CODE_TARGET); |
// 4b. The target is not a constructor, throw an appropriate TypeError. |
__ bind(&target_not_constructor); |
@@ -2016,98 +2012,16 @@ static void LeaveArgumentsAdaptorFrame(MacroAssembler* masm) { |
} |
// static |
-void Builtins::Generate_Apply(MacroAssembler* masm) { |
+void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm, |
+ Handle<Code> code) { |
// ----------- S t a t e ------------- |
- // -- r0 : argumentsList |
- // -- r1 : target |
- // -- r3 : new.target (checked to be constructor or undefined) |
- // -- sp[0] : thisArgument |
+ // -- r1 : target |
+ // -- r0 : number of parameters on the stack (not including the receiver) |
+ // -- r2 : arguments list (a FixedArray) |
+ // -- r4 : len (number of elements to push from args) |
+ // -- r3 : new.target (for [[Construct]]) |
// ----------------------------------- |
- |
- // Create the list of arguments from the array-like argumentsList. |
- { |
- Label create_arguments, create_array, create_holey_array, create_runtime, |
- done_create; |
- __ JumpIfSmi(r0, &create_runtime); |
- |
- // Load the map of argumentsList into r2. |
- __ ldr(r2, FieldMemOperand(r0, HeapObject::kMapOffset)); |
- |
- // Load native context into r4. |
- __ ldr(r4, NativeContextMemOperand()); |
- |
- // Check if argumentsList is an (unmodified) arguments object. |
- __ ldr(ip, ContextMemOperand(r4, Context::SLOPPY_ARGUMENTS_MAP_INDEX)); |
- __ cmp(ip, r2); |
- __ b(eq, &create_arguments); |
- __ ldr(ip, ContextMemOperand(r4, Context::STRICT_ARGUMENTS_MAP_INDEX)); |
- __ cmp(ip, r2); |
- __ b(eq, &create_arguments); |
- |
- // Check if argumentsList is a fast JSArray. |
- __ CompareInstanceType(r2, ip, JS_ARRAY_TYPE); |
- __ b(eq, &create_array); |
- |
- // Ask the runtime to create the list (actually a FixedArray). |
- __ bind(&create_runtime); |
- { |
- FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
- __ Push(r1, r3, r0); |
- __ CallRuntime(Runtime::kCreateListFromArrayLike); |
- __ Pop(r1, r3); |
- __ ldr(r2, FieldMemOperand(r0, FixedArray::kLengthOffset)); |
- __ SmiUntag(r2); |
- } |
- __ jmp(&done_create); |
- |
- // Try to create the list from an arguments object. |
- __ bind(&create_arguments); |
- __ ldr(r2, FieldMemOperand(r0, JSArgumentsObject::kLengthOffset)); |
- __ ldr(r4, FieldMemOperand(r0, JSObject::kElementsOffset)); |
- __ ldr(ip, FieldMemOperand(r4, FixedArray::kLengthOffset)); |
- __ cmp(r2, ip); |
- __ b(ne, &create_runtime); |
- __ SmiUntag(r2); |
- __ mov(r0, r4); |
- __ b(&done_create); |
- |
- // For holey JSArrays we need to check that the array prototype chain |
- // protector is intact and our prototype is the Array.prototype actually. |
- __ bind(&create_holey_array); |
- __ ldr(r2, FieldMemOperand(r2, Map::kPrototypeOffset)); |
- __ ldr(r4, ContextMemOperand(r4, Context::INITIAL_ARRAY_PROTOTYPE_INDEX)); |
- __ cmp(r2, r4); |
- __ b(ne, &create_runtime); |
- __ LoadRoot(r4, Heap::kArrayProtectorRootIndex); |
- __ ldr(r2, FieldMemOperand(r4, PropertyCell::kValueOffset)); |
- __ cmp(r2, Operand(Smi::FromInt(Isolate::kProtectorValid))); |
- __ b(ne, &create_runtime); |
- __ ldr(r2, FieldMemOperand(r0, JSArray::kLengthOffset)); |
- __ ldr(r0, FieldMemOperand(r0, JSArray::kElementsOffset)); |
- __ SmiUntag(r2); |
- __ b(&done_create); |
- |
- // Try to create the list from a JSArray object. |
- // -- r2 and r4 must be preserved till bne create_holey_array. |
- __ bind(&create_array); |
- __ ldr(r5, FieldMemOperand(r2, Map::kBitField2Offset)); |
- __ DecodeField<Map::ElementsKindBits>(r5); |
- STATIC_ASSERT(FAST_SMI_ELEMENTS == 0); |
- STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == 1); |
- STATIC_ASSERT(FAST_ELEMENTS == 2); |
- STATIC_ASSERT(FAST_HOLEY_ELEMENTS == 3); |
- __ cmp(r5, Operand(FAST_HOLEY_ELEMENTS)); |
- __ b(hi, &create_runtime); |
- // Only FAST_XXX after this point, FAST_HOLEY_XXX are odd values. |
- __ tst(r5, Operand(1)); |
- __ b(ne, &create_holey_array); |
- // FAST_SMI_ELEMENTS or FAST_ELEMENTS after this point. |
- __ ldr(r2, FieldMemOperand(r0, JSArray::kLengthOffset)); |
- __ ldr(r0, FieldMemOperand(r0, JSArray::kElementsOffset)); |
- __ SmiUntag(r2); |
- |
- __ bind(&done_create); |
- } |
+ __ AssertFixedArray(r2); |
// Check for stack overflow. |
{ |
@@ -2119,51 +2033,38 @@ void Builtins::Generate_Apply(MacroAssembler* masm) { |
// here which will cause ip to become negative. |
__ sub(ip, sp, ip); |
// Check if the arguments will overflow the stack. |
- __ cmp(ip, Operand(r2, LSL, kPointerSizeLog2)); |
+ __ cmp(ip, Operand(r4, LSL, kPointerSizeLog2)); |
__ b(gt, &done); // Signed comparison. |
__ TailCallRuntime(Runtime::kThrowStackOverflow); |
__ bind(&done); |
} |
- // ----------- S t a t e ------------- |
- // -- r1 : target |
- // -- r0 : args (a FixedArray built from argumentsList) |
- // -- r2 : len (number of elements to push from args) |
- // -- r3 : new.target (checked to be constructor or undefined) |
- // -- sp[0] : thisArgument |
- // ----------------------------------- |
- |
// Push arguments onto the stack (thisArgument is already on the stack). |
{ |
- __ mov(r4, Operand(0)); |
+ __ mov(r6, Operand(0)); |
__ LoadRoot(r5, Heap::kTheHoleValueRootIndex); |
- __ LoadRoot(r6, Heap::kUndefinedValueRootIndex); |
Label done, loop; |
__ bind(&loop); |
- __ cmp(r4, r2); |
+ __ cmp(r6, r4); |
__ b(eq, &done); |
- __ add(ip, r0, Operand(r4, LSL, kPointerSizeLog2)); |
+ __ add(ip, r2, Operand(r6, LSL, kPointerSizeLog2)); |
__ ldr(ip, FieldMemOperand(ip, FixedArray::kHeaderSize)); |
- __ cmp(r5, ip); |
- __ mov(ip, r6, LeaveCC, eq); |
+ __ cmp(ip, r5); |
+ __ LoadRoot(ip, Heap::kUndefinedValueRootIndex, eq); |
__ Push(ip); |
- __ add(r4, r4, Operand(1)); |
+ __ add(r6, r6, Operand(1)); |
__ b(&loop); |
__ bind(&done); |
- __ Move(r0, r4); |
+ __ add(r0, r0, r6); |
} |
- // Dispatch to Call or Construct depending on whether new.target is undefined. |
- { |
- __ CompareRoot(r3, Heap::kUndefinedValueRootIndex); |
- __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET, eq); |
- __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
- } |
+ // Tail-call to the actual Call or Construct builtin. |
+ __ Jump(code, RelocInfo::CODE_TARGET); |
} |
// static |
-void Builtins::Generate_ForwardVarargs(MacroAssembler* masm, |
- Handle<Code> code) { |
+void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm, |
+ Handle<Code> code) { |
// ----------- S t a t e ------------- |
// -- r0 : the number of arguments (not including the receiver) |
// -- r3 : the new.target (for [[Construct]] calls) |