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

Unified Diff: src/arm64/code-stubs-arm64.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/arm64/code-stubs-arm64.cc
diff --git a/src/arm64/code-stubs-arm64.cc b/src/arm64/code-stubs-arm64.cc
index d4cd44a577a985a22db2ac8b17581baf3a381039..57a0ffde92128c807ebeaceeb38ae7b3f16abfd4 100644
--- a/src/arm64/code-stubs-arm64.cc
+++ b/src/arm64/code-stubs-arm64.cc
@@ -4829,6 +4829,133 @@ void InternalArrayConstructorStub::Generate(MacroAssembler* masm) {
}
+void FastNewObjectStub::Generate(MacroAssembler* masm) {
+ // ----------- S t a t e -------------
+ // -- x1 : target
+ // -- x3 : new target
+ // -- cp : context
+ // -- lr : return address
+ // -----------------------------------
+ __ AssertFunction(x1);
+ __ AssertReceiver(x3);
+
+ // Verify that the new target is a JSFunction.
+ Label new_object;
+ __ JumpIfNotObjectType(x3, x2, x2, JS_FUNCTION_TYPE, &new_object);
+
+ // Load the initial map and verify that it's in fact a map.
+ __ Ldr(x2, FieldMemOperand(x3, JSFunction::kPrototypeOrInitialMapOffset));
+ __ JumpIfSmi(x2, &new_object);
+ __ JumpIfNotObjectType(x2, x0, x0, MAP_TYPE, &new_object);
+
+ // Fall back to runtime if the target differs from the new target's
+ // initial map constructor.
+ __ Ldr(x0, FieldMemOperand(x2, Map::kConstructorOrBackPointerOffset));
+ __ CompareAndBranch(x0, x1, ne, &new_object);
+
+ // Allocate the JSObject on the heap.
+ Label allocate, done_allocate;
+ __ Ldrb(x4, FieldMemOperand(x2, Map::kInstanceSizeOffset));
+ __ Allocate(x4, x0, x5, x6, &allocate, SIZE_IN_WORDS);
+ __ Bind(&done_allocate);
+
+ // Initialize the JSObject fields.
+ __ Mov(x1, x0);
+ STATIC_ASSERT(JSObject::kMapOffset == 0 * kPointerSize);
+ __ Str(x2, MemOperand(x1, kPointerSize, PostIndex));
+ __ LoadRoot(x3, Heap::kEmptyFixedArrayRootIndex);
+ STATIC_ASSERT(JSObject::kPropertiesOffset == 1 * kPointerSize);
+ STATIC_ASSERT(JSObject::kElementsOffset == 2 * kPointerSize);
+ __ Stp(x3, x3, MemOperand(x1, 2 * kPointerSize, PostIndex));
+ STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize);
+
+ // ----------- S t a t e -------------
+ // -- x0 : result (untagged)
+ // -- x1 : result fields (untagged)
+ // -- x5 : result end (untagged)
+ // -- x2 : initial map
+ // -- cp : context
+ // -- lr : return address
+ // -----------------------------------
+
+ // Perform in-object slack tracking if requested.
+ Label slack_tracking;
+ STATIC_ASSERT(Map::kNoSlackTracking == 0);
+ __ LoadRoot(x6, Heap::kUndefinedValueRootIndex);
+ __ Ldr(w3, FieldMemOperand(x2, Map::kBitField3Offset));
+ __ TestAndBranchIfAnySet(w3, Map::ConstructionCounter::kMask,
+ &slack_tracking);
+ {
+ // Initialize all in-object fields with undefined.
+ __ InitializeFieldsWithFiller(x1, x5, x6);
+
+ // Add the object tag to make the JSObject real.
+ STATIC_ASSERT(kHeapObjectTag == 1);
+ __ Add(x0, x0, kHeapObjectTag);
+ __ Ret();
+ }
+ __ Bind(&slack_tracking);
+ {
+ // Decrease generous allocation count.
+ STATIC_ASSERT(Map::ConstructionCounter::kNext == 32);
+ __ Sub(w3, w3, 1 << Map::ConstructionCounter::kShift);
+ __ Str(w3, FieldMemOperand(x2, Map::kBitField3Offset));
+
+ // Initialize the in-object fields with undefined.
+ __ Ldrb(x4, FieldMemOperand(x2, Map::kUnusedPropertyFieldsOffset));
+ __ Sub(x4, x5, Operand(x4, LSL, kPointerSizeLog2));
+ __ InitializeFieldsWithFiller(x1, x4, x6);
+
+ // Initialize the remaining (reserved) fields with one pointer filler map.
+ __ LoadRoot(x6, Heap::kOnePointerFillerMapRootIndex);
+ __ InitializeFieldsWithFiller(x1, x5, x6);
+
+ // Add the object tag to make the JSObject real.
+ STATIC_ASSERT(kHeapObjectTag == 1);
+ __ Add(x0, x0, kHeapObjectTag);
+
+ // Check if we can finalize the instance size.
+ Label finalize;
+ STATIC_ASSERT(Map::kSlackTrackingCounterEnd == 1);
+ __ TestAndBranchIfAllClear(w3, Map::ConstructionCounter::kMask, &finalize);
+ __ Ret();
+
+ // Finalize the instance size.
+ __ Bind(&finalize);
+ {
+ FrameScope scope(masm, StackFrame::INTERNAL);
+ __ Push(x0, x2);
+ __ CallRuntime(Runtime::kFinalizeInstanceSize);
+ __ Pop(x0);
+ }
+ __ Ret();
+ }
+
+ // Fall back to %AllocateInNewSpace.
+ __ Bind(&allocate);
+ {
+ FrameScope scope(masm, StackFrame::INTERNAL);
+ STATIC_ASSERT(kSmiTag == 0);
+ STATIC_ASSERT(kSmiTagSize == 1);
+ __ Mov(x4,
+ Operand(x4, LSL, kPointerSizeLog2 + kSmiTagSize + kSmiShiftSize));
+ __ Push(x2, x4);
+ __ CallRuntime(Runtime::kAllocateInNewSpace);
+ __ Pop(x2);
+ }
+ STATIC_ASSERT(kHeapObjectTag == 1);
+ __ Sub(x0, x0, kHeapObjectTag);
+ __ Ldrb(x5, FieldMemOperand(x2, Map::kInstanceSizeOffset));
+ __ Add(x5, x0, Operand(x5, LSL, kPointerSizeLog2));
+ __ B(&done_allocate);
+
+ // Fall back to %NewObject.
+ __ Bind(&new_object);
+ __ Push(x1, x3);
+ __ TailCallRuntime(Runtime::kNewObject);
+}
+
+
void FastNewRestParameterStub::Generate(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- x1 : function

Powered by Google App Engine
This is Rietveld 408576698