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

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

Issue 1703453002: [interpreter, debugger] support debug breaks via bytecode array copy (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressed last comment Created 4 years, 10 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
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(JavaScriptFrame* frame,
13 int inlined_jsframe_index, Isolate* isolate) 13 int inlined_jsframe_index, 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 has_adapted_arguments_ = frame_->has_adapted_arguments();
16 is_bottommost_ = inlined_jsframe_index == 0; 16 is_bottommost_ = inlined_jsframe_index == 0;
17 is_optimized_ = frame_->is_optimized(); 17 is_optimized_ = frame_->is_optimized();
18 is_interpreted_ = frame_->is_interpreted();
18 // Calculate the deoptimized frame. 19 // Calculate the deoptimized frame.
19 if (frame->is_optimized()) { 20 if (frame->is_optimized()) {
20 // TODO(turbofan): Revisit once we support deoptimization. 21 // TODO(turbofan): Revisit once we support deoptimization.
21 if (frame->LookupCode()->is_turbofanned() && 22 if (frame->LookupCode()->is_turbofanned() &&
22 frame->function()->shared()->asm_function() && 23 frame->function()->shared()->asm_function() &&
23 !FLAG_turbo_asm_deoptimization) { 24 !FLAG_turbo_asm_deoptimization) {
24 is_optimized_ = false; 25 is_optimized_ = false;
25 return; 26 return;
26 } 27 }
27 28
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 return isolate_->factory()->undefined_value(); 63 return isolate_->factory()->undefined_value();
63 } 64 }
64 return is_optimized_ ? deoptimized_frame_->GetExpression(index) 65 return is_optimized_ ? deoptimized_frame_->GetExpression(index)
65 : handle(frame_->GetExpression(index), isolate_); 66 : handle(frame_->GetExpression(index), isolate_);
66 } 67 }
67 68
68 69
69 int FrameInspector::GetSourcePosition() { 70 int FrameInspector::GetSourcePosition() {
70 if (is_optimized_) { 71 if (is_optimized_) {
71 return deoptimized_frame_->GetSourcePosition(); 72 return deoptimized_frame_->GetSourcePosition();
73 } else if (is_interpreted_) {
74 InterpretedFrame* frame = reinterpret_cast<InterpretedFrame*>(frame_);
75 // TODO(yangguo): Get the bytecode array from the frame.
Michael Starzinger 2016/02/22 09:37:49 Not sure about this TODO, why do we need to get th
Yang 2016/02/22 12:48:43 Absolutely correct. This is a stale TODO I forgot
76 BytecodeArray* bytecode_array =
77 frame->function()->shared()->bytecode_array();
78 return bytecode_array->SourcePosition(frame->GetBytecodeOffset());
72 } else { 79 } else {
73 Code* code = frame_->LookupCode(); 80 Code* code = frame_->LookupCode();
74 int offset = static_cast<int>(frame_->pc() - code->instruction_start()); 81 int offset = static_cast<int>(frame_->pc() - code->instruction_start());
75 return code->SourcePosition(offset); 82 return code->SourcePosition(offset);
76 } 83 }
77 } 84 }
78 85
79 86
80 bool FrameInspector::IsConstructor() { 87 bool FrameInspector::IsConstructor() {
81 return is_optimized_ && !is_bottommost_ 88 return is_optimized_ && !is_bottommost_
82 ? deoptimized_frame_->HasConstructStub() 89 ? deoptimized_frame_->HasConstructStub()
83 : frame_->IsConstructor(); 90 : frame_->IsConstructor();
84 } 91 }
85 92
86 Handle<Object> FrameInspector::GetContext() { 93 Handle<Object> FrameInspector::GetContext() {
87 return is_optimized_ ? deoptimized_frame_->GetContext() 94 return is_optimized_ ? deoptimized_frame_->GetContext()
88 : handle(frame_->context(), isolate_); 95 : handle(frame_->context(), isolate_);
89 } 96 }
90 97
91 98
92 // To inspect all the provided arguments the frame might need to be 99 // To inspect all the provided arguments the frame might need to be
93 // replaced with the arguments frame. 100 // replaced with the arguments frame.
94 void FrameInspector::SetArgumentsFrame(JavaScriptFrame* frame) { 101 void FrameInspector::SetArgumentsFrame(JavaScriptFrame* frame) {
95 DCHECK(has_adapted_arguments_); 102 DCHECK(has_adapted_arguments_);
96 frame_ = frame; 103 frame_ = frame;
97 is_optimized_ = frame_->is_optimized(); 104 is_optimized_ = frame_->is_optimized();
105 is_interpreted_ = frame_->is_interpreted();
98 DCHECK(!is_optimized_); 106 DCHECK(!is_optimized_);
99 } 107 }
100 108
101 109
102 // Create a plain JSObject which materializes the local scope for the specified 110 // Create a plain JSObject which materializes the local scope for the specified
103 // frame. 111 // frame.
104 void FrameInspector::MaterializeStackLocals(Handle<JSObject> target, 112 void FrameInspector::MaterializeStackLocals(Handle<JSObject> target,
105 Handle<ScopeInfo> scope_info) { 113 Handle<ScopeInfo> scope_info) {
106 HandleScope scope(isolate_); 114 HandleScope scope(isolate_);
107 // First fill all parameters. 115 // First fill all parameters.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 if (!frames[i].function()->shared()->IsSubjectToDebugging()) continue; 216 if (!frames[i].function()->shared()->IsSubjectToDebugging()) continue;
209 if (++count == index) return i; 217 if (++count == index) return i;
210 } 218 }
211 } 219 }
212 return -1; 220 return -1;
213 } 221 }
214 222
215 223
216 } // namespace internal 224 } // namespace internal
217 } // namespace v8 225 } // namespace v8
OLDNEW
« no previous file with comments | « src/debug/debug-frames.h ('k') | src/factory.h » ('j') | src/objects.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698