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

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

Issue 2619353006: Refactor FrameSummary for JS and Wasm frames (Closed)
Patch Set: Address comment 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.h » ('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"
9 #include "src/wasm/wasm-objects.h"
8 10
9 namespace v8 { 11 namespace v8 {
10 namespace internal { 12 namespace internal {
11 13
12 FrameInspector::FrameInspector(StandardFrame* frame, int inlined_jsframe_index, 14 FrameInspector::FrameInspector(StandardFrame* frame, int inlined_frame_index,
13 Isolate* isolate) 15 Isolate* isolate)
14 : frame_(frame), deoptimized_frame_(NULL), isolate_(isolate) { 16 : frame_(frame),
17 frame_summary_(FrameSummary::Get(frame, inlined_frame_index)),
18 deoptimized_frame_(nullptr),
19 isolate_(isolate) {
15 JavaScriptFrame* js_frame = 20 JavaScriptFrame* js_frame =
16 frame->is_java_script() ? javascript_frame() : nullptr; 21 frame->is_java_script() ? javascript_frame() : nullptr;
17 DCHECK(js_frame || frame->is_wasm()); 22 DCHECK(js_frame || frame->is_wasm());
18 has_adapted_arguments_ = js_frame && js_frame->has_adapted_arguments(); 23 has_adapted_arguments_ = js_frame && js_frame->has_adapted_arguments();
19 is_bottommost_ = inlined_jsframe_index == 0; 24 is_bottommost_ = inlined_frame_index == 0;
20 is_optimized_ = frame_->is_optimized(); 25 is_optimized_ = frame_->is_optimized();
21 is_interpreted_ = frame_->is_interpreted(); 26 is_interpreted_ = frame_->is_interpreted();
27
22 // Calculate the deoptimized frame. 28 // Calculate the deoptimized frame.
23 if (frame->is_optimized()) { 29 if (is_optimized_) {
24 DCHECK(js_frame != nullptr); 30 DCHECK(js_frame != nullptr);
25 // TODO(turbofan): Revisit once we support deoptimization. 31 // TODO(turbofan): Revisit once we support deoptimization.
26 if (js_frame->LookupCode()->is_turbofanned() && 32 if (js_frame->LookupCode()->is_turbofanned() &&
27 js_frame->function()->shared()->asm_function()) { 33 js_frame->function()->shared()->asm_function()) {
28 is_optimized_ = false; 34 is_optimized_ = false;
29 return; 35 return;
30 } 36 }
31 37
32 deoptimized_frame_ = Deoptimizer::DebuggerInspectableFrame( 38 deoptimized_frame_ = Deoptimizer::DebuggerInspectableFrame(
33 js_frame, inlined_jsframe_index, isolate); 39 js_frame, inlined_frame_index, isolate);
34 } 40 }
35 } 41 }
36 42
37 FrameInspector::~FrameInspector() { 43 FrameInspector::~FrameInspector() {
38 // Get rid of the calculated deoptimized frame if any. 44 // Get rid of the calculated deoptimized frame if any.
39 if (deoptimized_frame_ != nullptr) { 45 if (deoptimized_frame_ != nullptr) {
40 delete deoptimized_frame_; 46 delete deoptimized_frame_;
41 } 47 }
42 } 48 }
43 49
44 int FrameInspector::GetParametersCount() { 50 int FrameInspector::GetParametersCount() {
45 return is_optimized_ ? deoptimized_frame_->parameters_count() 51 return is_optimized_ ? deoptimized_frame_->parameters_count()
46 : frame_->ComputeParametersCount(); 52 : frame_->ComputeParametersCount();
47 } 53 }
48 54
49 Handle<Script> FrameInspector::GetScript() { 55 Handle<Script> FrameInspector::GetScript() {
50 Object* script = is_optimized_ 56 return Handle<Script>::cast(frame_summary_.script());
51 ? deoptimized_frame_->GetFunction()->shared()->script()
52 : frame_->script();
53 return handle(Script::cast(script), isolate_);
54 } 57 }
55 58
56 Handle<JSFunction> FrameInspector::GetFunction() { 59 Handle<JSFunction> FrameInspector::GetFunction() {
57 DCHECK(!frame_->is_wasm()); 60 return frame_summary_.AsJavaScript().function();
58 return is_optimized_ ? deoptimized_frame_->GetFunction()
59 : handle(javascript_frame()->function(), isolate_);
60 } 61 }
61 62
62 Handle<Object> FrameInspector::GetParameter(int index) { 63 Handle<Object> FrameInspector::GetParameter(int index) {
63 return is_optimized_ ? deoptimized_frame_->GetParameter(index) 64 return is_optimized_ ? deoptimized_frame_->GetParameter(index)
64 : handle(frame_->GetParameter(index), isolate_); 65 : handle(frame_->GetParameter(index), isolate_);
65 } 66 }
66 67
67 Handle<Object> FrameInspector::GetExpression(int index) { 68 Handle<Object> FrameInspector::GetExpression(int index) {
68 // TODO(turbofan): Revisit once we support deoptimization. 69 // TODO(turbofan): Revisit once we support deoptimization.
69 if (frame_->is_java_script() && 70 if (frame_->is_java_script() &&
70 javascript_frame()->LookupCode()->is_turbofanned() && 71 javascript_frame()->LookupCode()->is_turbofanned() &&
71 javascript_frame()->function()->shared()->asm_function()) { 72 javascript_frame()->function()->shared()->asm_function()) {
72 return isolate_->factory()->undefined_value(); 73 return isolate_->factory()->undefined_value();
73 } 74 }
74 return is_optimized_ ? deoptimized_frame_->GetExpression(index) 75 return is_optimized_ ? deoptimized_frame_->GetExpression(index)
75 : handle(frame_->GetExpression(index), isolate_); 76 : handle(frame_->GetExpression(index), isolate_);
76 } 77 }
77 78
78 int FrameInspector::GetSourcePosition() { 79 int FrameInspector::GetSourcePosition() {
79 return is_optimized_ ? deoptimized_frame_->GetSourcePosition() 80 return frame_summary_.SourcePosition();
80 : frame_->position();
81 } 81 }
82 82
83 bool FrameInspector::IsConstructor() { 83 bool FrameInspector::IsConstructor() { return frame_summary_.is_constructor(); }
84 return is_optimized_ && !is_bottommost_
85 ? deoptimized_frame_->HasConstructStub()
86 : frame_->IsConstructor();
87 }
88 84
89 Handle<Object> FrameInspector::GetContext() { 85 Handle<Object> FrameInspector::GetContext() {
90 return is_optimized_ ? deoptimized_frame_->GetContext() 86 return is_optimized_ ? deoptimized_frame_->GetContext()
91 : handle(frame_->context(), isolate_); 87 : handle(frame_->context(), isolate_);
92 } 88 }
93 89
94
95 // To inspect all the provided arguments the frame might need to be 90 // To inspect all the provided arguments the frame might need to be
96 // replaced with the arguments frame. 91 // replaced with the arguments frame.
97 void FrameInspector::SetArgumentsFrame(StandardFrame* frame) { 92 void FrameInspector::SetArgumentsFrame(StandardFrame* frame) {
98 DCHECK(has_adapted_arguments_); 93 DCHECK(has_adapted_arguments_);
99 DCHECK(frame->is_arguments_adaptor()); 94 DCHECK(frame->is_arguments_adaptor());
100 frame_ = frame; 95 frame_ = frame;
101 is_optimized_ = frame_->is_optimized(); 96 is_optimized_ = frame_->is_optimized();
102 is_interpreted_ = frame_->is_interpreted(); 97 is_interpreted_ = frame_->is_interpreted();
103 DCHECK(!is_optimized_); 98 DCHECK(!is_optimized_);
104 } 99 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 save = save->prev(); 197 save = save->prev();
203 } 198 }
204 DCHECK(save != NULL); 199 DCHECK(save != NULL);
205 return save; 200 return save;
206 } 201 }
207 202
208 int DebugFrameHelper::FindIndexedNonNativeFrame(StackTraceFrameIterator* it, 203 int DebugFrameHelper::FindIndexedNonNativeFrame(StackTraceFrameIterator* it,
209 int index) { 204 int index) {
210 int count = -1; 205 int count = -1;
211 for (; !it->done(); it->Advance()) { 206 for (; !it->done(); it->Advance()) {
212 if (it->is_wasm()) {
213 if (++count == index) return 0;
214 continue;
215 }
216 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); 207 List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
217 it->javascript_frame()->Summarize(&frames); 208 it->frame()->Summarize(&frames);
218 for (int i = frames.length() - 1; i >= 0; i--) { 209 for (int i = frames.length() - 1; i >= 0; i--) {
219 // Omit functions from native and extension scripts. 210 // Omit functions from native and extension scripts.
220 if (!frames[i].function()->shared()->IsSubjectToDebugging()) continue; 211 if (!frames[i].is_subject_to_debugging()) continue;
221 if (++count == index) return i; 212 if (++count == index) return i;
222 } 213 }
223 } 214 }
224 return -1; 215 return -1;
225 } 216 }
226 217
227 218
228 } // namespace internal 219 } // namespace internal
229 } // namespace v8 220 } // namespace v8
OLDNEW
« no previous file with comments | « src/debug/debug-frames.h ('k') | src/frames.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698