Commit 1266842b authored by zhengxing.li's avatar zhengxing.li Committed by Commit bot

X87: [turbofan] Switch passing of new.target to register.

  port 7c45b005 (r32203)

  original commit message:
  This passes the new.target value in a register instead of through a
  side-channel via the construct stub. Note that only TurboFan code uses
  the register value so far, but unoptimized code will be switched soon.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#32240}
parent 76fe8b01
......@@ -3503,7 +3503,8 @@ void LCodeGen::DoApplyArguments(LApplyArguments* instr) {
SafepointGenerator safepoint_generator(
this, pointers, Safepoint::kLazyDeopt);
ParameterCount actual(eax);
__ InvokeFunction(function, actual, CALL_FUNCTION, safepoint_generator);
__ InvokeFunction(function, no_reg, actual, CALL_FUNCTION,
safepoint_generator);
}
......@@ -4095,7 +4096,7 @@ void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) {
SafepointGenerator generator(
this, pointers, Safepoint::kLazyDeopt);
ParameterCount count(instr->arity());
__ InvokeFunction(edi, count, CALL_FUNCTION, generator);
__ InvokeFunction(edi, no_reg, count, CALL_FUNCTION, generator);
} else {
CallKnownFunction(known_function,
instr->hydrogen()->formal_parameter_count(),
......
......@@ -75,14 +75,21 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm,
static void CallRuntimePassFunction(
MacroAssembler* masm, Runtime::FunctionId function_id) {
// ----------- S t a t e -------------
// -- edx : new target (preserved for callee)
// -- edi : target function (preserved for callee)
// -----------------------------------
FrameScope scope(masm, StackFrame::INTERNAL);
// Push a copy of the function.
// Push a copy of the target function and the new target.
__ push(edi);
__ push(edx);
// Function is also the parameter to the runtime call.
__ push(edi);
__ CallRuntime(function_id, 1);
// Restore receiver.
// Restore target function and new target.
__ pop(edx);
__ pop(edi);
}
......@@ -332,8 +339,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ call(code, RelocInfo::CODE_TARGET);
} else {
ParameterCount actual(eax);
__ InvokeFunction(edi, actual, CALL_FUNCTION,
NullCallWrapper());
__ InvokeFunction(edi, edx, actual, CALL_FUNCTION, NullCallWrapper());
}
// Store offset of return address for deoptimizer.
......@@ -1528,8 +1534,8 @@ void Builtins::Generate_CallFunction(MacroAssembler* masm,
__ SmiUntag(ebx);
ParameterCount actual(eax);
ParameterCount expected(ebx);
__ InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), expected,
actual, JUMP_FUNCTION, NullCallWrapper());
__ InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), no_reg,
expected, actual, JUMP_FUNCTION, NullCallWrapper());
// The function is a "classConstructor", need to raise an exception.
__ bind(&class_constructor);
......
......@@ -1952,14 +1952,20 @@ void MacroAssembler::InvokePrologue(const ParameterCount& expected,
}
void MacroAssembler::InvokeCode(const Operand& code,
void MacroAssembler::InvokeCode(const Operand& code, Register new_target,
const ParameterCount& expected,
const ParameterCount& actual,
InvokeFlag flag,
const ParameterCount& actual, InvokeFlag flag,
const CallWrapper& call_wrapper) {
// You can't call a function without a valid frame.
DCHECK(flag == JUMP_FUNCTION || has_frame());
// Ensure new target is passed in the correct register. Otherwise clear the
// appropriate register in case new target is not given.
DCHECK_IMPLIES(new_target.is_valid(), new_target.is(edx));
if (!new_target.is_valid()) {
mov(edx, isolate()->factory()->undefined_value());
}
Label done;
bool definitely_mismatches = false;
InvokePrologue(expected, actual, &done, &definitely_mismatches, flag,
......@@ -1978,7 +1984,7 @@ void MacroAssembler::InvokeCode(const Operand& code,
}
void MacroAssembler::InvokeFunction(Register fun,
void MacroAssembler::InvokeFunction(Register fun, Register new_target,
const ParameterCount& actual,
InvokeFlag flag,
const CallWrapper& call_wrapper) {
......@@ -1986,13 +1992,13 @@ void MacroAssembler::InvokeFunction(Register fun,
DCHECK(flag == JUMP_FUNCTION || has_frame());
DCHECK(fun.is(edi));
mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
mov(ebx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
mov(ebx, FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset));
mov(ebx, FieldOperand(ebx, SharedFunctionInfo::kFormalParameterCountOffset));
SmiUntag(ebx);
ParameterCount expected(ebx);
InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset),
InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), new_target,
expected, actual, flag, call_wrapper);
}
......@@ -2008,8 +2014,8 @@ void MacroAssembler::InvokeFunction(Register fun,
DCHECK(fun.is(edi));
mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset),
expected, actual, flag, call_wrapper);
InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), no_reg, expected,
actual, flag, call_wrapper);
}
......@@ -2033,8 +2039,8 @@ void MacroAssembler::InvokeBuiltin(int native_context_index, InvokeFlag flag,
// parameter count to avoid emitting code to do the check.
ParameterCount expected(0);
GetBuiltinFunction(edi, native_context_index);
InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset),
expected, expected, flag, call_wrapper);
InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), no_reg, expected,
expected, flag, call_wrapper);
}
......
......@@ -332,20 +332,17 @@ class MacroAssembler: public Assembler {
const ParameterCount& actual,
InvokeFlag flag,
const CallWrapper& call_wrapper) {
InvokeCode(Operand(code), expected, actual, flag, call_wrapper);
InvokeCode(Operand(code), no_reg, expected, actual, flag, call_wrapper);
}
void InvokeCode(const Operand& code,
const ParameterCount& expected,
const ParameterCount& actual,
InvokeFlag flag,
const CallWrapper& call_wrapper);
void InvokeCode(const Operand& code, Register new_target,
const ParameterCount& expected, const ParameterCount& actual,
InvokeFlag flag, const CallWrapper& call_wrapper);
// Invoke the JavaScript function in the given register. Changes the
// current context to the context in the function before invoking.
void InvokeFunction(Register function,
const ParameterCount& actual,
InvokeFlag flag,
void InvokeFunction(Register function, Register new_target,
const ParameterCount& actual, InvokeFlag flag,
const CallWrapper& call_wrapper);
void InvokeFunction(Register function,
......@@ -959,12 +956,10 @@ class MacroAssembler: public Assembler {
// Helper functions for generating invokes.
void InvokePrologue(const ParameterCount& expected,
const ParameterCount& actual,
Label* done,
bool* definitely_mismatches,
InvokeFlag flag,
const ParameterCount& actual, Label* done,
bool* definitely_mismatches, InvokeFlag flag,
Label::Distance done_distance,
const CallWrapper& call_wrapper = NullCallWrapper());
const CallWrapper& call_wrapper);
void EnterExitFramePrologue();
void EnterExitFrameEpilogue(int argc, bool save_doubles);
......
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