Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: src/mips64/code-stubs-mips64.cc

Issue 1708313002: [stubs] Introduce a dedicated FastNewObjectStub. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove TODO. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_MIPS64 5 #if V8_TARGET_ARCH_MIPS64
6 6
7 #include "src/bootstrapper.h" 7 #include "src/bootstrapper.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/codegen.h" 9 #include "src/codegen.h"
10 #include "src/ic/handler-compiler.h" 10 #include "src/ic/handler-compiler.h"
(...skipping 4736 matching lines...) Expand 10 before | Expand all | Expand 10 after
4747 4747
4748 Label fast_elements_case; 4748 Label fast_elements_case;
4749 __ Branch(&fast_elements_case, eq, a3, Operand(FAST_ELEMENTS)); 4749 __ Branch(&fast_elements_case, eq, a3, Operand(FAST_ELEMENTS));
4750 GenerateCase(masm, FAST_HOLEY_ELEMENTS); 4750 GenerateCase(masm, FAST_HOLEY_ELEMENTS);
4751 4751
4752 __ bind(&fast_elements_case); 4752 __ bind(&fast_elements_case);
4753 GenerateCase(masm, FAST_ELEMENTS); 4753 GenerateCase(masm, FAST_ELEMENTS);
4754 } 4754 }
4755 4755
4756 4756
4757 void FastNewObjectStub::Generate(MacroAssembler* masm) {
4758 // ----------- S t a t e -------------
4759 // -- a1 : target
4760 // -- a3 : new target
4761 // -- cp : context
4762 // -- ra : return address
4763 // -----------------------------------
4764 __ AssertFunction(a1);
4765 __ AssertReceiver(a3);
4766
4767 // Verify that the new target is a JSFunction.
4768 Label new_object;
4769 __ GetObjectType(a3, a2, a2);
4770 __ Branch(&new_object, ne, a2, Operand(JS_FUNCTION_TYPE));
4771
4772 // Load the initial map and verify that it's in fact a map.
4773 __ ld(a2, FieldMemOperand(a3, JSFunction::kPrototypeOrInitialMapOffset));
4774 __ JumpIfSmi(a2, &new_object);
4775 __ GetObjectType(a2, a0, a0);
4776 __ Branch(&new_object, ne, a2, Operand(MAP_TYPE));
4777
4778 // Fall back to runtime if the target differs from the new target's
4779 // initial map constructor.
4780 __ ld(a0, FieldMemOperand(a2, Map::kConstructorOrBackPointerOffset));
4781 __ Branch(&new_object, ne, a0, Operand(a1));
4782
4783 // Allocate the JSObject on the heap.
4784 Label allocate, done_allocate;
4785 __ lbu(a4, FieldMemOperand(a2, Map::kInstanceSizeOffset));
4786 __ Allocate(a4, v0, a5, a0, &allocate, SIZE_IN_WORDS);
4787 __ bind(&done_allocate);
4788
4789 // Initialize the JSObject fields.
4790 __ sd(a2, MemOperand(v0, JSObject::kMapOffset));
4791 __ LoadRoot(a3, Heap::kEmptyFixedArrayRootIndex);
4792 __ sd(a3, MemOperand(v0, JSObject::kPropertiesOffset));
4793 __ sd(a3, MemOperand(v0, JSObject::kElementsOffset));
4794 STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize);
4795 __ Addu(a1, v0, Operand(JSObject::kHeaderSize));
4796
4797 // ----------- S t a t e -------------
4798 // -- v0 : result (untagged)
4799 // -- a1 : result fields (untagged)
4800 // -- a5 : result end (untagged)
4801 // -- a2 : initial map
4802 // -- cp : context
4803 // -- ra : return address
4804 // -----------------------------------
4805
4806 // Perform in-object slack tracking if requested.
4807 Label slack_tracking;
4808 STATIC_ASSERT(Map::kNoSlackTracking == 0);
4809 __ lw(a3, FieldMemOperand(a2, Map::kBitField3Offset));
4810 __ And(at, a3, Operand(Map::ConstructionCounter::kMask));
4811 __ Branch(USE_DELAY_SLOT, &slack_tracking, ne, at, Operand(zero_reg));
4812 __ LoadRoot(a0, Heap::kUndefinedValueRootIndex); // In delay slot.
4813 {
4814 // Initialize all in-object fields with undefined.
4815 __ InitializeFieldsWithFiller(a1, a5, a0);
4816
4817 // Add the object tag to make the JSObject real.
4818 STATIC_ASSERT(kHeapObjectTag == 1);
4819 __ Ret(USE_DELAY_SLOT);
4820 __ Addu(v0, v0, Operand(kHeapObjectTag)); // In delay slot.
4821 }
4822 __ bind(&slack_tracking);
4823 {
4824 // Decrease generous allocation count.
4825 STATIC_ASSERT(Map::ConstructionCounter::kNext == 32);
4826 __ Subu(a3, a3, Operand(1 << Map::ConstructionCounter::kShift));
4827 __ sw(a3, FieldMemOperand(a2, Map::kBitField3Offset));
4828
4829 // Initialize the in-object fields with undefined.
4830 __ lbu(a4, FieldMemOperand(a2, Map::kUnusedPropertyFieldsOffset));
4831 __ dsll(a4, a4, kPointerSizeLog2);
4832 __ Dsubu(a4, a5, a4);
4833 __ InitializeFieldsWithFiller(a1, a4, a0);
4834
4835 // Initialize the remaining (reserved) fields with one pointer filler map.
4836 __ LoadRoot(a0, Heap::kOnePointerFillerMapRootIndex);
4837 __ InitializeFieldsWithFiller(a1, a5, a0);
4838
4839 // Check if we can finalize the instance size.
4840 Label finalize;
4841 STATIC_ASSERT(Map::kSlackTrackingCounterEnd == 1);
4842 __ And(a3, a3, Operand(Map::ConstructionCounter::kMask));
4843 __ Branch(USE_DELAY_SLOT, &finalize, eq, a3, Operand(zero_reg));
4844 STATIC_ASSERT(kHeapObjectTag == 1);
4845 __ Addu(v0, v0, Operand(kHeapObjectTag)); // In delay slot.
4846 __ Ret();
4847
4848 // Finalize the instance size.
4849 __ bind(&finalize);
4850 {
4851 FrameScope scope(masm, StackFrame::INTERNAL);
4852 __ Push(v0, a2);
4853 __ CallRuntime(Runtime::kFinalizeInstanceSize);
4854 __ Pop(v0);
4855 }
4856 __ Ret();
4857 }
4858
4859 // Fall back to %AllocateInNewSpace.
4860 __ bind(&allocate);
4861 {
4862 FrameScope scope(masm, StackFrame::INTERNAL);
4863 STATIC_ASSERT(kSmiTag == 0);
4864 STATIC_ASSERT(kSmiTagSize == 1);
4865 __ dsll(a4, a4, kPointerSizeLog2 + kSmiShiftSize + kSmiTagSize);
4866 __ Push(a2, a4);
4867 __ CallRuntime(Runtime::kAllocateInNewSpace);
4868 __ Pop(a2);
4869 }
4870 STATIC_ASSERT(kHeapObjectTag == 1);
4871 __ Dsubu(v0, v0, Operand(kHeapObjectTag));
4872 __ lbu(a5, FieldMemOperand(a2, Map::kInstanceSizeOffset));
4873 __ Lsa(a5, v0, a5, kPointerSizeLog2);
4874 __ jmp(&done_allocate);
4875
4876 // Fall back to %NewObject.
4877 __ bind(&new_object);
4878 __ Push(a1, a3);
4879 __ TailCallRuntime(Runtime::kNewObject);
4880 }
4881
4882
4757 void FastNewRestParameterStub::Generate(MacroAssembler* masm) { 4883 void FastNewRestParameterStub::Generate(MacroAssembler* masm) {
4758 // ----------- S t a t e ------------- 4884 // ----------- S t a t e -------------
4759 // -- a1 : function 4885 // -- a1 : function
4760 // -- cp : context 4886 // -- cp : context
4761 // -- fp : frame pointer 4887 // -- fp : frame pointer
4762 // -- ra : return address 4888 // -- ra : return address
4763 // ----------------------------------- 4889 // -----------------------------------
4764 __ AssertFunction(a1); 4890 __ AssertFunction(a1);
4765 4891
4766 // For Ignition we need to skip all possible handler/stub frames until 4892 // For Ignition we need to skip all possible handler/stub frames until
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
5689 return_value_operand, NULL); 5815 return_value_operand, NULL);
5690 } 5816 }
5691 5817
5692 5818
5693 #undef __ 5819 #undef __
5694 5820
5695 } // namespace internal 5821 } // namespace internal
5696 } // namespace v8 5822 } // namespace v8
5697 5823
5698 #endif // V8_TARGET_ARCH_MIPS64 5824 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698