Index: src/mips/code-stubs-mips.cc |
diff --git a/src/mips/code-stubs-mips.cc b/src/mips/code-stubs-mips.cc |
index 0792403885318010b362929c9f396f8b987d9f12..dc224a985dc52746c5a33c633d809aa82445d2f7 100644 |
--- a/src/mips/code-stubs-mips.cc |
+++ b/src/mips/code-stubs-mips.cc |
@@ -4748,6 +4748,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. |
+ __ lw(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. |
+ __ lw(a0, FieldMemOperand(a2, Map::kConstructorOrBackPointerOffset)); |
+ __ Branch(&new_object, ne, a0, Operand(a1)); |
+ |
+ // Allocate the JSObject on the heap. |
+ Label allocate, done_allocate; |
+ __ lbu(t0, FieldMemOperand(a2, Map::kInstanceSizeOffset)); |
+ __ Allocate(t0, v0, t1, a0, &allocate, SIZE_IN_WORDS); |
+ __ bind(&done_allocate); |
+ |
+ // Initialize the JSObject fields. |
+ __ sw(a2, MemOperand(v0, JSObject::kMapOffset)); |
+ __ LoadRoot(a3, Heap::kEmptyFixedArrayRootIndex); |
+ __ sw(a3, MemOperand(v0, JSObject::kPropertiesOffset)); |
+ __ sw(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) |
+ // -- t1 : 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(0)); |
+ __ LoadRoot(a0, Heap::kUndefinedValueRootIndex); // In delay slot. |
+ { |
+ // Initialize all in-object fields with undefined. |
+ __ InitializeFieldsWithFiller(a1, t1, 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(t0, FieldMemOperand(a2, Map::kUnusedPropertyFieldsOffset)); |
+ __ sll(t0, t0, kPointerSizeLog2); |
+ __ subu(t0, t1, t0); |
+ __ InitializeFieldsWithFiller(a1, t0, a0); |
+ |
+ // Initialize the remaining (reserved) fields with one pointer filler map. |
+ __ LoadRoot(a0, Heap::kOnePointerFillerMapRootIndex); |
+ __ InitializeFieldsWithFiller(a1, t1, 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); |
+ __ sll(t0, t0, kPointerSizeLog2 + kSmiTagSize); |
+ __ Push(a2, t0); |
+ __ CallRuntime(Runtime::kAllocateInNewSpace); |
+ __ Pop(a2); |
+ } |
+ STATIC_ASSERT(kHeapObjectTag == 1); |
+ __ Subu(v0, v0, Operand(kHeapObjectTag)); |
+ __ lbu(t1, FieldMemOperand(a2, Map::kInstanceSizeOffset)); |
+ __ Lsa(t1, v0, t1, 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 |