| Index: src/mips/builtins-mips.cc
|
| diff --git a/src/mips/builtins-mips.cc b/src/mips/builtins-mips.cc
|
| index cd96d9961c712f5863c7c8191dd30eadf303a5d6..628dc21235e865d004f9157d5a2449c6c7b361f1 100644
|
| --- a/src/mips/builtins-mips.cc
|
| +++ b/src/mips/builtins-mips.cc
|
| @@ -342,10 +342,12 @@ void Builtins::Generate_InOptimizationQueue(MacroAssembler* masm) {
|
|
|
| static void Generate_JSConstructStubHelper(MacroAssembler* masm,
|
| bool is_api_function,
|
| - bool count_constructions) {
|
| + bool count_constructions,
|
| + bool create_memento) {
|
| // ----------- S t a t e -------------
|
| // -- a0 : number of arguments
|
| // -- a1 : constructor function
|
| + // -- a2 : allocation site or undefined
|
| // -- ra : return address
|
| // -- sp[...]: constructor arguments
|
| // -----------------------------------
|
| @@ -353,6 +355,12 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
|
| // Should never count constructions for api objects.
|
| ASSERT(!is_api_function || !count_constructions);
|
|
|
| + // Should never create mementos for api functions.
|
| + ASSERT(!is_api_function || !create_memento);
|
| +
|
| + // Should never create mementos before slack tracking is finished.
|
| + ASSERT(!count_constructions || !create_memento);
|
| +
|
| Isolate* isolate = masm->isolate();
|
|
|
| // ----------- S t a t e -------------
|
| @@ -366,6 +374,11 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
|
| {
|
| FrameScope scope(masm, StackFrame::CONSTRUCT);
|
|
|
| + if (create_memento) {
|
| + __ AssertUndefinedOrAllocationSite(a2, a3);
|
| + __ push(a2);
|
| + }
|
| +
|
| // Preserve the two incoming parameters on the stack.
|
| __ sll(a0, a0, kSmiTagSize); // Tag arguments count.
|
| __ MultiPushReversed(a0.bit() | a1.bit());
|
| @@ -425,13 +438,17 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
|
| // a1: constructor function
|
| // a2: initial map
|
| __ lbu(a3, FieldMemOperand(a2, Map::kInstanceSizeOffset));
|
| + if (create_memento) {
|
| + __ Addu(a3, a3, Operand(AllocationMemento::kSize / kPointerSize));
|
| + }
|
| +
|
| __ Allocate(a3, t4, t5, t6, &rt_call, SIZE_IN_WORDS);
|
|
|
| // Allocated the JSObject, now initialize the fields. Map is set to
|
| // initial map and properties and elements are set to empty fixed array.
|
| // a1: constructor function
|
| // a2: initial map
|
| - // a3: object size
|
| + // a3: object size (not including memento if create_memento)
|
| // t4: JSObject (not tagged)
|
| __ LoadRoot(t6, Heap::kEmptyFixedArrayRootIndex);
|
| __ mov(t5, t4);
|
| @@ -446,14 +463,13 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
|
| // Fill all the in-object properties with appropriate filler.
|
| // a1: constructor function
|
| // a2: initial map
|
| - // a3: object size (in words)
|
| + // a3: object size (in words, including memento if create_memento)
|
| // t4: JSObject (not tagged)
|
| // t5: First in-object property of JSObject (not tagged)
|
| - __ sll(t0, a3, kPointerSizeLog2);
|
| - __ addu(t6, t4, t0); // End of object.
|
| ASSERT_EQ(3 * kPointerSize, JSObject::kHeaderSize);
|
| - __ LoadRoot(t7, Heap::kUndefinedValueRootIndex);
|
| +
|
| if (count_constructions) {
|
| + __ LoadRoot(t7, Heap::kUndefinedValueRootIndex);
|
| __ lw(a0, FieldMemOperand(a2, Map::kInstanceSizesOffset));
|
| __ Ext(a0, a0, Map::kPreAllocatedPropertyFieldsByte * kBitsPerByte,
|
| kBitsPerByte);
|
| @@ -467,8 +483,33 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
|
| __ InitializeFieldsWithFiller(t5, a0, t7);
|
| // To allow for truncation.
|
| __ LoadRoot(t7, Heap::kOnePointerFillerMapRootIndex);
|
| + __ sll(at, a3, kPointerSizeLog2);
|
| + __ Addu(a0, t4, Operand(at)); // End of object.
|
| + __ InitializeFieldsWithFiller(t5, a0, t7);
|
| + } else if (create_memento) {
|
| + __ Subu(t7, a3, Operand(AllocationMemento::kSize / kPointerSize));
|
| + __ sll(at, t7, kPointerSizeLog2);
|
| + __ Addu(a0, t4, Operand(at)); // End of object.
|
| + __ LoadRoot(t7, Heap::kUndefinedValueRootIndex);
|
| + __ InitializeFieldsWithFiller(t5, a0, t7);
|
| +
|
| + // Fill in memento fields.
|
| + // t5: points to the allocated but uninitialized memento.
|
| + __ LoadRoot(t7, Heap::kAllocationMementoMapRootIndex);
|
| + ASSERT_EQ(0 * kPointerSize, AllocationMemento::kMapOffset);
|
| + __ sw(t7, MemOperand(t5));
|
| + __ Addu(t5, t5, kPointerSize);
|
| + // Load the AllocationSite.
|
| + __ lw(t7, MemOperand(sp, 2 * kPointerSize));
|
| + ASSERT_EQ(1 * kPointerSize, AllocationMemento::kAllocationSiteOffset);
|
| + __ sw(t7, MemOperand(t5));
|
| + __ Addu(t5, t5, kPointerSize);
|
| + } else {
|
| + __ LoadRoot(t7, Heap::kUndefinedValueRootIndex);
|
| + __ sll(at, a3, kPointerSizeLog2);
|
| + __ Addu(a0, t4, Operand(at)); // End of object.
|
| + __ InitializeFieldsWithFiller(t5, a0, t7);
|
| }
|
| - __ InitializeFieldsWithFiller(t5, t6, t7);
|
|
|
| // Add the object tag to make the JSObject real, so that we can continue
|
| // and jump into the continuation code at any time from now on. Any
|
| @@ -572,15 +613,48 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
|
| __ UndoAllocationInNewSpace(t4, t5);
|
| }
|
|
|
| - __ bind(&rt_call);
|
| // Allocate the new receiver object using the runtime call.
|
| // a1: constructor function
|
| + __ bind(&rt_call);
|
| + if (create_memento) {
|
| + // Get the cell or allocation site.
|
| + __ lw(a2, MemOperand(sp, 2 * kPointerSize));
|
| + __ push(a2);
|
| + }
|
| +
|
| __ push(a1); // Argument for Runtime_NewObject.
|
| - __ CallRuntime(Runtime::kNewObject, 1);
|
| + if (create_memento) {
|
| + __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 2);
|
| + } else {
|
| + __ CallRuntime(Runtime::kNewObject, 1);
|
| + }
|
| __ mov(t4, v0);
|
|
|
| + // If we ended up using the runtime, and we want a memento, then the
|
| + // runtime call made it for us, and we shouldn't do create count
|
| + // increment.
|
| + Label count_incremented;
|
| + if (create_memento) {
|
| + __ jmp(&count_incremented);
|
| + }
|
| +
|
| // Receiver for constructor call allocated.
|
| // t4: JSObject
|
| +
|
| + if (create_memento) {
|
| + __ lw(a2, MemOperand(sp, kPointerSize * 2));
|
| + __ LoadRoot(t5, Heap::kUndefinedValueRootIndex);
|
| + __ Branch(&count_incremented, eq, a2, Operand(t5));
|
| + // a2 is an AllocationSite. We are creating a memento from it, so we
|
| + // need to increment the memento create count.
|
| + __ lw(a3, FieldMemOperand(a2,
|
| + AllocationSite::kPretenureCreateCountOffset));
|
| + __ Addu(a3, a3, Operand(Smi::FromInt(1)));
|
| + __ sw(a3, FieldMemOperand(a2,
|
| + AllocationSite::kPretenureCreateCountOffset));
|
| + __ bind(&count_incremented);
|
| + }
|
| +
|
| __ bind(&allocated);
|
| __ Push(t4, t4);
|
|
|
| @@ -682,17 +756,17 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
|
|
|
|
|
| void Builtins::Generate_JSConstructStubCountdown(MacroAssembler* masm) {
|
| - Generate_JSConstructStubHelper(masm, false, true);
|
| + Generate_JSConstructStubHelper(masm, false, true, false);
|
| }
|
|
|
|
|
| void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) {
|
| - Generate_JSConstructStubHelper(masm, false, false);
|
| + Generate_JSConstructStubHelper(masm, false, false, FLAG_pretenuring_call_new);
|
| }
|
|
|
|
|
| void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) {
|
| - Generate_JSConstructStubHelper(masm, true, false);
|
| + Generate_JSConstructStubHelper(masm, true, false, false);
|
| }
|
|
|
|
|
|
|