Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(770)

Unified Diff: src/x64/macro-assembler-x64.cc

Issue 1463803002: [debugger] flood function for stepping before calling it. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase, ports, deoptimize builtins Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/x64/macro-assembler-x64.cc
diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc
index fbbc0688e1ce2453a35c66d797d221059f867d6f..1053a3f92e608fed933b45db40da14c0ec10ec27 100644
--- a/src/x64/macro-assembler-x64.cc
+++ b/src/x64/macro-assembler-x64.cc
@@ -707,8 +707,8 @@ void MacroAssembler::InvokeBuiltin(int native_context_index, InvokeFlag flag,
// arguments match the expected number of arguments. Fake a
// parameter count to avoid emitting code to do the check.
ParameterCount expected(0);
- GetBuiltinEntry(r8, native_context_index);
- InvokeCode(r8, no_reg, expected, expected, flag, call_wrapper);
+ GetBuiltinFunction(rdi, native_context_index);
+ InvokeFunctionCode(rdi, no_reg, expected, expected, flag, call_wrapper);
}
@@ -721,15 +721,6 @@ void MacroAssembler::GetBuiltinFunction(Register target,
}
-void MacroAssembler::GetBuiltinEntry(Register target,
- int native_context_index) {
- DCHECK(!target.is(rdi));
- // Load the JavaScript builtin function from the builtins object.
- GetBuiltinFunction(rdi, native_context_index);
- movp(target, FieldOperand(rdi, JSFunction::kCodeEntryOffset));
-}
-
-
#define REG(Name) \
{ Register::kCode_##Name }
@@ -4007,25 +3998,25 @@ void MacroAssembler::InvokeFunction(Register function,
const CallWrapper& call_wrapper) {
DCHECK(function.is(rdi));
movp(rsi, FieldOperand(function, JSFunction::kContextOffset));
- // Advances r8 to the end of the Code object header, to the start of
- // the executable code.
- movp(r8, FieldOperand(rdi, JSFunction::kCodeEntryOffset));
- InvokeCode(r8, new_target, expected, actual, flag, call_wrapper);
+ InvokeFunctionCode(rdi, new_target, expected, actual, flag, call_wrapper);
}
-void MacroAssembler::InvokeCode(Register code,
- Register new_target,
- const ParameterCount& expected,
- const ParameterCount& actual,
- InvokeFlag flag,
- const CallWrapper& call_wrapper) {
+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(rdi));
DCHECK_IMPLIES(new_target.is_valid(), new_target.is(rdx));
+
+ if (call_wrapper.NeedsDebugStepCheck()) {
+ FloodFunctionIfStepping(function, new_target, expected, actual);
+ }
+
+ // Clear the new.target register if not given.
if (!new_target.is_valid()) {
LoadRoot(rdx, Heap::kUndefinedValueRootIndex);
}
@@ -4040,6 +4031,10 @@ void MacroAssembler::InvokeCode(Register code,
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);
@@ -4119,6 +4114,49 @@ void MacroAssembler::InvokePrologue(const ParameterCount& expected,
}
+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());
+ Operand debug_step_action_operand = ExternalOperand(debug_step_action);
+ cmpb(debug_step_action_operand, Immediate(StepIn));
+ j(not_equal, &skip_flooding);
+ {
+ FrameScope frame(this,
+ has_frame() ? StackFrame::NONE : StackFrame::INTERNAL);
+ if (expected.is_reg()) {
+ Integer32ToSmi(expected.reg(), expected.reg());
+ Push(expected.reg());
+ }
+ if (actual.is_reg()) {
+ Integer32ToSmi(actual.reg(), 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());
+ SmiToInteger64(actual.reg(), actual.reg());
+ }
+ if (expected.is_reg()) {
+ Pop(expected.reg());
+ SmiToInteger64(expected.reg(), expected.reg());
+ }
+ }
+ bind(&skip_flooding);
+}
+
+
void MacroAssembler::StubPrologue() {
pushq(rbp); // Caller's frame pointer.
movp(rbp, rsp);
« src/js/macros.py ('K') | « src/x64/macro-assembler-x64.h ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698