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

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: fix 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
« no previous file with comments | « src/x64/macro-assembler-x64.h ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/x64/macro-assembler-x64.cc
diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc
index 8affaafd2bee53fbc0d6386533f13093f99bcbf9..1e957cd6d4f8f314f5d43e43f13ae70ef6101def 100644
--- a/src/x64/macro-assembler-x64.cc
+++ b/src/x64/macro-assembler-x64.cc
@@ -708,8 +708,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);
}
@@ -722,15 +722,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 }
@@ -4019,25 +4010,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);
}
@@ -4052,6 +4043,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);
@@ -4131,6 +4126,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);
« no previous file with comments | « 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