OLD | NEW |
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 Handle<WasmInstanceObject> instance = |
| 41 frame_summary_.AsWasm().wasm_instance(); |
| 42 Handle<WasmDebugInfo> debug_info = |
| 43 WasmInstanceObject::GetOrCreateDebugInfo(instance); |
| 44 wasm_interpreted_frame_ = WasmDebugInfo::GetInterpretedFrame( |
| 45 debug_info, frame_->fp(), inlined_frame_index); |
| 46 DCHECK_NOT_NULL(wasm_interpreted_frame_); |
40 } | 47 } |
41 } | 48 } |
42 | 49 |
43 FrameInspector::~FrameInspector() { | 50 FrameInspector::~FrameInspector() { |
44 // Get rid of the calculated deoptimized frame if any. | 51 // Destructor needs to be defined in the .c file, because the types of the |
45 if (deoptimized_frame_ != nullptr) { | 52 // std::unique_ptr's are not known in the header. |
46 delete deoptimized_frame_; | |
47 } | |
48 } | 53 } |
49 | 54 |
50 int FrameInspector::GetParametersCount() { | 55 int FrameInspector::GetParametersCount() { |
51 return is_optimized_ ? deoptimized_frame_->parameters_count() | 56 if (is_optimized_) return deoptimized_frame_->parameters_count(); |
52 : frame_->ComputeParametersCount(); | 57 if (wasm_interpreted_frame_) |
| 58 return wasm_interpreted_frame_->GetParameterCount(); |
| 59 return frame_->ComputeParametersCount(); |
53 } | 60 } |
54 | 61 |
55 Handle<Script> FrameInspector::GetScript() { | 62 Handle<Script> FrameInspector::GetScript() { |
56 return Handle<Script>::cast(frame_summary_.script()); | 63 return Handle<Script>::cast(frame_summary_.script()); |
57 } | 64 } |
58 | 65 |
59 Handle<JSFunction> FrameInspector::GetFunction() { | 66 Handle<JSFunction> FrameInspector::GetFunction() { |
60 return frame_summary_.AsJavaScript().function(); | 67 return frame_summary_.AsJavaScript().function(); |
61 } | 68 } |
62 | 69 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |