Commit e50c861b authored by mstarzinger's avatar mstarzinger Committed by Commit bot

Remove separate construct stub for new.target users.

R=bmeurer@chromium.org

Review URL: https://codereview.chromium.org/1213623020

Cr-Commit-Position: refs/heads/master@{#29562}
parent 8965b683
......@@ -318,7 +318,7 @@ static void Generate_Runtime_NewObject(MacroAssembler* masm,
Label* allocated) {
if (create_memento) {
// Get the cell or allocation site.
__ ldr(r2, MemOperand(sp, 2 * kPointerSize));
__ ldr(r2, MemOperand(sp, 3 * kPointerSize));
__ push(r2);
}
......@@ -343,7 +343,6 @@ static void Generate_Runtime_NewObject(MacroAssembler* masm,
static void Generate_JSConstructStubHelper(MacroAssembler* masm,
bool is_api_function,
bool use_new_target,
bool create_memento) {
// ----------- S t a t e -------------
// -- r0 : number of arguments
......@@ -372,9 +371,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ SmiTag(r0);
__ push(r0);
__ push(r1);
if (use_new_target) {
__ push(r3);
}
__ push(r3);
Label rt_call, allocated, normal_new, count_incremented;
__ cmp(r1, r3);
......@@ -614,8 +611,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ bind(&allocated);
if (create_memento) {
int offset = (use_new_target ? 3 : 2) * kPointerSize;
__ ldr(r2, MemOperand(sp, offset));
__ ldr(r2, MemOperand(sp, 3 * kPointerSize));
__ LoadRoot(r5, Heap::kUndefinedValueRootIndex);
__ cmp(r2, r5);
__ b(eq, &count_incremented);
......@@ -630,9 +626,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
}
// Restore the parameters.
if (use_new_target) {
__ pop(r3);
}
__ pop(r3);
__ pop(r1);
// Retrieve smi-tagged arguments count from the stack.
......@@ -641,9 +635,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// Push new.target onto the construct frame. This is stored just below the
// receiver on the stack.
if (use_new_target) {
__ push(r3);
}
__ push(r3);
__ push(r4);
__ push(r4);
......@@ -657,8 +649,8 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// r3: number of arguments (smi-tagged)
// sp[0]: receiver
// sp[1]: receiver
// sp[2]: new.target (if used)
// sp[2/3]: number of arguments (smi-tagged)
// sp[2]: new.target
// sp[3]: number of arguments (smi-tagged)
Label loop, entry;
__ SmiTag(r3, r0);
__ b(&entry);
......@@ -683,17 +675,15 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
}
// Store offset of return address for deoptimizer.
// TODO(arv): Remove the "!use_new_target" before supporting optimization
// of functions that reference new.target
if (!is_api_function && !use_new_target) {
if (!is_api_function) {
masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset());
}
// Restore context from the frame.
// r0: result
// sp[0]: receiver
// sp[1]: new.target (if used)
// sp[1/2]: number of arguments (smi-tagged)
// sp[1]: new.target
// sp[2]: number of arguments (smi-tagged)
__ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
// If the result is an object (in the ECMA sense), we should get rid
......@@ -723,10 +713,9 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ bind(&exit);
// r0: result
// sp[0]: receiver (newly allocated object)
// sp[1]: new.target (if used)
// sp[1/2]: number of arguments (smi-tagged)
int offset = (use_new_target ? 2 : 1) * kPointerSize;
__ ldr(r1, MemOperand(sp, offset));
// sp[1]: new.target (original constructor)
// sp[2]: number of arguments (smi-tagged)
__ ldr(r1, MemOperand(sp, 2 * kPointerSize));
// Leave construct frame.
}
......@@ -739,17 +728,12 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) {
Generate_JSConstructStubHelper(masm, false, false, FLAG_pretenuring_call_new);
Generate_JSConstructStubHelper(masm, false, FLAG_pretenuring_call_new);
}
void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) {
Generate_JSConstructStubHelper(masm, true, false, false);
}
void Builtins::Generate_JSConstructStubNewTarget(MacroAssembler* masm) {
Generate_JSConstructStubHelper(masm, false, true, FLAG_pretenuring_call_new);
Generate_JSConstructStubHelper(masm, true, false);
}
......
......@@ -309,7 +309,7 @@ static void Generate_Runtime_NewObject(MacroAssembler* masm,
Label* allocated) {
if (create_memento) {
// Get the cell or allocation site.
__ Peek(x4, 2 * kXRegSize);
__ Peek(x4, 3 * kXRegSize);
__ Push(x4);
__ Push(x1); // Argument for Runtime_NewObject.
__ Push(original_constructor);
......@@ -331,7 +331,6 @@ static void Generate_Runtime_NewObject(MacroAssembler* masm,
static void Generate_JSConstructStubHelper(MacroAssembler* masm,
bool is_api_function,
bool use_new_target,
bool create_memento) {
// ----------- S t a t e -------------
// -- x0 : number of arguments
......@@ -364,14 +363,10 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// Preserve the incoming parameters on the stack.
__ SmiTag(argc);
if (use_new_target) {
__ Push(argc, constructor, original_constructor);
} else {
__ Push(argc, constructor);
}
// sp[0]: new.target (if used)
// sp[0/1]: Constructor function.
// sp[1/2]: number of arguments (smi-tagged)
__ Push(argc, constructor, original_constructor);
// sp[0]: new.target
// sp[1]: Constructor function.
// sp[2]: number of arguments (smi-tagged)
Label rt_call, count_incremented, allocated, normal_new;
__ Cmp(constructor, original_constructor);
......@@ -587,8 +582,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ Bind(&allocated);
if (create_memento) {
int offset = (use_new_target ? 3 : 2) * kXRegSize;
__ Peek(x10, offset);
__ Peek(x10, 3 * kXRegSize);
__ JumpIfRoot(x10, Heap::kUndefinedValueRootIndex, &count_incremented);
// r2 is an AllocationSite. We are creating a memento from it, so we
// need to increment the memento create count.
......@@ -601,9 +595,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
}
// Restore the parameters.
if (use_new_target) {
__ Pop(original_constructor);
}
__ Pop(original_constructor);
__ Pop(constructor);
// Reload the number of arguments from the stack.
......@@ -612,11 +604,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ Peek(argc, 0); // Load number of arguments.
__ SmiUntag(argc);
if (use_new_target) {
__ Push(original_constructor, x4, x4);
} else {
__ Push(x4, x4);
}
__ Push(original_constructor, x4, x4);
// Set up pointer to last argument.
__ Add(x2, fp, StandardFrameConstants::kCallerSPOffset);
......@@ -628,8 +616,8 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// x2: address of last argument (caller sp)
// jssp[0]: receiver
// jssp[1]: receiver
// jssp[2]: new.target (if used)
// jssp[2/3]: number of arguments (smi-tagged)
// jssp[2]: new.target
// jssp[3]: number of arguments (smi-tagged)
// Compute the start address of the copy in x3.
__ Add(x3, x2, Operand(argc, LSL, kPointerSizeLog2));
Label loop, entry, done_copying_arguments;
......@@ -660,17 +648,15 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
}
// Store offset of return address for deoptimizer.
// TODO(arv): Remove the "!use_new_target" before supporting optimization
// of functions that reference new.target
if (!is_api_function && !use_new_target) {
if (!is_api_function) {
masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset());
}
// Restore the context from the frame.
// x0: result
// jssp[0]: receiver
// jssp[1]: new.target (if used)
// jssp[1/2]: number of arguments (smi-tagged)
// jssp[1]: new.target
// jssp[2]: number of arguments (smi-tagged)
__ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
// If the result is an object (in the ECMA sense), we should get rid
......@@ -698,10 +684,9 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ Bind(&exit);
// x0: result
// jssp[0]: receiver (newly allocated object)
// jssp[1]: new.target (if used)
// jssp[1/2]: number of arguments (smi-tagged)
int offset = (use_new_target ? 2 : 1) * kXRegSize;
__ Peek(x1, offset);
// jssp[1]: new.target (original constructor)
// jssp[2]: number of arguments (smi-tagged)
__ Peek(x1, 2 * kXRegSize);
// Leave construct frame.
}
......@@ -714,17 +699,12 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) {
Generate_JSConstructStubHelper(masm, false, false, FLAG_pretenuring_call_new);
Generate_JSConstructStubHelper(masm, false, FLAG_pretenuring_call_new);
}
void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) {
Generate_JSConstructStubHelper(masm, true, false, false);
}
void Builtins::Generate_JSConstructStubNewTarget(MacroAssembler* masm) {
Generate_JSConstructStubHelper(masm, false, true, FLAG_pretenuring_call_new);
Generate_JSConstructStubHelper(masm, true, false);
}
......
......@@ -70,7 +70,6 @@ enum BuiltinExtraArguments {
V(JSConstructStubGeneric, BUILTIN, UNINITIALIZED, kNoExtraICState) \
V(JSConstructStubForDerived, BUILTIN, UNINITIALIZED, kNoExtraICState) \
V(JSConstructStubApi, BUILTIN, UNINITIALIZED, kNoExtraICState) \
V(JSConstructStubNewTarget, BUILTIN, UNINITIALIZED, kNoExtraICState) \
V(JSEntryTrampoline, BUILTIN, UNINITIALIZED, kNoExtraICState) \
V(JSConstructEntryTrampoline, BUILTIN, UNINITIALIZED, kNoExtraICState) \
V(CompileLazy, BUILTIN, UNINITIALIZED, kNoExtraICState) \
......@@ -309,7 +308,6 @@ class Builtins {
static void Generate_JSConstructStubGeneric(MacroAssembler* masm);
static void Generate_JSConstructStubForDerived(MacroAssembler* masm);
static void Generate_JSConstructStubApi(MacroAssembler* masm);
static void Generate_JSConstructStubNewTarget(MacroAssembler* masm);
static void Generate_JSEntryTrampoline(MacroAssembler* masm);
static void Generate_JSConstructEntryTrampoline(MacroAssembler* masm);
static void Generate_NotifyDeoptimized(MacroAssembler* masm);
......
......@@ -1443,11 +1443,6 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
// first time. It may have already been compiled previously.
result->set_never_compiled(outer_info->is_first_compile() && lazy);
if (literal->scope()->new_target_var() != nullptr) {
Handle<Code> stub(isolate->builtins()->JSConstructStubNewTarget());
result->set_construct_stub(*stub);
}
RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result);
result->set_allows_lazy_compilation(literal->AllowsLazyCompilation());
result->set_allows_lazy_compilation_without_context(allow_lazy_without_ctx);
......
......@@ -1230,6 +1230,12 @@ void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator,
PrintF(trace_scope_->file(), "(%d)\n", height - 1);
}
// The original constructor.
output_offset -= kPointerSize;
value = reinterpret_cast<intptr_t>(isolate_->heap()->undefined_value());
output_frame->SetFrameSlot(output_offset, value);
DebugPrintOutputSlot(value, frame_index, output_offset, "new.target\n");
// The newly allocated object was passed as receiver in the artificial
// constructor stub environment created by HEnvironment::CopyForInlining().
output_offset -= kPointerSize;
......
......@@ -155,7 +155,7 @@ class ConstructFrameConstants : public AllStatic {
public:
// FP-relative.
static const int kImplicitReceiverOffset =
StandardFrameConstants::kExpressionsOffset - 2 * kPointerSize;
StandardFrameConstants::kExpressionsOffset - 3 * kPointerSize;
static const int kOriginalConstructorOffset =
StandardFrameConstants::kExpressionsOffset - 2 * kPointerSize;
static const int kLengthOffset =
......@@ -164,7 +164,7 @@ class ConstructFrameConstants : public AllStatic {
StandardFrameConstants::kExpressionsOffset - 0 * kPointerSize;
static const int kFrameSize =
StandardFrameConstants::kFixedFrameSize + 3 * kPointerSize;
StandardFrameConstants::kFixedFrameSize + 4 * kPointerSize;
};
......
......@@ -105,12 +105,12 @@ static void Generate_Runtime_NewObject(MacroAssembler* masm,
Register original_constructor,
Label* count_incremented,
Label* allocated) {
int offset = 0;
int offset = kPointerSize;
if (create_memento) {
// Get the cell or allocation site.
__ mov(edi, Operand(esp, kPointerSize * 2));
__ mov(edi, Operand(esp, kPointerSize * 3));
__ push(edi);
offset = kPointerSize;
offset += kPointerSize;
}
// Must restore esi (context) and edi (constructor) before calling
......@@ -138,7 +138,6 @@ static void Generate_Runtime_NewObject(MacroAssembler* masm,
static void Generate_JSConstructStubHelper(MacroAssembler* masm,
bool is_api_function,
bool use_new_target,
bool create_memento) {
// ----------- S t a t e -------------
// -- eax: number of arguments
......@@ -163,9 +162,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ SmiTag(eax);
__ push(eax);
__ push(edi);
if (use_new_target) {
__ push(edx);
}
__ push(edx);
__ cmp(edx, edi);
Label normal_new;
......@@ -393,8 +390,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ bind(&allocated);
if (create_memento) {
int offset = (use_new_target ? 3 : 2) * kPointerSize;
__ mov(ecx, Operand(esp, offset));
__ mov(ecx, Operand(esp, 3 * kPointerSize));
__ cmp(ecx, masm->isolate()->factory()->undefined_value());
__ j(equal, &count_incremented);
// ecx is an AllocationSite. We are creating a memento from it, so we
......@@ -405,9 +401,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
}
// Restore the parameters.
if (use_new_target) {
__ pop(edx); // new.target
}
__ pop(edx); // new.target
__ pop(edi); // Constructor function.
// Retrieve smi-tagged arguments count from the stack.
......@@ -416,9 +410,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// Push new.target onto the construct frame. This is stored just below the
// receiver on the stack.
if (use_new_target) {
__ push(edx);
}
__ push(edx);
// Push the allocated receiver to the stack. We need two copies
// because we may have to return the original one and the calling
......@@ -452,9 +444,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
}
// Store offset of return address for deoptimizer.
// TODO(arv): Remove the "!use_new_target" before supporting optimization
// of functions that reference new.target
if (!is_api_function && !use_new_target) {
if (!is_api_function) {
masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset());
}
......@@ -482,8 +472,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// Restore the arguments count and leave the construct frame. The arguments
// count is stored below the reciever and the new.target.
__ bind(&exit);
int offset = (use_new_target ? 2 : 1) * kPointerSize;
__ mov(ebx, Operand(esp, offset));
__ mov(ebx, Operand(esp, 2 * kPointerSize));
// Leave construct frame.
}
......@@ -499,17 +488,12 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) {
Generate_JSConstructStubHelper(masm, false, false, FLAG_pretenuring_call_new);
Generate_JSConstructStubHelper(masm, false, FLAG_pretenuring_call_new);
}
void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) {
Generate_JSConstructStubHelper(masm, true, false, false);
}
void Builtins::Generate_JSConstructStubNewTarget(MacroAssembler* masm) {
Generate_JSConstructStubHelper(masm, false, true, FLAG_pretenuring_call_new);
Generate_JSConstructStubHelper(masm, true, false);
}
......
......@@ -323,7 +323,7 @@ static void Generate_Runtime_NewObject(MacroAssembler* masm,
Label* allocated) {
if (create_memento) {
// Get the cell or allocation site.
__ lw(a2, MemOperand(sp, 2 * kPointerSize));
__ lw(a2, MemOperand(sp, 3 * kPointerSize));
__ push(a2);
}
......@@ -348,7 +348,6 @@ static void Generate_Runtime_NewObject(MacroAssembler* masm,
static void Generate_JSConstructStubHelper(MacroAssembler* masm,
bool is_api_function,
bool use_new_target,
bool create_memento) {
// ----------- S t a t e -------------
// -- a0 : number of arguments
......@@ -382,11 +381,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// Preserve the incoming parameters on the stack.
__ SmiTag(a0);
if (use_new_target) {
__ Push(a0, a1, a3);
} else {
__ Push(a0, a1);
}
__ Push(a0, a1, a3);
Label rt_call, allocated, normal_new, count_incremented;
__ Branch(&normal_new, eq, a1, Operand(a3));
......@@ -633,8 +628,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ bind(&allocated);
if (create_memento) {
int offset = (use_new_target ? 3 : 2) * kPointerSize;
__ lw(a2, MemOperand(sp, offset));
__ lw(a2, MemOperand(sp, 3 * kPointerSize));
__ LoadRoot(t5, Heap::kUndefinedValueRootIndex);
__ Branch(&count_incremented, eq, a2, Operand(t5));
// a2 is an AllocationSite. We are creating a memento from it, so we
......@@ -648,20 +642,14 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
}
// Restore the parameters.
if (use_new_target) {
__ Pop(a3); // new.target
}
__ Pop(a3); // new.target
__ Pop(a1);
// Retrieve smi-tagged arguments count from the stack.
__ lw(a0, MemOperand(sp));
__ SmiUntag(a0);
if (use_new_target) {
__ Push(a3, t4, t4);
} else {
__ Push(t4, t4);
}
__ Push(a3, t4, t4);
// Set up pointer to last argument.
__ Addu(a2, fp, Operand(StandardFrameConstants::kCallerSPOffset));
......@@ -673,8 +661,8 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// a3: number of arguments (smi-tagged)
// sp[0]: receiver
// sp[1]: receiver
// sp[2]: new.target (if used)
// sp[2/3]: number of arguments (smi-tagged)
// sp[2]: new.target
// sp[3]: number of arguments (smi-tagged)
Label loop, entry;
__ SmiTag(a3, a0);
__ jmp(&entry);
......@@ -701,9 +689,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
}
// Store offset of return address for deoptimizer.
// TODO(arv): Remove the "!use_new_target" before supporting optimization
// of functions that reference new.target
if (!is_api_function && !use_new_target) {
if (!is_api_function) {
masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset());
}
......@@ -718,8 +704,8 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// If the result is a smi, it is *not* an object in the ECMA sense.
// v0: result
// sp[0]: receiver (newly allocated object)
// sp[1]: new.target (if used)
// sp[1/2]: number of arguments (smi-tagged)
// sp[1]: new.target
// sp[2]: number of arguments (smi-tagged)
__ JumpIfSmi(v0, &use_receiver);
// If the type of the result (stored in its map) is less than
......@@ -737,10 +723,9 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ bind(&exit);
// v0: result
// sp[0]: receiver (newly allocated object)
// sp[1]: new.target (if used)
// sp[1/2]: number of arguments (smi-tagged)
int offset = (use_new_target ? 2 : 1) * kPointerSize;
__ lw(a1, MemOperand(sp, offset));
// sp[1]: new.target (original constructor)
// sp[2]: number of arguments (smi-tagged)
__ lw(a1, MemOperand(sp, 2 * kPointerSize));
// Leave construct frame.
}
......@@ -754,17 +739,12 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) {
Generate_JSConstructStubHelper(masm, false, false, FLAG_pretenuring_call_new);
Generate_JSConstructStubHelper(masm, false, FLAG_pretenuring_call_new);
}
void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) {
Generate_JSConstructStubHelper(masm, true, false, false);
}
void Builtins::Generate_JSConstructStubNewTarget(MacroAssembler* masm) {
Generate_JSConstructStubHelper(masm, false, true, FLAG_pretenuring_call_new);
Generate_JSConstructStubHelper(masm, true, false);
}
......
......@@ -322,7 +322,7 @@ static void Generate_Runtime_NewObject(MacroAssembler* masm,
Label* allocated) {
if (create_memento) {
// Get the cell or allocation site.
__ ld(a2, MemOperand(sp, 2 * kPointerSize));
__ ld(a2, MemOperand(sp, 3 * kPointerSize));
__ push(a2);
}
......@@ -347,7 +347,6 @@ static void Generate_Runtime_NewObject(MacroAssembler* masm,
static void Generate_JSConstructStubHelper(MacroAssembler* masm,
bool is_api_function,
bool use_new_target,
bool create_memento) {
// ----------- S t a t e -------------
// -- a0 : number of arguments
......@@ -381,11 +380,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// Preserve the incoming parameters on the stack.
__ SmiTag(a0);
if (use_new_target) {
__ Push(a0, a1, a3);
} else {
__ Push(a0, a1);
}
__ Push(a0, a1, a3);
Label rt_call, allocated, normal_new, count_incremented;
__ Branch(&normal_new, eq, a1, Operand(a3));
......@@ -640,8 +635,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ bind(&allocated);
if (create_memento) {
int offset = (use_new_target ? 3 : 2) * kPointerSize;
__ ld(a2, MemOperand(sp, offset));
__ ld(a2, MemOperand(sp, 3 * kPointerSize));
__ LoadRoot(t1, Heap::kUndefinedValueRootIndex);
__ Branch(&count_incremented, eq, a2, Operand(t1));
// a2 is an AllocationSite. We are creating a memento from it, so we
......@@ -655,19 +649,13 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
}
// Restore the parameters.
if (use_new_target) {
__ Pop(a3); // new.target
}
__ Pop(a3); // new.target
__ Pop(a1);
__ ld(a0, MemOperand(sp));
__ SmiUntag(a0);
if (use_new_target) {
__ Push(a3, t0, t0);
} else {
__ Push(t0, t0);
}
__ Push(a3, t0, t0);
// Set up pointer to last argument.
__ Daddu(a2, fp, Operand(StandardFrameConstants::kCallerSPOffset));
......@@ -679,8 +667,8 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// a3: number of arguments (smi-tagged)
// sp[0]: receiver
// sp[1]: receiver
// sp[2]: new.target (if used)
// sp[2/3]: number of arguments (smi-tagged)
// sp[2]: new.target
// sp[3]: number of arguments (smi-tagged)
Label loop, entry;
__ mov(a3, a0);
__ jmp(&entry);
......@@ -707,9 +695,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
}
// Store offset of return address for deoptimizer.
// TODO(arv): Remove the "!use_new_target" before supporting optimization
// of functions that reference new.target
if (!is_api_function && !use_new_target) {
if (!is_api_function) {
masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset());
}
......@@ -724,8 +710,8 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// If the result is a smi, it is *not* an object in the ECMA sense.
// v0: result
// sp[0]: receiver (newly allocated object)
// sp[1]: new.target (if used)
// sp[1/2]: number of arguments (smi-tagged)
// sp[1]: new.target
// sp[2]: number of arguments (smi-tagged)
__ JumpIfSmi(v0, &use_receiver);
// If the type of the result (stored in its map) is less than
......@@ -743,10 +729,9 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ bind(&exit);
// v0: result
// sp[0]: receiver (newly allocated object)
// sp[1]: new.target (if used)
// sp[1/2]: number of arguments (smi-tagged)
int offset = (use_new_target ? 2 : 1) * kPointerSize;
__ ld(a1, MemOperand(sp, offset));
// sp[1]: new.target (original constructor)
// sp[2]: number of arguments (smi-tagged)
__ ld(a1, MemOperand(sp, 2 * kPointerSize));
// Leave construct frame.
}
......@@ -760,17 +745,12 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) {
Generate_JSConstructStubHelper(masm, false, false, FLAG_pretenuring_call_new);
Generate_JSConstructStubHelper(masm, false, FLAG_pretenuring_call_new);
}
void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) {
Generate_JSConstructStubHelper(masm, true, false, false);
}
void Builtins::Generate_JSConstructStubNewTarget(MacroAssembler* masm) {
Generate_JSConstructStubHelper(masm, false, true, FLAG_pretenuring_call_new);
Generate_JSConstructStubHelper(masm, true, false);
}
......
......@@ -104,12 +104,12 @@ static void Generate_Runtime_NewObject(MacroAssembler* masm,
Register original_constructor,
Label* count_incremented,
Label* allocated) {
int offset = 0;
int offset = kPointerSize;
if (create_memento) {
// Get the cell or allocation site.
__ movp(rdi, Operand(rsp, kPointerSize * 2));
__ movp(rdi, Operand(rsp, kPointerSize * 3));
__ Push(rdi);
offset = kPointerSize;
offset += kPointerSize;
}
// Must restore rsi (context) and rdi (constructor) before calling runtime.
......@@ -136,7 +136,6 @@ static void Generate_Runtime_NewObject(MacroAssembler* masm,
static void Generate_JSConstructStubHelper(MacroAssembler* masm,
bool is_api_function,
bool use_new_target,
bool create_memento) {
// ----------- S t a t e -------------
// -- rax: number of arguments
......@@ -161,9 +160,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ Integer32ToSmi(rax, rax);
__ Push(rax);
__ Push(rdi);
if (use_new_target) {
__ Push(rdx);
}
__ Push(rdx);
Label rt_call, normal_new, allocated, count_incremented;
__ cmpp(rdx, rdi);
......@@ -390,8 +387,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ bind(&allocated);
if (create_memento) {
int offset = (use_new_target ? 3 : 2) * kPointerSize;
__ movp(rcx, Operand(rsp, offset));
__ movp(rcx, Operand(rsp, 3 * kPointerSize));
__ Cmp(rcx, masm->isolate()->factory()->undefined_value());
__ j(equal, &count_incremented);
// rcx is an AllocationSite. We are creating a memento from it, so we
......@@ -403,9 +399,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
}
// Restore the parameters.
if (use_new_target) {
__ Pop(rdx);
}
__ Pop(rdx);
__ Pop(rdi);
// Retrieve smi-tagged arguments count from the stack.
......@@ -414,9 +408,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// Push new.target onto the construct frame. This is stored just below the
// receiver on the stack.
if (use_new_target) {
__ Push(rdx);
}
__ Push(rdx);
// Push the allocated receiver to the stack. We need two copies
// because we may have to return the original one and the calling
......@@ -449,9 +441,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
}
// Store offset of return address for deoptimizer.
// TODO(arv): Remove the "!use_new_target" before supporting optimization
// of functions that reference new.target
if (!is_api_function && !use_new_target) {
if (!is_api_function) {
masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset());
}
......@@ -479,8 +469,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// Restore the arguments count and leave the construct frame. The arguments
// count is stored below the reciever and the new.target.
__ bind(&exit);
int offset = (use_new_target ? 2 : 1) * kPointerSize;
__ movp(rbx, Operand(rsp, offset));
__ movp(rbx, Operand(rsp, 2 * kPointerSize));
// Leave construct frame.
}
......@@ -497,17 +486,12 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) {
Generate_JSConstructStubHelper(masm, false, false, FLAG_pretenuring_call_new);
Generate_JSConstructStubHelper(masm, false, FLAG_pretenuring_call_new);
}
void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) {
Generate_JSConstructStubHelper(masm, true, false, false);
}
void Builtins::Generate_JSConstructStubNewTarget(MacroAssembler* masm) {
Generate_JSConstructStubHelper(masm, false, true, FLAG_pretenuring_call_new);
Generate_JSConstructStubHelper(masm, true, false);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment