Index: src/ppc/code-stubs-ppc.cc |
diff --git a/src/ppc/code-stubs-ppc.cc b/src/ppc/code-stubs-ppc.cc |
index 66d5cb3cb8747cb810ced0da5b64eb9cad9773d2..3734f1f6e60a64b74b3e65560d3e3dbd636a23c0 100644 |
--- a/src/ppc/code-stubs-ppc.cc |
+++ b/src/ppc/code-stubs-ppc.cc |
@@ -4704,6 +4704,128 @@ void InternalArrayConstructorStub::Generate(MacroAssembler* masm) { |
GenerateCase(masm, FAST_ELEMENTS); |
} |
+void FastNewObjectStub::Generate(MacroAssembler* masm) { |
+ // ----------- S t a t e ------------- |
+ // -- r4 : target |
+ // -- r6 : new target |
+ // -- cp : context |
+ // -- lr : return address |
+ // ----------------------------------- |
+ __ AssertFunction(r4); |
+ __ AssertReceiver(r6); |
+ |
+ // Verify that the new target is a JSFunction. |
+ Label new_object; |
+ __ CompareObjectType(r6, r5, r5, JS_FUNCTION_TYPE); |
+ __ bne(&new_object); |
+ |
+ // Load the initial map and verify that it's in fact a map. |
+ __ LoadP(r5, FieldMemOperand(r6, JSFunction::kPrototypeOrInitialMapOffset)); |
+ __ JumpIfSmi(r5, &new_object); |
+ __ CompareObjectType(r5, r3, r3, MAP_TYPE); |
+ __ bne(&new_object); |
+ |
+ // Fall back to runtime if the target differs from the new target's |
+ // initial map constructor. |
+ __ LoadP(r3, FieldMemOperand(r5, Map::kConstructorOrBackPointerOffset)); |
+ __ cmp(r3, r4); |
+ __ bne(&new_object); |
+ |
+ // Allocate the JSObject on the heap. |
+ Label allocate, done_allocate; |
+ __ lbz(r7, FieldMemOperand(r5, Map::kInstanceSizeOffset)); |
+ __ Allocate(r7, r3, r8, r9, &allocate, SIZE_IN_WORDS); |
+ __ bind(&done_allocate); |
+ |
+ // Initialize the JSObject fields. |
+ __ StoreP(r5, MemOperand(r3, JSObject::kMapOffset)); |
+ __ LoadRoot(r6, Heap::kEmptyFixedArrayRootIndex); |
+ __ StoreP(r6, MemOperand(r3, JSObject::kPropertiesOffset)); |
+ __ StoreP(r6, MemOperand(r3, JSObject::kElementsOffset)); |
+ STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize); |
+ __ addi(r4, r3, Operand(JSObject::kHeaderSize)); |
+ |
+ // ----------- S t a t e ------------- |
+ // -- r3 : result (untagged) |
+ // -- r4 : result fields (untagged) |
+ // -- r8 : result end (untagged) |
+ // -- r5 : initial map |
+ // -- cp : context |
+ // -- lr : return address |
+ // ----------------------------------- |
+ |
+ // Perform in-object slack tracking if requested. |
+ Label slack_tracking; |
+ STATIC_ASSERT(Map::kNoSlackTracking == 0); |
+ __ LoadRoot(r9, Heap::kUndefinedValueRootIndex); |
+ __ lwz(r6, FieldMemOperand(r5, Map::kBitField3Offset)); |
+ __ DecodeField<Map::ConstructionCounter>(r10, r6, SetRC); |
+ __ bne(&slack_tracking, cr0); |
+ { |
+ // Initialize all in-object fields with undefined. |
+ __ InitializeFieldsWithFiller(r4, r8, r9); |
+ |
+ // Add the object tag to make the JSObject real. |
+ __ addi(r3, r3, Operand(kHeapObjectTag)); |
+ __ Ret(); |
+ } |
+ __ bind(&slack_tracking); |
+ { |
+ // Decrease generous allocation count. |
+ STATIC_ASSERT(Map::ConstructionCounter::kNext == 32); |
+ __ Add(r6, r6, -(1 << Map::ConstructionCounter::kShift), r0); |
+ __ stw(r6, FieldMemOperand(r5, Map::kBitField3Offset)); |
+ |
+ // Initialize the in-object fields with undefined. |
+ __ lbz(r7, FieldMemOperand(r5, Map::kUnusedPropertyFieldsOffset)); |
+ __ ShiftLeftImm(r7, r7, Operand(kPointerSizeLog2)); |
+ __ sub(r7, r8, r7); |
+ __ InitializeFieldsWithFiller(r4, r7, r9); |
+ |
+ // Initialize the remaining (reserved) fields with one pointer filler map. |
+ __ LoadRoot(r9, Heap::kOnePointerFillerMapRootIndex); |
+ __ InitializeFieldsWithFiller(r4, r8, r9); |
+ |
+ // Add the object tag to make the JSObject real. |
+ __ addi(r3, r3, Operand(kHeapObjectTag)); |
+ |
+ // Check if we can finalize the instance size. |
+ __ cmpi(r10, Operand(Map::kSlackTrackingCounterEnd)); |
+ __ Ret(ne); |
+ |
+ // Finalize the instance size. |
+ { |
+ FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
+ __ Push(r3, r5); |
+ __ CallRuntime(Runtime::kFinalizeInstanceSize); |
+ __ Pop(r3); |
+ } |
+ __ Ret(); |
+ } |
+ |
+ // Fall back to %AllocateInNewSpace. |
+ __ bind(&allocate); |
+ { |
+ FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
+ STATIC_ASSERT(kSmiTag == 0); |
+ __ ShiftLeftImm(r7, r7, |
+ Operand(kPointerSizeLog2 + kSmiTagSize + kSmiShiftSize)); |
+ __ Push(r5, r7); |
+ __ CallRuntime(Runtime::kAllocateInNewSpace); |
+ __ Pop(r5); |
+ } |
+ __ subi(r3, r3, Operand(kHeapObjectTag)); |
+ __ lbz(r8, FieldMemOperand(r5, Map::kInstanceSizeOffset)); |
+ __ ShiftLeftImm(r8, r8, Operand(kPointerSizeLog2)); |
+ __ add(r8, r3, r8); |
+ __ b(&done_allocate); |
+ |
+ // Fall back to %NewObject. |
+ __ bind(&new_object); |
+ __ Push(r4, r6); |
+ __ TailCallRuntime(Runtime::kNewObject); |
+} |
+ |
void FastNewRestParameterStub::Generate(MacroAssembler* masm) { |
// ----------- S t a t e ------------- |
// -- r4 : function |