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 | 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 Loading... |
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 BytecodeArray* bytecode_array = |
| 76 frame->function()->shared()->bytecode_array(); |
| 77 return bytecode_array->SourcePosition(frame->GetBytecodeOffset()); |
72 } else { | 78 } else { |
73 Code* code = frame_->LookupCode(); | 79 Code* code = frame_->LookupCode(); |
74 int offset = static_cast<int>(frame_->pc() - code->instruction_start()); | 80 int offset = static_cast<int>(frame_->pc() - code->instruction_start()); |
75 return code->SourcePosition(offset); | 81 return code->SourcePosition(offset); |
76 } | 82 } |
77 } | 83 } |
78 | 84 |
79 | 85 |
80 bool FrameInspector::IsConstructor() { | 86 bool FrameInspector::IsConstructor() { |
81 return is_optimized_ && !is_bottommost_ | 87 return is_optimized_ && !is_bottommost_ |
82 ? deoptimized_frame_->HasConstructStub() | 88 ? deoptimized_frame_->HasConstructStub() |
83 : frame_->IsConstructor(); | 89 : frame_->IsConstructor(); |
84 } | 90 } |
85 | 91 |
86 Handle<Object> FrameInspector::GetContext() { | 92 Handle<Object> FrameInspector::GetContext() { |
87 return is_optimized_ ? deoptimized_frame_->GetContext() | 93 return is_optimized_ ? deoptimized_frame_->GetContext() |
88 : handle(frame_->context(), isolate_); | 94 : handle(frame_->context(), isolate_); |
89 } | 95 } |
90 | 96 |
91 | 97 |
92 // To inspect all the provided arguments the frame might need to be | 98 // To inspect all the provided arguments the frame might need to be |
93 // replaced with the arguments frame. | 99 // replaced with the arguments frame. |
94 void FrameInspector::SetArgumentsFrame(JavaScriptFrame* frame) { | 100 void FrameInspector::SetArgumentsFrame(JavaScriptFrame* frame) { |
95 DCHECK(has_adapted_arguments_); | 101 DCHECK(has_adapted_arguments_); |
96 frame_ = frame; | 102 frame_ = frame; |
97 is_optimized_ = frame_->is_optimized(); | 103 is_optimized_ = frame_->is_optimized(); |
| 104 is_interpreted_ = frame_->is_interpreted(); |
98 DCHECK(!is_optimized_); | 105 DCHECK(!is_optimized_); |
99 } | 106 } |
100 | 107 |
101 | 108 |
102 // Create a plain JSObject which materializes the local scope for the specified | 109 // Create a plain JSObject which materializes the local scope for the specified |
103 // frame. | 110 // frame. |
104 void FrameInspector::MaterializeStackLocals(Handle<JSObject> target, | 111 void FrameInspector::MaterializeStackLocals(Handle<JSObject> target, |
105 Handle<ScopeInfo> scope_info) { | 112 Handle<ScopeInfo> scope_info) { |
106 HandleScope scope(isolate_); | 113 HandleScope scope(isolate_); |
107 // First fill all parameters. | 114 // First fill all parameters. |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 if (!frames[i].function()->shared()->IsSubjectToDebugging()) continue; | 215 if (!frames[i].function()->shared()->IsSubjectToDebugging()) continue; |
209 if (++count == index) return i; | 216 if (++count == index) return i; |
210 } | 217 } |
211 } | 218 } |
212 return -1; | 219 return -1; |
213 } | 220 } |
214 | 221 |
215 | 222 |
216 } // namespace internal | 223 } // namespace internal |
217 } // namespace v8 | 224 } // namespace v8 |
OLD | NEW |