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

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

Issue 2069823003: [wasm] Enable wasm frame inspection for debugging (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@split-wasm-debug
Patch Set: Add two DCHECKs Created 4 years, 6 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/debug/debug-scopes.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 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
11 11
12 FrameInspector::FrameInspector(JavaScriptFrame* frame, 12 FrameInspector::FrameInspector(StandardFrame* frame, int inlined_jsframe_index,
13 int inlined_jsframe_index, Isolate* isolate) 13 Isolate* isolate)
14 : frame_(frame), deoptimized_frame_(NULL), isolate_(isolate) { 14 : frame_(frame), deoptimized_frame_(NULL), isolate_(isolate) {
15 has_adapted_arguments_ = frame_->has_adapted_arguments(); 15 JavaScriptFrame* js_frame =
16 frame->is_java_script() ? javascript_frame() : nullptr;
17 DCHECK(js_frame || frame->is_wasm());
18 has_adapted_arguments_ = js_frame && js_frame->has_adapted_arguments();
16 is_bottommost_ = inlined_jsframe_index == 0; 19 is_bottommost_ = inlined_jsframe_index == 0;
17 is_optimized_ = frame_->is_optimized(); 20 is_optimized_ = frame_->is_optimized();
18 is_interpreted_ = frame_->is_interpreted(); 21 is_interpreted_ = frame_->is_interpreted();
19 // Calculate the deoptimized frame. 22 // Calculate the deoptimized frame.
20 if (frame->is_optimized()) { 23 if (frame->is_optimized()) {
24 DCHECK(js_frame != nullptr);
21 // TODO(turbofan): Revisit once we support deoptimization. 25 // TODO(turbofan): Revisit once we support deoptimization.
22 if (frame->LookupCode()->is_turbofanned() && 26 if (js_frame->LookupCode()->is_turbofanned() &&
23 frame->function()->shared()->asm_function() && 27 js_frame->function()->shared()->asm_function() &&
24 !FLAG_turbo_asm_deoptimization) { 28 !FLAG_turbo_asm_deoptimization) {
25 is_optimized_ = false; 29 is_optimized_ = false;
26 return; 30 return;
27 } 31 }
28 32
29 deoptimized_frame_ = Deoptimizer::DebuggerInspectableFrame( 33 deoptimized_frame_ = Deoptimizer::DebuggerInspectableFrame(
30 frame, inlined_jsframe_index, isolate); 34 js_frame, inlined_jsframe_index, isolate);
31 } 35 }
32 } 36 }
33 37
34 38
35 FrameInspector::~FrameInspector() { 39 FrameInspector::~FrameInspector() {
36 // Get rid of the calculated deoptimized frame if any. 40 // Get rid of the calculated deoptimized frame if any.
37 if (deoptimized_frame_ != NULL) { 41 if (deoptimized_frame_ != NULL) {
38 Deoptimizer::DeleteDebuggerInspectableFrame(deoptimized_frame_, isolate_); 42 Deoptimizer::DeleteDebuggerInspectableFrame(deoptimized_frame_, isolate_);
39 } 43 }
40 } 44 }
41 45
42 46
43 int FrameInspector::GetParametersCount() { 47 int FrameInspector::GetParametersCount() {
44 return is_optimized_ ? deoptimized_frame_->parameters_count() 48 return is_optimized_ ? deoptimized_frame_->parameters_count()
45 : frame_->ComputeParametersCount(); 49 : frame_->ComputeParametersCount();
46 } 50 }
47 51
48 Handle<Object> FrameInspector::GetFunction() { 52 Handle<Script> FrameInspector::GetScript() {
53 Object* script = is_optimized_
54 ? deoptimized_frame_->GetFunction()->shared()->script()
55 : frame_->script();
56 return handle(Script::cast(script), isolate_);
57 }
58
59 Handle<JSFunction> FrameInspector::GetFunction() {
60 DCHECK(!frame_->is_wasm());
49 return is_optimized_ ? deoptimized_frame_->GetFunction() 61 return is_optimized_ ? deoptimized_frame_->GetFunction()
50 : handle(frame_->function(), isolate_); 62 : handle(javascript_frame()->function(), isolate_);
51 } 63 }
52 64
53 Handle<Object> FrameInspector::GetParameter(int index) { 65 Handle<Object> FrameInspector::GetParameter(int index) {
54 return is_optimized_ ? deoptimized_frame_->GetParameter(index) 66 return is_optimized_ ? deoptimized_frame_->GetParameter(index)
55 : handle(frame_->GetParameter(index), isolate_); 67 : handle(frame_->GetParameter(index), isolate_);
56 } 68 }
57 69
58 Handle<Object> FrameInspector::GetExpression(int index) { 70 Handle<Object> FrameInspector::GetExpression(int index) {
59 // TODO(turbofan): Revisit once we support deoptimization. 71 // TODO(turbofan): Revisit once we support deoptimization.
60 if (frame_->LookupCode()->is_turbofanned() && 72 if (frame_->is_java_script() &&
61 frame_->function()->shared()->asm_function() && 73 javascript_frame()->LookupCode()->is_turbofanned() &&
74 javascript_frame()->function()->shared()->asm_function() &&
62 !FLAG_turbo_asm_deoptimization) { 75 !FLAG_turbo_asm_deoptimization) {
63 return isolate_->factory()->undefined_value(); 76 return isolate_->factory()->undefined_value();
64 } 77 }
65 return is_optimized_ ? deoptimized_frame_->GetExpression(index) 78 return is_optimized_ ? deoptimized_frame_->GetExpression(index)
66 : handle(frame_->GetExpression(index), isolate_); 79 : handle(frame_->GetExpression(index), isolate_);
67 } 80 }
68 81
69 82
70 int FrameInspector::GetSourcePosition() { 83 int FrameInspector::GetSourcePosition() {
71 if (is_optimized_) { 84 if (is_optimized_) {
(...skipping 17 matching lines...) Expand all
89 } 102 }
90 103
91 Handle<Object> FrameInspector::GetContext() { 104 Handle<Object> FrameInspector::GetContext() {
92 return is_optimized_ ? deoptimized_frame_->GetContext() 105 return is_optimized_ ? deoptimized_frame_->GetContext()
93 : handle(frame_->context(), isolate_); 106 : handle(frame_->context(), isolate_);
94 } 107 }
95 108
96 109
97 // To inspect all the provided arguments the frame might need to be 110 // To inspect all the provided arguments the frame might need to be
98 // replaced with the arguments frame. 111 // replaced with the arguments frame.
99 void FrameInspector::SetArgumentsFrame(JavaScriptFrame* frame) { 112 void FrameInspector::SetArgumentsFrame(StandardFrame* frame) {
100 DCHECK(has_adapted_arguments_); 113 DCHECK(has_adapted_arguments_);
114 DCHECK(frame->is_arguments_adaptor());
101 frame_ = frame; 115 frame_ = frame;
102 is_optimized_ = frame_->is_optimized(); 116 is_optimized_ = frame_->is_optimized();
103 is_interpreted_ = frame_->is_interpreted(); 117 is_interpreted_ = frame_->is_interpreted();
104 DCHECK(!is_optimized_); 118 DCHECK(!is_optimized_);
105 } 119 }
106 120
107 121
108 // Create a plain JSObject which materializes the local scope for the specified 122 // Create a plain JSObject which materializes the local scope for the specified
109 // frame. 123 // frame.
110 void FrameInspector::MaterializeStackLocals(Handle<JSObject> target, 124 void FrameInspector::MaterializeStackLocals(Handle<JSObject> target,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 void FrameInspector::MaterializeStackLocals(Handle<JSObject> target, 163 void FrameInspector::MaterializeStackLocals(Handle<JSObject> target,
150 Handle<JSFunction> function) { 164 Handle<JSFunction> function) {
151 Handle<SharedFunctionInfo> shared(function->shared()); 165 Handle<SharedFunctionInfo> shared(function->shared());
152 Handle<ScopeInfo> scope_info(shared->scope_info()); 166 Handle<ScopeInfo> scope_info(shared->scope_info());
153 MaterializeStackLocals(target, scope_info); 167 MaterializeStackLocals(target, scope_info);
154 } 168 }
155 169
156 170
157 void FrameInspector::UpdateStackLocalsFromMaterializedObject( 171 void FrameInspector::UpdateStackLocalsFromMaterializedObject(
158 Handle<JSObject> target, Handle<ScopeInfo> scope_info) { 172 Handle<JSObject> target, Handle<ScopeInfo> scope_info) {
159 if (is_optimized_) { 173 // Optimized frames and wasm frames are not supported. Simply give up.
160 // Optimized frames are not supported. Simply give up. 174 if (is_optimized_ || frame_->is_wasm()) return;
161 return;
162 }
163 175
164 HandleScope scope(isolate_); 176 HandleScope scope(isolate_);
165 177
166 // Parameters. 178 // Parameters.
167 for (int i = 0; i < scope_info->ParameterCount(); ++i) { 179 for (int i = 0; i < scope_info->ParameterCount(); ++i) {
168 // Shadowed parameters were not materialized. 180 // Shadowed parameters were not materialized.
169 Handle<String> name(scope_info->ParameterName(i)); 181 Handle<String> name(scope_info->ParameterName(i));
170 if (ScopeInfo::VariableIsSynthetic(*name)) continue; 182 if (ScopeInfo::VariableIsSynthetic(*name)) continue;
171 if (ParameterIsShadowedByContextLocal(scope_info, name)) continue; 183 if (ParameterIsShadowedByContextLocal(scope_info, name)) continue;
172 184
173 DCHECK(!frame_->GetParameter(i)->IsTheHole(isolate_)); 185 DCHECK(!javascript_frame()->GetParameter(i)->IsTheHole(isolate_));
174 Handle<Object> value = 186 Handle<Object> value =
175 Object::GetPropertyOrElement(target, name).ToHandleChecked(); 187 Object::GetPropertyOrElement(target, name).ToHandleChecked();
176 frame_->SetParameterValue(i, *value); 188 javascript_frame()->SetParameterValue(i, *value);
177 } 189 }
178 190
179 // Stack locals. 191 // Stack locals.
180 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { 192 for (int i = 0; i < scope_info->StackLocalCount(); ++i) {
181 Handle<String> name(scope_info->StackLocalName(i)); 193 Handle<String> name(scope_info->StackLocalName(i));
182 if (ScopeInfo::VariableIsSynthetic(*name)) continue; 194 if (ScopeInfo::VariableIsSynthetic(*name)) continue;
183 int index = scope_info->StackLocalIndex(i); 195 int index = scope_info->StackLocalIndex(i);
184 if (frame_->GetExpression(index)->IsTheHole(isolate_)) continue; 196 if (frame_->GetExpression(index)->IsTheHole(isolate_)) continue;
185 Handle<Object> value = 197 Handle<Object> value =
186 Object::GetPropertyOrElement(target, name).ToHandleChecked(); 198 Object::GetPropertyOrElement(target, name).ToHandleChecked();
187 frame_->SetExpression(index, *value); 199 frame_->SetExpression(index, *value);
188 } 200 }
189 } 201 }
190 202
191 203
192 bool FrameInspector::ParameterIsShadowedByContextLocal( 204 bool FrameInspector::ParameterIsShadowedByContextLocal(
193 Handle<ScopeInfo> info, Handle<String> parameter_name) { 205 Handle<ScopeInfo> info, Handle<String> parameter_name) {
194 VariableMode mode; 206 VariableMode mode;
195 InitializationFlag init_flag; 207 InitializationFlag init_flag;
196 MaybeAssignedFlag maybe_assigned_flag; 208 MaybeAssignedFlag maybe_assigned_flag;
197 return ScopeInfo::ContextSlotIndex(info, parameter_name, &mode, &init_flag, 209 return ScopeInfo::ContextSlotIndex(info, parameter_name, &mode, &init_flag,
198 &maybe_assigned_flag) != -1; 210 &maybe_assigned_flag) != -1;
199 } 211 }
200 212
201 213 SaveContext* DebugFrameHelper::FindSavedContextForFrame(Isolate* isolate,
202 SaveContext* DebugFrameHelper::FindSavedContextForFrame( 214 StandardFrame* frame) {
203 Isolate* isolate, JavaScriptFrame* frame) {
204 SaveContext* save = isolate->save_context(); 215 SaveContext* save = isolate->save_context();
205 while (save != NULL && !save->IsBelowFrame(frame)) { 216 while (save != NULL && !save->IsBelowFrame(frame)) {
206 save = save->prev(); 217 save = save->prev();
207 } 218 }
208 DCHECK(save != NULL); 219 DCHECK(save != NULL);
209 return save; 220 return save;
210 } 221 }
211 222
212 223 int DebugFrameHelper::FindIndexedNonNativeFrame(StackTraceFrameIterator* it,
213 int DebugFrameHelper::FindIndexedNonNativeFrame(JavaScriptFrameIterator* it,
214 int index) { 224 int index) {
215 int count = -1; 225 int count = -1;
216 for (; !it->done(); it->Advance()) { 226 for (; !it->done(); it->Advance()) {
227 if (it->is_wasm()) {
228 if (++count == index) return 0;
229 continue;
230 }
217 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); 231 List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
218 it->frame()->Summarize(&frames); 232 it->javascript_frame()->Summarize(&frames);
219 for (int i = frames.length() - 1; i >= 0; i--) { 233 for (int i = frames.length() - 1; i >= 0; i--) {
220 // Omit functions from native and extension scripts. 234 // Omit functions from native and extension scripts.
221 if (!frames[i].function()->shared()->IsSubjectToDebugging()) continue; 235 if (!frames[i].function()->shared()->IsSubjectToDebugging()) continue;
222 if (++count == index) return i; 236 if (++count == index) return i;
223 } 237 }
224 } 238 }
225 return -1; 239 return -1;
226 } 240 }
227 241
228 242
229 } // namespace internal 243 } // namespace internal
230 } // namespace v8 244 } // namespace v8
OLDNEW
« no previous file with comments | « src/debug/debug-frames.h ('k') | src/debug/debug-scopes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698