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

Unified Diff: src/debug/debug.cc

Issue 2649533002: [wasm] Implement stepping in wasm code (Closed)
Patch Set: Rebase to Yangs CL and address Ben's comments Created 3 years, 11 months 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/compiler/wasm-compiler.cc ('k') | src/frames.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/debug/debug.cc
diff --git a/src/debug/debug.cc b/src/debug/debug.cc
index 654951870b97fc470d7e9b88ff90519a5904e572..76b56dff2a7960889fe00248a110b97d711658d5 100644
--- a/src/debug/debug.cc
+++ b/src/debug/debug.cc
@@ -982,24 +982,36 @@ void Debug::PrepareStep(StepAction step_action) {
// If there is no JavaScript stack don't do anything.
if (frame_id == StackFrame::NO_ID) return;
- JavaScriptFrameIterator frames_it(isolate_, frame_id);
- JavaScriptFrame* frame = frames_it.frame();
+ StackTraceFrameIterator frames_it(isolate_, frame_id);
+ StandardFrame* frame = frames_it.frame();
feature_tracker()->Track(DebugFeatureTracker::kStepping);
thread_local_.last_step_action_ = step_action;
UpdateHookOnFunctionCall();
+ // Handle stepping in wasm functions via the wasm interpreter.
+ if (frame->is_wasm()) {
+ // If the top frame is compiled, we cannot step.
+ if (frame->is_wasm_compiled()) return;
+ WasmInterpreterEntryFrame* wasm_frame =
+ WasmInterpreterEntryFrame::cast(frame);
+ wasm_frame->wasm_instance()->debug_info()->PrepareStep(step_action);
+ return;
+ }
+
+ JavaScriptFrame* js_frame = JavaScriptFrame::cast(frame);
+
// If the function on the top frame is unresolved perform step out. This will
// be the case when calling unknown function and having the debugger stopped
// in an unhandled exception.
- if (!frame->function()->IsJSFunction()) {
+ if (!js_frame->function()->IsJSFunction()) {
// Step out: Find the calling JavaScript frame and flood it with
// breakpoints.
frames_it.Advance();
// Fill the function to return to with one-shot break points.
- JSFunction* function = frames_it.frame()->function();
- FloodWithOneShot(Handle<JSFunction>(function));
+ JSFunction* function = JavaScriptFrame::cast(frames_it.frame())->function();
+ FloodWithOneShot(handle(function, isolate_));
return;
}
@@ -1013,7 +1025,7 @@ void Debug::PrepareStep(StepAction step_action) {
}
Handle<DebugInfo> debug_info(shared->GetDebugInfo());
- BreakLocation location = BreakLocation::FromFrame(debug_info, frame);
+ BreakLocation location = BreakLocation::FromFrame(debug_info, js_frame);
// Any step at a return is a step-out.
if (location.IsReturn()) step_action = StepOut;
@@ -1034,18 +1046,27 @@ void Debug::PrepareStep(StepAction step_action) {
// Advance to caller frame.
frames_it.Advance();
// Skip native and extension functions on the stack.
- while (!frames_it.done() &&
- !frames_it.frame()->function()->shared()->IsSubjectToDebugging()) {
+ while (!frames_it.done()) {
titzer 2017/01/23 18:30:45 As per previous comment, mind cleaning up this loo
Clemens Hammacher 2017/01/23 18:47:27 Done, but I'm not sure if it improves readability.
+ if (!frames_it.frame()->is_java_script()) break;
+ JavaScriptFrame* js_frame = JavaScriptFrame::cast(frames_it.frame());
+ if (js_frame->function()->shared()->IsSubjectToDebugging()) break;
// Builtin functions are not subject to stepping, but need to be
// deoptimized to include checks for step-in at call sites.
- Deoptimizer::DeoptimizeFunction(frames_it.frame()->function());
+ Deoptimizer::DeoptimizeFunction(js_frame->function());
frames_it.Advance();
}
if (!frames_it.done()) {
- // Fill the caller function to return to with one-shot break points.
- Handle<JSFunction> caller_function(frames_it.frame()->function());
- FloodWithOneShot(caller_function);
- thread_local_.target_fp_ = frames_it.frame()->UnpaddedFP();
+ StandardFrame* caller_frame = frames_it.frame();
+ if (caller_frame->is_wasm()) {
+ // TODO(clemensh): Implement stepping out from JS to WASM.
+ } else {
+ JavaScriptFrame* js_caller_frame =
+ JavaScriptFrame::cast(caller_frame);
+ // Fill the caller function to return to with one-shot break points.
+ Handle<JSFunction> caller_function(js_caller_frame->function());
+ FloodWithOneShot(caller_function);
+ thread_local_.target_fp_ = frames_it.frame()->UnpaddedFP();
+ }
}
// Clear last position info. For stepping out it does not matter.
thread_local_.last_statement_position_ = kNoSourcePosition;
@@ -1056,9 +1077,11 @@ void Debug::PrepareStep(StepAction step_action) {
FloodWithOneShot(function);
break;
case StepIn:
+ // TODO(clemensh): Implement stepping from JS into WASM.
FloodWithOneShot(function);
break;
case StepFrame:
+ // TODO(clemensh): Implement stepping from JS into WASM or vice versa.
Yang 2017/01/23 14:26:20 StepFrame will be removed soonish. Once Framework
// No point in setting one-shot breaks at places where we are not about
// to leave the current frame.
FloodWithOneShot(function, CALLS_AND_RETURNS);
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | src/frames.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698