Commit 69d946c6 authored by zhengxing.li's avatar zhengxing.li Committed by Commit bot

X87: [debugger] flood function for stepping before calling it.

  port 81e131ce (r32339)

  original commit message:

BUG=

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

Cr-Commit-Position: refs/heads/master@{#32357}
parent e2128e3c
......@@ -36,7 +36,7 @@ void NamedLoadHandlerCompiler::GenerateLoadViaGetter(
ParameterCount expected(expected_arguments);
__ LoadAccessor(edi, holder, accessor_index, ACCESSOR_GETTER);
__ InvokeFunction(edi, expected, actual, CALL_FUNCTION,
NullCallWrapper());
CheckDebugStepCallWrapper());
} else {
// If we generate a global code snippet for deoptimization only, remember
// the place to continue after deoptimization.
......@@ -267,7 +267,7 @@ void NamedStoreHandlerCompiler::GenerateStoreViaSetter(
ParameterCount expected(expected_arguments);
__ LoadAccessor(edi, holder, accessor_index, ACCESSOR_SETTER);
__ InvokeFunction(edi, expected, actual, CALL_FUNCTION,
NullCallWrapper());
CheckDebugStepCallWrapper());
} else {
// If we generate a global code snippet for deoptimization only, remember
// the place to continue after deoptimization.
......
......@@ -341,7 +341,8 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ call(code, RelocInfo::CODE_TARGET);
} else {
ParameterCount actual(eax);
__ InvokeFunction(edi, edx, actual, CALL_FUNCTION, NullCallWrapper());
__ InvokeFunction(edi, edx, actual, CALL_FUNCTION,
CheckDebugStepCallWrapper());
}
// Store offset of return address for deoptimizer.
......@@ -1545,9 +1546,8 @@ void Builtins::Generate_CallFunction(MacroAssembler* masm,
__ SmiUntag(ebx);
ParameterCount actual(eax);
ParameterCount expected(ebx);
__ InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), no_reg,
expected, actual, JUMP_FUNCTION, NullCallWrapper());
__ InvokeFunctionCode(edi, no_reg, expected, actual, JUMP_FUNCTION,
CheckDebugStepCallWrapper());
// The function is a "classConstructor", need to raise an exception.
__ bind(&class_constructor);
{
......
......@@ -1952,16 +1952,63 @@ void MacroAssembler::InvokePrologue(const ParameterCount& expected,
}
void MacroAssembler::InvokeCode(const Operand& code, Register new_target,
const ParameterCount& expected,
const ParameterCount& actual, InvokeFlag flag,
const CallWrapper& call_wrapper) {
void MacroAssembler::FloodFunctionIfStepping(Register fun, Register new_target,
const ParameterCount& expected,
const ParameterCount& actual) {
Label skip_flooding;
ExternalReference debug_step_action =
ExternalReference::debug_last_step_action_address(isolate());
cmpb(Operand::StaticVariable(debug_step_action), StepIn);
j(not_equal, &skip_flooding);
{
FrameScope frame(this,
has_frame() ? StackFrame::NONE : StackFrame::INTERNAL);
if (expected.is_reg()) {
SmiTag(expected.reg());
Push(expected.reg());
}
if (actual.is_reg()) {
SmiTag(actual.reg());
Push(actual.reg());
}
if (new_target.is_valid()) {
Push(new_target);
}
Push(fun);
Push(fun);
CallRuntime(Runtime::kDebugPrepareStepInIfStepping, 1);
Pop(fun);
if (new_target.is_valid()) {
Pop(new_target);
}
if (actual.is_reg()) {
Pop(actual.reg());
SmiUntag(actual.reg());
}
if (expected.is_reg()) {
Pop(expected.reg());
SmiUntag(expected.reg());
}
}
bind(&skip_flooding);
}
void MacroAssembler::InvokeFunctionCode(Register function, Register new_target,
const ParameterCount& expected,
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(function.is(edi));
DCHECK_IMPLIES(new_target.is_valid(), new_target.is(edx));
if (call_wrapper.NeedsDebugStepCheck()) {
FloodFunctionIfStepping(function, new_target, expected, actual);
}
// Clear the new.target register if not given.
if (!new_target.is_valid()) {
mov(edx, isolate()->factory()->undefined_value());
}
......@@ -1971,6 +2018,10 @@ void MacroAssembler::InvokeCode(const Operand& code, Register new_target,
InvokePrologue(expected, actual, &done, &definitely_mismatches, flag,
Label::kNear, call_wrapper);
if (!definitely_mismatches) {
// We call indirectly through the code field in the function to
// allow recompilation to take effect without changing any of the
// call sites.
Operand code = FieldOperand(function, JSFunction::kCodeEntryOffset);
if (flag == CALL_FUNCTION) {
call_wrapper.BeforeCall(CallSize(code));
call(code);
......@@ -1998,8 +2049,7 @@ void MacroAssembler::InvokeFunction(Register fun, Register new_target,
SmiUntag(ebx);
ParameterCount expected(ebx);
InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), new_target,
expected, actual, flag, call_wrapper);
InvokeFunctionCode(edi, new_target, expected, actual, flag, call_wrapper);
}
......@@ -2014,8 +2064,7 @@ void MacroAssembler::InvokeFunction(Register fun,
DCHECK(fun.is(edi));
mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), no_reg, expected,
actual, flag, call_wrapper);
InvokeFunctionCode(edi, no_reg, expected, actual, flag, call_wrapper);
}
......@@ -2039,8 +2088,7 @@ 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), no_reg, expected,
expected, flag, call_wrapper);
InvokeFunctionCode(edi, no_reg, expected, expected, flag, call_wrapper);
}
......@@ -2053,16 +2101,6 @@ void MacroAssembler::GetBuiltinFunction(Register target,
}
void MacroAssembler::GetBuiltinEntry(Register target,
int native_context_index) {
DCHECK(!target.is(edi));
// Load the JavaScript builtin function from the builtins object.
GetBuiltinFunction(edi, native_context_index);
// Load the code entry point from the function into the target register.
mov(target, FieldOperand(edi, JSFunction::kCodeEntryOffset));
}
void MacroAssembler::LoadContext(Register dst, int context_chain_length) {
if (context_chain_length > 0) {
// Move up the chain of contexts to the context containing the slot.
......
This diff is collapsed.
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