[crankshaft] Pass new.target to direct function calls.

This changes all direct function calls in Crankshaft to pass undefined
via the register expected to hold the new.target value. Note that the
register is still ignored by all callees for now.

This is a preparatory CL to allows us passing new.target in a register
instead of via a side-channel through the construct stub frame.

R=bmeurer@chromium.org
BUG=v8:4544
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#32125}
This commit is contained in:
mstarzinger 2015-11-19 11:33:44 -08:00 committed by Commit bot
parent 89e859fb2b
commit e2bce9d392
8 changed files with 48 additions and 24 deletions

View File

@ -3415,7 +3415,8 @@ void LCodeGen::CallKnownFunction(Handle<JSFunction> function,
// Change context.
__ ldr(cp, FieldMemOperand(function_reg, JSFunction::kContextOffset));
// Always initialize r0 to the number of actual arguments.
// Always initialize new target and number of actual arguments.
__ LoadRoot(r3, Heap::kUndefinedValueRootIndex);
__ mov(r0, Operand(arity));
// Invoke function.
@ -3797,11 +3798,13 @@ void LCodeGen::DoCallJSFunction(LCallJSFunction* instr) {
DCHECK(ToRegister(instr->function()).is(r1));
DCHECK(ToRegister(instr->result()).is(r0));
__ mov(r0, Operand(instr->arity()));
// Change context.
__ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset));
// Always initialize new target and number of actual arguments.
__ LoadRoot(r3, Heap::kUndefinedValueRootIndex);
__ mov(r0, Operand(instr->arity()));
// Load the code entry address
__ ldr(ip, FieldMemOperand(r1, JSFunction::kCodeEntryOffset));
__ Call(ip);

View File

@ -1979,7 +1979,8 @@ void LCodeGen::CallKnownFunction(Handle<JSFunction> function,
// Change context.
__ Ldr(cp, FieldMemOperand(function_reg, JSFunction::kContextOffset));
// Always initialize x0 to the number of actual arguments.
// Always initialize new target and number of actual arguments.
__ LoadRoot(x3, Heap::kUndefinedValueRootIndex);
__ Mov(arity_reg, arity);
// Invoke function.
@ -2047,11 +2048,13 @@ void LCodeGen::DoCallJSFunction(LCallJSFunction* instr) {
DCHECK(instr->IsMarkedAsCall());
DCHECK(ToRegister(instr->function()).is(x1));
__ Mov(x0, Operand(instr->arity()));
// Change context.
__ Ldr(cp, FieldMemOperand(x1, JSFunction::kContextOffset));
// Always initialize new target and number of actual arguments.
__ LoadRoot(x3, Heap::kUndefinedValueRootIndex);
__ Mov(x0, instr->arity());
// Load the code entry address
__ Ldr(x10, FieldMemOperand(x1, JSFunction::kCodeEntryOffset));
__ Call(x10);

View File

@ -3291,7 +3291,8 @@ void LCodeGen::CallKnownFunction(Handle<JSFunction> function,
// Change context.
__ mov(esi, FieldOperand(function_reg, JSFunction::kContextOffset));
// Always initialize eax to the number of actual arguments.
// Always initialize new target and number of actual arguments.
__ mov(edx, factory()->undefined_value());
__ mov(eax, arity);
// Invoke function directly.
@ -3354,11 +3355,13 @@ void LCodeGen::DoCallJSFunction(LCallJSFunction* instr) {
DCHECK(ToRegister(instr->function()).is(edi));
DCHECK(ToRegister(instr->result()).is(eax));
__ mov(eax, instr->arity());
// Change context.
__ mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
// Always initialize new target and number of actual arguments.
__ mov(edx, factory()->undefined_value());
__ mov(eax, instr->arity());
bool is_self_call = false;
if (instr->hydrogen()->function()->IsConstant()) {
HConstant* fun_const = HConstant::cast(instr->hydrogen()->function());

View File

@ -3364,7 +3364,8 @@ void LCodeGen::CallKnownFunction(Handle<JSFunction> function,
// Change context.
__ lw(cp, FieldMemOperand(function_reg, JSFunction::kContextOffset));
// Always initialize a0 to the number of actual arguments.
// Always initialize new target and number of actual arguments.
__ LoadRoot(a3, Heap::kUndefinedValueRootIndex);
__ li(a0, Operand(arity));
// Invoke function.
@ -3772,11 +3773,13 @@ void LCodeGen::DoCallJSFunction(LCallJSFunction* instr) {
DCHECK(ToRegister(instr->function()).is(a1));
DCHECK(ToRegister(instr->result()).is(v0));
__ li(a0, Operand(instr->arity()));
// Change context.
__ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset));
// Always initialize new target and number of actual arguments.
__ LoadRoot(a3, Heap::kUndefinedValueRootIndex);
__ li(a0, Operand(instr->arity()));
// Load the code entry address
__ lw(at, FieldMemOperand(a1, JSFunction::kCodeEntryOffset));
__ Call(at);

View File

@ -3533,7 +3533,8 @@ void LCodeGen::CallKnownFunction(Handle<JSFunction> function,
// Change context.
__ ld(cp, FieldMemOperand(function_reg, JSFunction::kContextOffset));
// Always initialize a0 to the number of actual arguments.
// Always initialize new target and number of actual arguments.
__ LoadRoot(a3, Heap::kUndefinedValueRootIndex);
__ li(a0, Operand(arity));
// Invoke function.
@ -3960,11 +3961,13 @@ void LCodeGen::DoCallJSFunction(LCallJSFunction* instr) {
DCHECK(ToRegister(instr->function()).is(a1));
DCHECK(ToRegister(instr->result()).is(v0));
__ li(a0, Operand(instr->arity()));
// Change context.
__ ld(cp, FieldMemOperand(a1, JSFunction::kContextOffset));
// Always initialize new target and number of actual arguments.
__ LoadRoot(a3, Heap::kUndefinedValueRootIndex);
__ li(a0, Operand(instr->arity()));
// Load the code entry address
__ ld(at, FieldMemOperand(a1, JSFunction::kCodeEntryOffset));
__ Call(at);

View File

@ -3589,7 +3589,8 @@ void LCodeGen::CallKnownFunction(Handle<JSFunction> function,
// Change context.
__ LoadP(cp, FieldMemOperand(function_reg, JSFunction::kContextOffset));
// Always initialize r3 to the number of actual arguments.
// Always initialize new target and number of actual arguments.
__ LoadRoot(r6, Heap::kUndefinedValueRootIndex);
__ mov(r3, Operand(arity));
bool is_self_call = function.is_identical_to(info()->closure());
@ -4003,11 +4004,13 @@ void LCodeGen::DoCallJSFunction(LCallJSFunction* instr) {
DCHECK(ToRegister(instr->function()).is(r4));
DCHECK(ToRegister(instr->result()).is(r3));
__ mov(r3, Operand(instr->arity()));
// Change context.
__ LoadP(cp, FieldMemOperand(r4, JSFunction::kContextOffset));
// Always initialize new target and number of actual arguments.
__ LoadRoot(r6, Heap::kUndefinedValueRootIndex);
__ mov(r3, Operand(instr->arity()));
bool is_self_call = false;
if (instr->hydrogen()->function()->IsConstant()) {
HConstant* fun_const = HConstant::cast(instr->hydrogen()->function());

View File

@ -3368,7 +3368,8 @@ void LCodeGen::CallKnownFunction(Handle<JSFunction> function,
// Change context.
__ movp(rsi, FieldOperand(function_reg, JSFunction::kContextOffset));
// Always initialize rax to the number of actual arguments.
// Always initialize new target and number of actual arguments.
__ LoadRoot(rdx, Heap::kUndefinedValueRootIndex);
__ Set(rax, arity);
// Invoke function.
@ -3432,11 +3433,13 @@ void LCodeGen::DoCallJSFunction(LCallJSFunction* instr) {
DCHECK(ToRegister(instr->function()).is(rdi));
DCHECK(ToRegister(instr->result()).is(rax));
__ Set(rax, instr->arity());
// Change context.
__ movp(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
// Always initialize new target and number of actual arguments.
__ LoadRoot(rdx, Heap::kUndefinedValueRootIndex);
__ Set(rax, instr->arity());
LPointerMap* pointers = instr->pointer_map();
SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt);

View File

@ -3562,7 +3562,8 @@ void LCodeGen::CallKnownFunction(Handle<JSFunction> function,
// Change context.
__ mov(esi, FieldOperand(function_reg, JSFunction::kContextOffset));
// Always initialize eax to the number of actual arguments.
// Always initialize new target and number of actual arguments.
__ mov(edx, factory()->undefined_value());
__ mov(eax, arity);
// Invoke function directly.
@ -3625,11 +3626,13 @@ void LCodeGen::DoCallJSFunction(LCallJSFunction* instr) {
DCHECK(ToRegister(instr->function()).is(edi));
DCHECK(ToRegister(instr->result()).is(eax));
__ mov(eax, instr->arity());
// Change context.
__ mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
// Always initialize new target and number of actual arguments.
__ mov(edx, factory()->undefined_value());
__ mov(eax, instr->arity());
bool is_self_call = false;
if (instr->hydrogen()->function()->IsConstant()) {
HConstant* fun_const = HConstant::cast(instr->hydrogen()->function());