| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #if V8_TARGET_ARCH_ARM | 5 #if V8_TARGET_ARCH_ARM |
| 6 | 6 |
| 7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
| 8 #include "src/api-arguments.h" | 8 #include "src/api-arguments.h" |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 4540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4551 __ cmp(r0, r1); | 4551 __ cmp(r0, r1); |
| 4552 __ b(ne, &new_object); | 4552 __ b(ne, &new_object); |
| 4553 | 4553 |
| 4554 // Allocate the JSObject on the heap. | 4554 // Allocate the JSObject on the heap. |
| 4555 Label allocate, done_allocate; | 4555 Label allocate, done_allocate; |
| 4556 __ ldrb(r4, FieldMemOperand(r2, Map::kInstanceSizeOffset)); | 4556 __ ldrb(r4, FieldMemOperand(r2, Map::kInstanceSizeOffset)); |
| 4557 __ Allocate(r4, r0, r5, r6, &allocate, SIZE_IN_WORDS); | 4557 __ Allocate(r4, r0, r5, r6, &allocate, SIZE_IN_WORDS); |
| 4558 __ bind(&done_allocate); | 4558 __ bind(&done_allocate); |
| 4559 | 4559 |
| 4560 // Initialize the JSObject fields. | 4560 // Initialize the JSObject fields. |
| 4561 __ str(r2, MemOperand(r0, JSObject::kMapOffset)); | 4561 __ str(r2, FieldMemOperand(r0, JSObject::kMapOffset)); |
| 4562 __ LoadRoot(r3, Heap::kEmptyFixedArrayRootIndex); | 4562 __ LoadRoot(r3, Heap::kEmptyFixedArrayRootIndex); |
| 4563 __ str(r3, MemOperand(r0, JSObject::kPropertiesOffset)); | 4563 __ str(r3, FieldMemOperand(r0, JSObject::kPropertiesOffset)); |
| 4564 __ str(r3, MemOperand(r0, JSObject::kElementsOffset)); | 4564 __ str(r3, FieldMemOperand(r0, JSObject::kElementsOffset)); |
| 4565 STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize); | 4565 STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize); |
| 4566 __ add(r1, r0, Operand(JSObject::kHeaderSize)); | 4566 __ add(r1, r0, Operand(JSObject::kHeaderSize - kHeapObjectTag)); |
| 4567 | 4567 |
| 4568 // ----------- S t a t e ------------- | 4568 // ----------- S t a t e ------------- |
| 4569 // -- r0 : result (untagged) | 4569 // -- r0 : result (tagged) |
| 4570 // -- r1 : result fields (untagged) | 4570 // -- r1 : result fields (untagged) |
| 4571 // -- r5 : result end (untagged) | 4571 // -- r5 : result end (untagged) |
| 4572 // -- r2 : initial map | 4572 // -- r2 : initial map |
| 4573 // -- cp : context | 4573 // -- cp : context |
| 4574 // -- lr : return address | 4574 // -- lr : return address |
| 4575 // ----------------------------------- | 4575 // ----------------------------------- |
| 4576 | 4576 |
| 4577 // Perform in-object slack tracking if requested. | 4577 // Perform in-object slack tracking if requested. |
| 4578 Label slack_tracking; | 4578 Label slack_tracking; |
| 4579 STATIC_ASSERT(Map::kNoSlackTracking == 0); | 4579 STATIC_ASSERT(Map::kNoSlackTracking == 0); |
| 4580 __ LoadRoot(r6, Heap::kUndefinedValueRootIndex); | 4580 __ LoadRoot(r6, Heap::kUndefinedValueRootIndex); |
| 4581 __ ldr(r3, FieldMemOperand(r2, Map::kBitField3Offset)); | 4581 __ ldr(r3, FieldMemOperand(r2, Map::kBitField3Offset)); |
| 4582 __ tst(r3, Operand(Map::ConstructionCounter::kMask)); | 4582 __ tst(r3, Operand(Map::ConstructionCounter::kMask)); |
| 4583 __ b(ne, &slack_tracking); | 4583 __ b(ne, &slack_tracking); |
| 4584 { | 4584 { |
| 4585 // Initialize all in-object fields with undefined. | 4585 // Initialize all in-object fields with undefined. |
| 4586 __ InitializeFieldsWithFiller(r1, r5, r6); | 4586 __ InitializeFieldsWithFiller(r1, r5, r6); |
| 4587 | |
| 4588 // Add the object tag to make the JSObject real. | |
| 4589 STATIC_ASSERT(kHeapObjectTag == 1); | |
| 4590 __ add(r0, r0, Operand(kHeapObjectTag)); | |
| 4591 __ Ret(); | 4587 __ Ret(); |
| 4592 } | 4588 } |
| 4593 __ bind(&slack_tracking); | 4589 __ bind(&slack_tracking); |
| 4594 { | 4590 { |
| 4595 // Decrease generous allocation count. | 4591 // Decrease generous allocation count. |
| 4596 STATIC_ASSERT(Map::ConstructionCounter::kNext == 32); | 4592 STATIC_ASSERT(Map::ConstructionCounter::kNext == 32); |
| 4597 __ sub(r3, r3, Operand(1 << Map::ConstructionCounter::kShift)); | 4593 __ sub(r3, r3, Operand(1 << Map::ConstructionCounter::kShift)); |
| 4598 __ str(r3, FieldMemOperand(r2, Map::kBitField3Offset)); | 4594 __ str(r3, FieldMemOperand(r2, Map::kBitField3Offset)); |
| 4599 | 4595 |
| 4600 // Initialize the in-object fields with undefined. | 4596 // Initialize the in-object fields with undefined. |
| 4601 __ ldrb(r4, FieldMemOperand(r2, Map::kUnusedPropertyFieldsOffset)); | 4597 __ ldrb(r4, FieldMemOperand(r2, Map::kUnusedPropertyFieldsOffset)); |
| 4602 __ sub(r4, r5, Operand(r4, LSL, kPointerSizeLog2)); | 4598 __ sub(r4, r5, Operand(r4, LSL, kPointerSizeLog2)); |
| 4603 __ InitializeFieldsWithFiller(r1, r4, r6); | 4599 __ InitializeFieldsWithFiller(r1, r4, r6); |
| 4604 | 4600 |
| 4605 // Initialize the remaining (reserved) fields with one pointer filler map. | 4601 // Initialize the remaining (reserved) fields with one pointer filler map. |
| 4606 __ LoadRoot(r6, Heap::kOnePointerFillerMapRootIndex); | 4602 __ LoadRoot(r6, Heap::kOnePointerFillerMapRootIndex); |
| 4607 __ InitializeFieldsWithFiller(r1, r5, r6); | 4603 __ InitializeFieldsWithFiller(r1, r5, r6); |
| 4608 | 4604 |
| 4609 // Add the object tag to make the JSObject real. | |
| 4610 STATIC_ASSERT(kHeapObjectTag == 1); | |
| 4611 __ add(r0, r0, Operand(kHeapObjectTag)); | |
| 4612 | |
| 4613 // Check if we can finalize the instance size. | 4605 // Check if we can finalize the instance size. |
| 4614 STATIC_ASSERT(Map::kSlackTrackingCounterEnd == 1); | 4606 STATIC_ASSERT(Map::kSlackTrackingCounterEnd == 1); |
| 4615 __ tst(r3, Operand(Map::ConstructionCounter::kMask)); | 4607 __ tst(r3, Operand(Map::ConstructionCounter::kMask)); |
| 4616 __ Ret(ne); | 4608 __ Ret(ne); |
| 4617 | 4609 |
| 4618 // Finalize the instance size. | 4610 // Finalize the instance size. |
| 4619 { | 4611 { |
| 4620 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 4612 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
| 4621 __ Push(r0, r2); | 4613 __ Push(r0, r2); |
| 4622 __ CallRuntime(Runtime::kFinalizeInstanceSize); | 4614 __ CallRuntime(Runtime::kFinalizeInstanceSize); |
| 4623 __ Pop(r0); | 4615 __ Pop(r0); |
| 4624 } | 4616 } |
| 4625 __ Ret(); | 4617 __ Ret(); |
| 4626 } | 4618 } |
| 4627 | 4619 |
| 4628 // Fall back to %AllocateInNewSpace. | 4620 // Fall back to %AllocateInNewSpace. |
| 4629 __ bind(&allocate); | 4621 __ bind(&allocate); |
| 4630 { | 4622 { |
| 4631 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 4623 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
| 4632 STATIC_ASSERT(kSmiTag == 0); | 4624 STATIC_ASSERT(kSmiTag == 0); |
| 4633 STATIC_ASSERT(kSmiTagSize == 1); | 4625 STATIC_ASSERT(kSmiTagSize == 1); |
| 4634 __ mov(r4, Operand(r4, LSL, kPointerSizeLog2 + 1)); | 4626 __ mov(r4, Operand(r4, LSL, kPointerSizeLog2 + 1)); |
| 4635 __ Push(r2, r4); | 4627 __ Push(r2, r4); |
| 4636 __ CallRuntime(Runtime::kAllocateInNewSpace); | 4628 __ CallRuntime(Runtime::kAllocateInNewSpace); |
| 4637 __ Pop(r2); | 4629 __ Pop(r2); |
| 4638 } | 4630 } |
| 4639 STATIC_ASSERT(kHeapObjectTag == 1); | |
| 4640 __ sub(r0, r0, Operand(kHeapObjectTag)); | |
| 4641 __ ldrb(r5, FieldMemOperand(r2, Map::kInstanceSizeOffset)); | 4631 __ ldrb(r5, FieldMemOperand(r2, Map::kInstanceSizeOffset)); |
| 4642 __ add(r5, r0, Operand(r5, LSL, kPointerSizeLog2)); | 4632 __ add(r5, r0, Operand(r5, LSL, kPointerSizeLog2)); |
| 4633 STATIC_ASSERT(kHeapObjectTag == 1); |
| 4634 __ sub(r5, r5, Operand(kHeapObjectTag)); |
| 4643 __ b(&done_allocate); | 4635 __ b(&done_allocate); |
| 4644 | 4636 |
| 4645 // Fall back to %NewObject. | 4637 // Fall back to %NewObject. |
| 4646 __ bind(&new_object); | 4638 __ bind(&new_object); |
| 4647 __ Push(r1, r3); | 4639 __ Push(r1, r3); |
| 4648 __ TailCallRuntime(Runtime::kNewObject); | 4640 __ TailCallRuntime(Runtime::kNewObject); |
| 4649 } | 4641 } |
| 4650 | 4642 |
| 4651 | 4643 |
| 4652 void FastNewRestParameterStub::Generate(MacroAssembler* masm) { | 4644 void FastNewRestParameterStub::Generate(MacroAssembler* masm) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4695 // Return an empty rest parameter array. | 4687 // Return an empty rest parameter array. |
| 4696 __ bind(&no_rest_parameters); | 4688 __ bind(&no_rest_parameters); |
| 4697 { | 4689 { |
| 4698 // ----------- S t a t e ------------- | 4690 // ----------- S t a t e ------------- |
| 4699 // -- cp : context | 4691 // -- cp : context |
| 4700 // -- lr : return address | 4692 // -- lr : return address |
| 4701 // ----------------------------------- | 4693 // ----------------------------------- |
| 4702 | 4694 |
| 4703 // Allocate an empty rest parameter array. | 4695 // Allocate an empty rest parameter array. |
| 4704 Label allocate, done_allocate; | 4696 Label allocate, done_allocate; |
| 4705 __ Allocate(JSArray::kSize, r0, r1, r2, &allocate, TAG_OBJECT); | 4697 __ Allocate(JSArray::kSize, r0, r1, r2, &allocate, NO_ALLOCATION_FLAGS); |
| 4706 __ bind(&done_allocate); | 4698 __ bind(&done_allocate); |
| 4707 | 4699 |
| 4708 // Setup the rest parameter array in r0. | 4700 // Setup the rest parameter array in r0. |
| 4709 __ LoadNativeContextSlot(Context::JS_ARRAY_FAST_ELEMENTS_MAP_INDEX, r1); | 4701 __ LoadNativeContextSlot(Context::JS_ARRAY_FAST_ELEMENTS_MAP_INDEX, r1); |
| 4710 __ str(r1, FieldMemOperand(r0, JSArray::kMapOffset)); | 4702 __ str(r1, FieldMemOperand(r0, JSArray::kMapOffset)); |
| 4711 __ LoadRoot(r1, Heap::kEmptyFixedArrayRootIndex); | 4703 __ LoadRoot(r1, Heap::kEmptyFixedArrayRootIndex); |
| 4712 __ str(r1, FieldMemOperand(r0, JSArray::kPropertiesOffset)); | 4704 __ str(r1, FieldMemOperand(r0, JSArray::kPropertiesOffset)); |
| 4713 __ str(r1, FieldMemOperand(r0, JSArray::kElementsOffset)); | 4705 __ str(r1, FieldMemOperand(r0, JSArray::kElementsOffset)); |
| 4714 __ mov(r1, Operand(0)); | 4706 __ mov(r1, Operand(0)); |
| 4715 __ str(r1, FieldMemOperand(r0, JSArray::kLengthOffset)); | 4707 __ str(r1, FieldMemOperand(r0, JSArray::kLengthOffset)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 4737 // -- cp : context | 4729 // -- cp : context |
| 4738 // -- r0 : number of rest parameters (tagged) | 4730 // -- r0 : number of rest parameters (tagged) |
| 4739 // -- r2 : pointer to first rest parameters | 4731 // -- r2 : pointer to first rest parameters |
| 4740 // -- lr : return address | 4732 // -- lr : return address |
| 4741 // ----------------------------------- | 4733 // ----------------------------------- |
| 4742 | 4734 |
| 4743 // Allocate space for the rest parameter array plus the backing store. | 4735 // Allocate space for the rest parameter array plus the backing store. |
| 4744 Label allocate, done_allocate; | 4736 Label allocate, done_allocate; |
| 4745 __ mov(r1, Operand(JSArray::kSize + FixedArray::kHeaderSize)); | 4737 __ mov(r1, Operand(JSArray::kSize + FixedArray::kHeaderSize)); |
| 4746 __ add(r1, r1, Operand(r0, LSL, kPointerSizeLog2 - 1)); | 4738 __ add(r1, r1, Operand(r0, LSL, kPointerSizeLog2 - 1)); |
| 4747 __ Allocate(r1, r3, r4, r5, &allocate, TAG_OBJECT); | 4739 __ Allocate(r1, r3, r4, r5, &allocate, NO_ALLOCATION_FLAGS); |
| 4748 __ bind(&done_allocate); | 4740 __ bind(&done_allocate); |
| 4749 | 4741 |
| 4750 // Setup the elements array in r3. | 4742 // Setup the elements array in r3. |
| 4751 __ LoadRoot(r1, Heap::kFixedArrayMapRootIndex); | 4743 __ LoadRoot(r1, Heap::kFixedArrayMapRootIndex); |
| 4752 __ str(r1, FieldMemOperand(r3, FixedArray::kMapOffset)); | 4744 __ str(r1, FieldMemOperand(r3, FixedArray::kMapOffset)); |
| 4753 __ str(r0, FieldMemOperand(r3, FixedArray::kLengthOffset)); | 4745 __ str(r0, FieldMemOperand(r3, FixedArray::kLengthOffset)); |
| 4754 __ add(r4, r3, Operand(FixedArray::kHeaderSize)); | 4746 __ add(r4, r3, Operand(FixedArray::kHeaderSize)); |
| 4755 { | 4747 { |
| 4756 Label loop, done_loop; | 4748 Label loop, done_loop; |
| 4757 __ add(r1, r4, Operand(r0, LSL, kPointerSizeLog2 - 1)); | 4749 __ add(r1, r4, Operand(r0, LSL, kPointerSizeLog2 - 1)); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4869 __ add(r9, r9, Operand(kParameterMapHeaderSize), LeaveCC, ne); | 4861 __ add(r9, r9, Operand(kParameterMapHeaderSize), LeaveCC, ne); |
| 4870 | 4862 |
| 4871 // 2. Backing store. | 4863 // 2. Backing store. |
| 4872 __ add(r9, r9, Operand(r5, LSL, 1)); | 4864 __ add(r9, r9, Operand(r5, LSL, 1)); |
| 4873 __ add(r9, r9, Operand(FixedArray::kHeaderSize)); | 4865 __ add(r9, r9, Operand(FixedArray::kHeaderSize)); |
| 4874 | 4866 |
| 4875 // 3. Arguments object. | 4867 // 3. Arguments object. |
| 4876 __ add(r9, r9, Operand(JSSloppyArgumentsObject::kSize)); | 4868 __ add(r9, r9, Operand(JSSloppyArgumentsObject::kSize)); |
| 4877 | 4869 |
| 4878 // Do the allocation of all three objects in one go. | 4870 // Do the allocation of all three objects in one go. |
| 4879 __ Allocate(r9, r0, r9, r4, &runtime, TAG_OBJECT); | 4871 __ Allocate(r9, r0, r9, r4, &runtime, NO_ALLOCATION_FLAGS); |
| 4880 | 4872 |
| 4881 // r0 = address of new object(s) (tagged) | 4873 // r0 = address of new object(s) (tagged) |
| 4882 // r2 = argument count (smi-tagged) | 4874 // r2 = argument count (smi-tagged) |
| 4883 // Get the arguments boilerplate from the current native context into r4. | 4875 // Get the arguments boilerplate from the current native context into r4. |
| 4884 const int kNormalOffset = | 4876 const int kNormalOffset = |
| 4885 Context::SlotOffset(Context::SLOPPY_ARGUMENTS_MAP_INDEX); | 4877 Context::SlotOffset(Context::SLOPPY_ARGUMENTS_MAP_INDEX); |
| 4886 const int kAliasedOffset = | 4878 const int kAliasedOffset = |
| 4887 Context::SlotOffset(Context::FAST_ALIASED_ARGUMENTS_MAP_INDEX); | 4879 Context::SlotOffset(Context::FAST_ALIASED_ARGUMENTS_MAP_INDEX); |
| 4888 | 4880 |
| 4889 __ ldr(r4, NativeContextMemOperand()); | 4881 __ ldr(r4, NativeContextMemOperand()); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5066 // -- cp : context | 5058 // -- cp : context |
| 5067 // -- r0 : number of rest parameters (tagged) | 5059 // -- r0 : number of rest parameters (tagged) |
| 5068 // -- r2 : pointer to first rest parameters | 5060 // -- r2 : pointer to first rest parameters |
| 5069 // -- lr : return address | 5061 // -- lr : return address |
| 5070 // ----------------------------------- | 5062 // ----------------------------------- |
| 5071 | 5063 |
| 5072 // Allocate space for the strict arguments object plus the backing store. | 5064 // Allocate space for the strict arguments object plus the backing store. |
| 5073 Label allocate, done_allocate; | 5065 Label allocate, done_allocate; |
| 5074 __ mov(r1, Operand(JSStrictArgumentsObject::kSize + FixedArray::kHeaderSize)); | 5066 __ mov(r1, Operand(JSStrictArgumentsObject::kSize + FixedArray::kHeaderSize)); |
| 5075 __ add(r1, r1, Operand(r0, LSL, kPointerSizeLog2 - 1)); | 5067 __ add(r1, r1, Operand(r0, LSL, kPointerSizeLog2 - 1)); |
| 5076 __ Allocate(r1, r3, r4, r5, &allocate, TAG_OBJECT); | 5068 __ Allocate(r1, r3, r4, r5, &allocate, NO_ALLOCATION_FLAGS); |
| 5077 __ bind(&done_allocate); | 5069 __ bind(&done_allocate); |
| 5078 | 5070 |
| 5079 // Setup the elements array in r3. | 5071 // Setup the elements array in r3. |
| 5080 __ LoadRoot(r1, Heap::kFixedArrayMapRootIndex); | 5072 __ LoadRoot(r1, Heap::kFixedArrayMapRootIndex); |
| 5081 __ str(r1, FieldMemOperand(r3, FixedArray::kMapOffset)); | 5073 __ str(r1, FieldMemOperand(r3, FixedArray::kMapOffset)); |
| 5082 __ str(r0, FieldMemOperand(r3, FixedArray::kLengthOffset)); | 5074 __ str(r0, FieldMemOperand(r3, FixedArray::kLengthOffset)); |
| 5083 __ add(r4, r3, Operand(FixedArray::kHeaderSize)); | 5075 __ add(r4, r3, Operand(FixedArray::kHeaderSize)); |
| 5084 { | 5076 { |
| 5085 Label loop, done_loop; | 5077 Label loop, done_loop; |
| 5086 __ add(r1, r4, Operand(r0, LSL, kPointerSizeLog2 - 1)); | 5078 __ add(r1, r4, Operand(r0, LSL, kPointerSizeLog2 - 1)); |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5577 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, | 5569 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, |
| 5578 kStackUnwindSpace, NULL, return_value_operand, NULL); | 5570 kStackUnwindSpace, NULL, return_value_operand, NULL); |
| 5579 } | 5571 } |
| 5580 | 5572 |
| 5581 #undef __ | 5573 #undef __ |
| 5582 | 5574 |
| 5583 } // namespace internal | 5575 } // namespace internal |
| 5584 } // namespace v8 | 5576 } // namespace v8 |
| 5585 | 5577 |
| 5586 #endif // V8_TARGET_ARCH_ARM | 5578 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |