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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: src/mips64/code-stubs-mips64.cc
diff --git a/src/mips64/code-stubs-mips64.cc b/src/mips64/code-stubs-mips64.cc
index 58828acfa4e3b59e0cb15085330d1156da98a7c4..8a71aacb0ba0c94a57b68d10a449a4a2a1e3ee2a 100644
--- a/src/mips64/code-stubs-mips64.cc
+++ b/src/mips64/code-stubs-mips64.cc
@@ -4754,6 +4754,132 @@ void InternalArrayConstructorStub::Generate(MacroAssembler* masm) {
}
+void FastNewObjectStub::Generate(MacroAssembler* masm) {
+ // ----------- S t a t e -------------
+ // -- a1 : target
+ // -- a3 : new target
+ // -- cp : context
+ // -- ra : return address
+ // -----------------------------------
+ __ AssertFunction(a1);
+ __ AssertReceiver(a3);
+
+ // Verify that the new target is a JSFunction.
+ Label new_object;
+ __ GetObjectType(a3, a2, a2);
+ __ Branch(&new_object, ne, a2, Operand(JS_FUNCTION_TYPE));
+
+ // Load the initial map and verify that it's in fact a map.
+ __ ld(a2, FieldMemOperand(a3, JSFunction::kPrototypeOrInitialMapOffset));
+ __ JumpIfSmi(a2, &new_object);
+ __ GetObjectType(a2, a0, a0);
+ __ Branch(&new_object, ne, a2, Operand(MAP_TYPE));
+
+ // Fall back to runtime if the target differs from the new target's
+ // initial map constructor.
+ __ ld(a0, FieldMemOperand(a2, Map::kConstructorOrBackPointerOffset));
+ __ Branch(&new_object, ne, a0, Operand(a1));
+
+ // Allocate the JSObject on the heap.
+ Label allocate, done_allocate;
+ __ lbu(a4, FieldMemOperand(a2, Map::kInstanceSizeOffset));
+ __ Allocate(a4, v0, a5, a0, &allocate, SIZE_IN_WORDS);
+ __ bind(&done_allocate);
+
+ // Initialize the JSObject fields.
+ __ sd(a2, MemOperand(v0, JSObject::kMapOffset));
+ __ LoadRoot(a3, Heap::kEmptyFixedArrayRootIndex);
+ __ sd(a3, MemOperand(v0, JSObject::kPropertiesOffset));
+ __ sd(a3, MemOperand(v0, JSObject::kElementsOffset));
+ STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize);
+ __ Addu(a1, v0, Operand(JSObject::kHeaderSize));
+
+ // ----------- S t a t e -------------
+ // -- v0 : result (untagged)
+ // -- a1 : result fields (untagged)
+ // -- a5 : result end (untagged)
+ // -- a2 : initial map
+ // -- cp : context
+ // -- ra : return address
+ // -----------------------------------
+
+ // Perform in-object slack tracking if requested.
+ Label slack_tracking;
+ STATIC_ASSERT(Map::kNoSlackTracking == 0);
+ __ lw(a3, FieldMemOperand(a2, Map::kBitField3Offset));
+ __ And(at, a3, Operand(Map::ConstructionCounter::kMask));
+ __ Branch(USE_DELAY_SLOT, &slack_tracking, ne, at, Operand(zero_reg));
+ __ LoadRoot(a0, Heap::kUndefinedValueRootIndex); // In delay slot.
+ {
+ // Initialize all in-object fields with undefined.
+ __ InitializeFieldsWithFiller(a1, a5, a0);
+
+ // Add the object tag to make the JSObject real.
+ STATIC_ASSERT(kHeapObjectTag == 1);
+ __ Ret(USE_DELAY_SLOT);
+ __ Addu(v0, v0, Operand(kHeapObjectTag)); // In delay slot.
+ }
+ __ bind(&slack_tracking);
+ {
+ // Decrease generous allocation count.
+ STATIC_ASSERT(Map::ConstructionCounter::kNext == 32);
+ __ Subu(a3, a3, Operand(1 << Map::ConstructionCounter::kShift));
+ __ sw(a3, FieldMemOperand(a2, Map::kBitField3Offset));
+
+ // Initialize the in-object fields with undefined.
+ __ lbu(a4, FieldMemOperand(a2, Map::kUnusedPropertyFieldsOffset));
+ __ dsll(a4, a4, kPointerSizeLog2);
+ __ Dsubu(a4, a5, a4);
+ __ InitializeFieldsWithFiller(a1, a4, a0);
+
+ // Initialize the remaining (reserved) fields with one pointer filler map.
+ __ LoadRoot(a0, Heap::kOnePointerFillerMapRootIndex);
+ __ InitializeFieldsWithFiller(a1, a5, a0);
+
+ // Check if we can finalize the instance size.
+ Label finalize;
+ STATIC_ASSERT(Map::kSlackTrackingCounterEnd == 1);
+ __ And(a3, a3, Operand(Map::ConstructionCounter::kMask));
+ __ Branch(USE_DELAY_SLOT, &finalize, eq, a3, Operand(zero_reg));
+ STATIC_ASSERT(kHeapObjectTag == 1);
+ __ Addu(v0, v0, Operand(kHeapObjectTag)); // In delay slot.
+ __ Ret();
+
+ // Finalize the instance size.
+ __ bind(&finalize);
+ {
+ FrameScope scope(masm, StackFrame::INTERNAL);
+ __ Push(v0, a2);
+ __ CallRuntime(Runtime::kFinalizeInstanceSize);
+ __ Pop(v0);
+ }
+ __ Ret();
+ }
+
+ // Fall back to %AllocateInNewSpace.
+ __ bind(&allocate);
+ {
+ FrameScope scope(masm, StackFrame::INTERNAL);
+ STATIC_ASSERT(kSmiTag == 0);
+ STATIC_ASSERT(kSmiTagSize == 1);
+ __ dsll(a4, a4, kPointerSizeLog2 + kSmiShiftSize + kSmiTagSize);
+ __ Push(a2, a4);
+ __ CallRuntime(Runtime::kAllocateInNewSpace);
+ __ Pop(a2);
+ }
+ STATIC_ASSERT(kHeapObjectTag == 1);
+ __ Dsubu(v0, v0, Operand(kHeapObjectTag));
+ __ lbu(a5, FieldMemOperand(a2, Map::kInstanceSizeOffset));
+ __ Lsa(a5, v0, a5, kPointerSizeLog2);
+ __ jmp(&done_allocate);
+
+ // Fall back to %NewObject.
+ __ bind(&new_object);
+ __ Push(a1, a3);
+ __ TailCallRuntime(Runtime::kNewObject);
+}
+
+
void FastNewRestParameterStub::Generate(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- a1 : function

Powered by Google App Engine
This is Rietveld 408576698