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

Side by Side Diff: src/mips/code-stubs-mips.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_MIPS 5 #if V8_TARGET_ARCH_MIPS
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 4730 matching lines...) Expand 10 before | Expand all | Expand 10 after
4741 4741
4742 Label fast_elements_case; 4742 Label fast_elements_case;
4743 __ Branch(&fast_elements_case, eq, a3, Operand(FAST_ELEMENTS)); 4743 __ Branch(&fast_elements_case, eq, a3, Operand(FAST_ELEMENTS));
4744 GenerateCase(masm, FAST_HOLEY_ELEMENTS); 4744 GenerateCase(masm, FAST_HOLEY_ELEMENTS);
4745 4745
4746 __ bind(&fast_elements_case); 4746 __ bind(&fast_elements_case);
4747 GenerateCase(masm, FAST_ELEMENTS); 4747 GenerateCase(masm, FAST_ELEMENTS);
4748 } 4748 }
4749 4749
4750 4750
4751 void FastNewObjectStub::Generate(MacroAssembler* masm) {
4752 // ----------- S t a t e -------------
4753 // -- a1 : target
4754 // -- a3 : new target
4755 // -- cp : context
4756 // -- ra : return address
4757 // -----------------------------------
4758 __ AssertFunction(a1);
4759 __ AssertReceiver(a3);
4760
4761 // Verify that the new target is a JSFunction.
4762 Label new_object;
4763 __ GetObjectType(a3, a2, a2);
4764 __ Branch(&new_object, ne, a2, Operand(JS_FUNCTION_TYPE));
4765
4766 // Load the initial map and verify that it's in fact a map.
4767 __ lw(a2, FieldMemOperand(a3, JSFunction::kPrototypeOrInitialMapOffset));
4768 __ JumpIfSmi(a2, &new_object);
4769 __ GetObjectType(a2, a0, a0);
4770 __ Branch(&new_object, ne, a2, Operand(MAP_TYPE));
4771
4772 // Fall back to runtime if the target differs from the new target's
4773 // initial map constructor.
4774 __ lw(a0, FieldMemOperand(a2, Map::kConstructorOrBackPointerOffset));
4775 __ Branch(&new_object, ne, a0, Operand(a1));
4776
4777 // Allocate the JSObject on the heap.
4778 Label allocate, done_allocate;
4779 __ lbu(t0, FieldMemOperand(a2, Map::kInstanceSizeOffset));
4780 __ Allocate(t0, v0, t1, a0, &allocate, SIZE_IN_WORDS);
4781 __ bind(&done_allocate);
4782
4783 // Initialize the JSObject fields.
4784 __ sw(a2, MemOperand(v0, JSObject::kMapOffset));
4785 __ LoadRoot(a3, Heap::kEmptyFixedArrayRootIndex);
4786 __ sw(a3, MemOperand(v0, JSObject::kPropertiesOffset));
4787 __ sw(a3, MemOperand(v0, JSObject::kElementsOffset));
4788 STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize);
4789 __ Addu(a1, v0, Operand(JSObject::kHeaderSize));
4790
4791 // ----------- S t a t e -------------
4792 // -- v0 : result (untagged)
4793 // -- a1 : result fields (untagged)
4794 // -- t1 : result end (untagged)
4795 // -- a2 : initial map
4796 // -- cp : context
4797 // -- ra : return address
4798 // -----------------------------------
4799
4800 // Perform in-object slack tracking if requested.
4801 Label slack_tracking;
4802 STATIC_ASSERT(Map::kNoSlackTracking == 0);
4803 __ lw(a3, FieldMemOperand(a2, Map::kBitField3Offset));
4804 __ And(at, a3, Operand(Map::ConstructionCounter::kMask));
4805 __ Branch(USE_DELAY_SLOT, &slack_tracking, ne, at, Operand(0));
4806 __ LoadRoot(a0, Heap::kUndefinedValueRootIndex); // In delay slot.
4807 {
4808 // Initialize all in-object fields with undefined.
4809 __ InitializeFieldsWithFiller(a1, t1, a0);
4810
4811 // Add the object tag to make the JSObject real.
4812 STATIC_ASSERT(kHeapObjectTag == 1);
4813 __ Ret(USE_DELAY_SLOT);
4814 __ Addu(v0, v0, Operand(kHeapObjectTag)); // In delay slot.
4815 }
4816 __ bind(&slack_tracking);
4817 {
4818 // Decrease generous allocation count.
4819 STATIC_ASSERT(Map::ConstructionCounter::kNext == 32);
4820 __ Subu(a3, a3, Operand(1 << Map::ConstructionCounter::kShift));
4821 __ sw(a3, FieldMemOperand(a2, Map::kBitField3Offset));
4822
4823 // Initialize the in-object fields with undefined.
4824 __ lbu(t0, FieldMemOperand(a2, Map::kUnusedPropertyFieldsOffset));
4825 __ sll(t0, t0, kPointerSizeLog2);
4826 __ subu(t0, t1, t0);
4827 __ InitializeFieldsWithFiller(a1, t0, a0);
4828
4829 // Initialize the remaining (reserved) fields with one pointer filler map.
4830 __ LoadRoot(a0, Heap::kOnePointerFillerMapRootIndex);
4831 __ InitializeFieldsWithFiller(a1, t1, a0);
4832
4833 // Check if we can finalize the instance size.
4834 Label finalize;
4835 STATIC_ASSERT(Map::kSlackTrackingCounterEnd == 1);
4836 __ And(a3, a3, Operand(Map::ConstructionCounter::kMask));
4837 __ Branch(USE_DELAY_SLOT, &finalize, eq, a3, Operand(zero_reg));
4838 STATIC_ASSERT(kHeapObjectTag == 1);
4839 __ Addu(v0, v0, Operand(kHeapObjectTag)); // In delay slot.
4840 __ Ret();
4841
4842 // Finalize the instance size.
4843 __ bind(&finalize);
4844 {
4845 FrameScope scope(masm, StackFrame::INTERNAL);
4846 __ Push(v0, a2);
4847 __ CallRuntime(Runtime::kFinalizeInstanceSize);
4848 __ Pop(v0);
4849 }
4850 __ Ret();
4851 }
4852
4853 // Fall back to %AllocateInNewSpace.
4854 __ bind(&allocate);
4855 {
4856 FrameScope scope(masm, StackFrame::INTERNAL);
4857 STATIC_ASSERT(kSmiTag == 0);
4858 STATIC_ASSERT(kSmiTagSize == 1);
4859 __ sll(t0, t0, kPointerSizeLog2 + kSmiTagSize);
4860 __ Push(a2, t0);
4861 __ CallRuntime(Runtime::kAllocateInNewSpace);
4862 __ Pop(a2);
4863 }
4864 STATIC_ASSERT(kHeapObjectTag == 1);
4865 __ Subu(v0, v0, Operand(kHeapObjectTag));
4866 __ lbu(t1, FieldMemOperand(a2, Map::kInstanceSizeOffset));
4867 __ Lsa(t1, v0, t1, kPointerSizeLog2);
4868 __ jmp(&done_allocate);
4869
4870 // Fall back to %NewObject.
4871 __ bind(&new_object);
4872 __ Push(a1, a3);
4873 __ TailCallRuntime(Runtime::kNewObject);
4874 }
4875
4876
4751 void FastNewRestParameterStub::Generate(MacroAssembler* masm) { 4877 void FastNewRestParameterStub::Generate(MacroAssembler* masm) {
4752 // ----------- S t a t e ------------- 4878 // ----------- S t a t e -------------
4753 // -- a1 : function 4879 // -- a1 : function
4754 // -- cp : context 4880 // -- cp : context
4755 // -- fp : frame pointer 4881 // -- fp : frame pointer
4756 // -- ra : return address 4882 // -- ra : return address
4757 // ----------------------------------- 4883 // -----------------------------------
4758 __ AssertFunction(a1); 4884 __ AssertFunction(a1);
4759 4885
4760 // For Ignition we need to skip all possible handler/stub frames until 4886 // For Ignition we need to skip all possible handler/stub frames until
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after
5661 return_value_operand, NULL); 5787 return_value_operand, NULL);
5662 } 5788 }
5663 5789
5664 5790
5665 #undef __ 5791 #undef __
5666 5792
5667 } // namespace internal 5793 } // namespace internal
5668 } // namespace v8 5794 } // namespace v8
5669 5795
5670 #endif // V8_TARGET_ARCH_MIPS 5796 #endif // V8_TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698