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

Side by Side Diff: src/debug/debug-frames.cc

Issue 2629823003: [wasm] Implement frame inspection for interpreted frames (Closed)
Patch Set: Rebase after Yangs revert ಠ益ಠ 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 unified diff | Download patch
« no previous file with comments | « src/debug/debug-frames.h ('k') | src/frames.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/debug/debug-frames.h" 5 #include "src/debug/debug-frames.h"
6 6
7 #include "src/frames-inl.h" 7 #include "src/frames-inl.h"
8 #include "src/wasm/wasm-interpreter.h" 8 #include "src/wasm/wasm-interpreter.h"
9 #include "src/wasm/wasm-objects.h" 9 #include "src/wasm/wasm-objects.h"
10 10
11 namespace v8 { 11 namespace v8 {
12 namespace internal { 12 namespace internal {
13 13
14 FrameInspector::FrameInspector(StandardFrame* frame, int inlined_frame_index, 14 FrameInspector::FrameInspector(StandardFrame* frame, int inlined_frame_index,
15 Isolate* isolate) 15 Isolate* isolate)
16 : frame_(frame), 16 : frame_(frame),
17 frame_summary_(FrameSummary::Get(frame, inlined_frame_index)), 17 frame_summary_(FrameSummary::Get(frame, inlined_frame_index)),
18 deoptimized_frame_(nullptr),
19 isolate_(isolate) { 18 isolate_(isolate) {
20 JavaScriptFrame* js_frame = 19 JavaScriptFrame* js_frame =
21 frame->is_java_script() ? javascript_frame() : nullptr; 20 frame->is_java_script() ? javascript_frame() : nullptr;
22 DCHECK(js_frame || frame->is_wasm()); 21 DCHECK(js_frame || frame->is_wasm());
23 has_adapted_arguments_ = js_frame && js_frame->has_adapted_arguments(); 22 has_adapted_arguments_ = js_frame && js_frame->has_adapted_arguments();
24 is_bottommost_ = inlined_frame_index == 0; 23 is_bottommost_ = inlined_frame_index == 0;
25 is_optimized_ = frame_->is_optimized(); 24 is_optimized_ = frame_->is_optimized();
26 is_interpreted_ = frame_->is_interpreted(); 25 is_interpreted_ = frame_->is_interpreted();
27 26
28 // Calculate the deoptimized frame. 27 // Calculate the deoptimized frame.
29 if (is_optimized_) { 28 if (is_optimized_) {
30 DCHECK(js_frame != nullptr); 29 DCHECK(js_frame != nullptr);
31 // TODO(turbofan): Revisit once we support deoptimization. 30 // TODO(turbofan): Revisit once we support deoptimization.
32 if (js_frame->LookupCode()->is_turbofanned() && 31 if (js_frame->LookupCode()->is_turbofanned() &&
33 js_frame->function()->shared()->asm_function()) { 32 js_frame->function()->shared()->asm_function()) {
34 is_optimized_ = false; 33 is_optimized_ = false;
35 return; 34 return;
36 } 35 }
37 36
38 deoptimized_frame_ = Deoptimizer::DebuggerInspectableFrame( 37 deoptimized_frame_.reset(Deoptimizer::DebuggerInspectableFrame(
39 js_frame, inlined_frame_index, isolate); 38 js_frame, inlined_frame_index, isolate));
39 } else if (frame_->is_wasm_interpreter_entry()) {
40 wasm_interpreted_frame_ =
41 frame_summary_.AsWasm()
42 .wasm_instance()
43 ->debug_info()
44 ->GetInterpretedFrame(frame_->fp(), inlined_frame_index);
45 DCHECK(wasm_interpreted_frame_);
40 } 46 }
41 } 47 }
42 48
43 FrameInspector::~FrameInspector() { 49 FrameInspector::~FrameInspector() {
44 // Get rid of the calculated deoptimized frame if any. 50 // Destructor needs to be defined in the .cc file, because it instantiates
45 if (deoptimized_frame_ != nullptr) { 51 // std::unique_ptr destructors but the types are not known in the header.
46 delete deoptimized_frame_;
47 }
48 } 52 }
49 53
50 int FrameInspector::GetParametersCount() { 54 int FrameInspector::GetParametersCount() {
51 return is_optimized_ ? deoptimized_frame_->parameters_count() 55 if (is_optimized_) return deoptimized_frame_->parameters_count();
52 : frame_->ComputeParametersCount(); 56 if (wasm_interpreted_frame_)
57 return wasm_interpreted_frame_->GetParameterCount();
58 return frame_->ComputeParametersCount();
53 } 59 }
54 60
55 Handle<Script> FrameInspector::GetScript() { 61 Handle<Script> FrameInspector::GetScript() {
56 return Handle<Script>::cast(frame_summary_.script()); 62 return Handle<Script>::cast(frame_summary_.script());
57 } 63 }
58 64
59 Handle<JSFunction> FrameInspector::GetFunction() { 65 Handle<JSFunction> FrameInspector::GetFunction() {
60 return frame_summary_.AsJavaScript().function(); 66 return frame_summary_.AsJavaScript().function();
61 } 67 }
62 68
63 Handle<Object> FrameInspector::GetParameter(int index) { 69 Handle<Object> FrameInspector::GetParameter(int index) {
64 return is_optimized_ ? deoptimized_frame_->GetParameter(index) 70 if (is_optimized_) return deoptimized_frame_->GetParameter(index);
65 : handle(frame_->GetParameter(index), isolate_); 71 // TODO(clemensh): Handle wasm_interpreted_frame_.
72 return handle(frame_->GetParameter(index), isolate_);
66 } 73 }
67 74
68 Handle<Object> FrameInspector::GetExpression(int index) { 75 Handle<Object> FrameInspector::GetExpression(int index) {
69 // TODO(turbofan): Revisit once we support deoptimization. 76 // TODO(turbofan): Revisit once we support deoptimization.
70 if (frame_->is_java_script() && 77 if (frame_->is_java_script() &&
71 javascript_frame()->LookupCode()->is_turbofanned() && 78 javascript_frame()->LookupCode()->is_turbofanned() &&
72 javascript_frame()->function()->shared()->asm_function()) { 79 javascript_frame()->function()->shared()->asm_function()) {
73 return isolate_->factory()->undefined_value(); 80 return isolate_->factory()->undefined_value();
74 } 81 }
75 return is_optimized_ ? deoptimized_frame_->GetExpression(index) 82 return is_optimized_ ? deoptimized_frame_->GetExpression(index)
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 if (!frames[i].is_subject_to_debugging()) continue; 218 if (!frames[i].is_subject_to_debugging()) continue;
212 if (++count == index) return i; 219 if (++count == index) return i;
213 } 220 }
214 } 221 }
215 return -1; 222 return -1;
216 } 223 }
217 224
218 225
219 } // namespace internal 226 } // namespace internal
220 } // namespace v8 227 } // namespace v8
OLDNEW
« no previous file with comments | « src/debug/debug-frames.h ('k') | src/frames.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698