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

Unified Diff: src/arm/code-stubs-arm.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/arm/code-stubs-arm.cc
diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc
index b4b9e3a20c5e3a635048c836758a154263911cb6..239eddd28efddd577ab0dd07e6425f6780f6ddb0 100644
--- a/src/arm/code-stubs-arm.cc
+++ b/src/arm/code-stubs-arm.cc
@@ -4561,6 +4561,131 @@ void InternalArrayConstructorStub::Generate(MacroAssembler* masm) {
}
+void FastNewObjectStub::Generate(MacroAssembler* masm) {
+ // ----------- S t a t e -------------
+ // -- r1 : target
+ // -- r3 : new target
+ // -- cp : context
+ // -- lr : return address
+ // -----------------------------------
+ __ AssertFunction(r1);
+ __ AssertReceiver(r3);
+
+ // Verify that the new target is a JSFunction.
+ Label new_object;
+ __ CompareObjectType(r3, r2, r2, JS_FUNCTION_TYPE);
+ __ b(ne, &new_object);
+
+ // Load the initial map and verify that it's in fact a map.
+ __ ldr(r2, FieldMemOperand(r3, JSFunction::kPrototypeOrInitialMapOffset));
+ __ JumpIfSmi(r2, &new_object);
+ __ CompareObjectType(r2, r0, r0, MAP_TYPE);
+ __ b(ne, &new_object);
+
+ // Fall back to runtime if the target differs from the new target's
+ // initial map constructor.
+ __ ldr(r0, FieldMemOperand(r2, Map::kConstructorOrBackPointerOffset));
+ __ cmp(r0, r1);
+ __ b(ne, &new_object);
+
+ // Allocate the JSObject on the heap.
+ Label allocate, done_allocate;
+ __ ldrb(r4, FieldMemOperand(r2, Map::kInstanceSizeOffset));
+ __ Allocate(r4, r0, r5, r6, &allocate, SIZE_IN_WORDS);
+ __ bind(&done_allocate);
+
+ // Initialize the JSObject fields.
+ __ str(r2, MemOperand(r0, JSObject::kMapOffset));
+ __ LoadRoot(r3, Heap::kEmptyFixedArrayRootIndex);
+ __ str(r3, MemOperand(r0, JSObject::kPropertiesOffset));
+ __ str(r3, MemOperand(r0, JSObject::kElementsOffset));
+ STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize);
+ __ add(r1, r0, Operand(JSObject::kHeaderSize));
+
+ // ----------- S t a t e -------------
+ // -- r0 : result (untagged)
+ // -- r1 : result fields (untagged)
+ // -- r5 : result end (untagged)
+ // -- r2 : initial map
+ // -- cp : context
+ // -- lr : return address
+ // -----------------------------------
+
+ // Perform in-object slack tracking if requested.
+ Label slack_tracking;
+ STATIC_ASSERT(Map::kNoSlackTracking == 0);
+ __ LoadRoot(r6, Heap::kUndefinedValueRootIndex);
+ __ ldr(r3, FieldMemOperand(r2, Map::kBitField3Offset));
+ __ tst(r3, Operand(Map::ConstructionCounter::kMask));
+ __ b(ne, &slack_tracking);
+ {
+ // Initialize all in-object fields with undefined.
+ __ InitializeFieldsWithFiller(r1, r5, r6);
+
+ // Add the object tag to make the JSObject real.
+ STATIC_ASSERT(kHeapObjectTag == 1);
+ __ add(r0, r0, Operand(kHeapObjectTag));
+ __ Ret();
+ }
+ __ bind(&slack_tracking);
+ {
+ // Decrease generous allocation count.
+ STATIC_ASSERT(Map::ConstructionCounter::kNext == 32);
+ __ sub(r3, r3, Operand(1 << Map::ConstructionCounter::kShift));
+ __ str(r3, FieldMemOperand(r2, Map::kBitField3Offset));
+
+ // Initialize the in-object fields with undefined.
+ __ ldrb(r4, FieldMemOperand(r2, Map::kUnusedPropertyFieldsOffset));
+ __ sub(r4, r5, Operand(r4, LSL, kPointerSizeLog2));
+ __ InitializeFieldsWithFiller(r1, r4, r6);
+
+ // Initialize the remaining (reserved) fields with one pointer filler map.
+ __ LoadRoot(r6, Heap::kOnePointerFillerMapRootIndex);
+ __ InitializeFieldsWithFiller(r1, r5, r6);
+
+ // Add the object tag to make the JSObject real.
+ STATIC_ASSERT(kHeapObjectTag == 1);
+ __ add(r0, r0, Operand(kHeapObjectTag));
+
+ // Check if we can finalize the instance size.
+ STATIC_ASSERT(Map::kSlackTrackingCounterEnd == 1);
+ __ tst(r3, Operand(Map::ConstructionCounter::kMask));
+ __ Ret(ne);
+
+ // Finalize the instance size.
+ {
+ FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
+ __ Push(r0, r2);
+ __ CallRuntime(Runtime::kFinalizeInstanceSize);
+ __ Pop(r0);
+ }
+ __ Ret();
+ }
+
+ // Fall back to %AllocateInNewSpace.
+ __ bind(&allocate);
+ {
+ FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
+ STATIC_ASSERT(kSmiTag == 0);
+ STATIC_ASSERT(kSmiTagSize == 1);
+ __ mov(r4, Operand(r4, LSL, kPointerSizeLog2 + 1));
+ __ Push(r2, r4);
+ __ CallRuntime(Runtime::kAllocateInNewSpace);
+ __ Pop(r2);
+ }
+ STATIC_ASSERT(kHeapObjectTag == 1);
+ __ sub(r0, r0, Operand(kHeapObjectTag));
+ __ ldrb(r5, FieldMemOperand(r2, Map::kInstanceSizeOffset));
+ __ add(r5, r0, Operand(r5, LSL, kPointerSizeLog2));
+ __ b(&done_allocate);
+
+ // Fall back to %NewObject.
+ __ bind(&new_object);
+ __ Push(r1, r3);
+ __ TailCallRuntime(Runtime::kNewObject);
+}
+
+
void FastNewRestParameterStub::Generate(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- r1 : function

Powered by Google App Engine
This is Rietveld 408576698