| 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 { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 Deoptimizer::DeleteDebuggerInspectableFrame(deoptimized_frame_, isolate_); | 37 Deoptimizer::DeleteDebuggerInspectableFrame(deoptimized_frame_, isolate_); |
| 38 } | 38 } |
| 39 } | 39 } |
| 40 | 40 |
| 41 | 41 |
| 42 int FrameInspector::GetParametersCount() { | 42 int FrameInspector::GetParametersCount() { |
| 43 return is_optimized_ ? deoptimized_frame_->parameters_count() | 43 return is_optimized_ ? deoptimized_frame_->parameters_count() |
| 44 : frame_->ComputeParametersCount(); | 44 : frame_->ComputeParametersCount(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 | 47 Handle<Object> FrameInspector::GetFunction() { |
| 48 Object* FrameInspector::GetFunction() { | 48 return is_optimized_ ? deoptimized_frame_->GetFunction() |
| 49 return is_optimized_ ? deoptimized_frame_->GetFunction() : frame_->function(); | 49 : handle(frame_->function(), isolate_); |
| 50 } | 50 } |
| 51 | 51 |
| 52 | 52 Handle<Object> FrameInspector::GetParameter(int index) { |
| 53 Object* FrameInspector::GetParameter(int index) { | |
| 54 return is_optimized_ ? deoptimized_frame_->GetParameter(index) | 53 return is_optimized_ ? deoptimized_frame_->GetParameter(index) |
| 55 : frame_->GetParameter(index); | 54 : handle(frame_->GetParameter(index), isolate_); |
| 56 } | 55 } |
| 57 | 56 |
| 58 | 57 Handle<Object> FrameInspector::GetExpression(int index) { |
| 59 Object* FrameInspector::GetExpression(int index) { | |
| 60 // TODO(turbofan): Revisit once we support deoptimization. | 58 // TODO(turbofan): Revisit once we support deoptimization. |
| 61 if (frame_->LookupCode()->is_turbofanned() && | 59 if (frame_->LookupCode()->is_turbofanned() && |
| 62 frame_->function()->shared()->asm_function() && | 60 frame_->function()->shared()->asm_function() && |
| 63 !FLAG_turbo_asm_deoptimization) { | 61 !FLAG_turbo_asm_deoptimization) { |
| 64 return isolate_->heap()->undefined_value(); | 62 return isolate_->factory()->undefined_value(); |
| 65 } | 63 } |
| 66 return is_optimized_ ? deoptimized_frame_->GetExpression(index) | 64 return is_optimized_ ? deoptimized_frame_->GetExpression(index) |
| 67 : frame_->GetExpression(index); | 65 : handle(frame_->GetExpression(index), isolate_); |
| 68 } | 66 } |
| 69 | 67 |
| 70 | 68 |
| 71 int FrameInspector::GetSourcePosition() { | 69 int FrameInspector::GetSourcePosition() { |
| 72 if (is_optimized_) { | 70 if (is_optimized_) { |
| 73 return deoptimized_frame_->GetSourcePosition(); | 71 return deoptimized_frame_->GetSourcePosition(); |
| 74 } else { | 72 } else { |
| 75 Code* code = frame_->LookupCode(); | 73 Code* code = frame_->LookupCode(); |
| 76 int offset = static_cast<int>(frame_->pc() - code->instruction_start()); | 74 int offset = static_cast<int>(frame_->pc() - code->instruction_start()); |
| 77 return code->SourcePosition(offset); | 75 return code->SourcePosition(offset); |
| 78 } | 76 } |
| 79 } | 77 } |
| 80 | 78 |
| 81 | 79 |
| 82 bool FrameInspector::IsConstructor() { | 80 bool FrameInspector::IsConstructor() { |
| 83 return is_optimized_ && !is_bottommost_ | 81 return is_optimized_ && !is_bottommost_ |
| 84 ? deoptimized_frame_->HasConstructStub() | 82 ? deoptimized_frame_->HasConstructStub() |
| 85 : frame_->IsConstructor(); | 83 : frame_->IsConstructor(); |
| 86 } | 84 } |
| 87 | 85 |
| 88 | 86 Handle<Object> FrameInspector::GetContext() { |
| 89 Object* FrameInspector::GetContext() { | 87 return is_optimized_ ? deoptimized_frame_->GetContext() |
| 90 return is_optimized_ ? deoptimized_frame_->GetContext() : frame_->context(); | 88 : handle(frame_->context(), isolate_); |
| 91 } | 89 } |
| 92 | 90 |
| 93 | 91 |
| 94 // To inspect all the provided arguments the frame might need to be | 92 // To inspect all the provided arguments the frame might need to be |
| 95 // replaced with the arguments frame. | 93 // replaced with the arguments frame. |
| 96 void FrameInspector::SetArgumentsFrame(JavaScriptFrame* frame) { | 94 void FrameInspector::SetArgumentsFrame(JavaScriptFrame* frame) { |
| 97 DCHECK(has_adapted_arguments_); | 95 DCHECK(has_adapted_arguments_); |
| 98 frame_ = frame; | 96 frame_ = frame; |
| 99 is_optimized_ = frame_->is_optimized(); | 97 is_optimized_ = frame_->is_optimized(); |
| 100 DCHECK(!is_optimized_); | 98 DCHECK(!is_optimized_); |
| 101 } | 99 } |
| 102 | 100 |
| 103 | 101 |
| 104 // Create a plain JSObject which materializes the local scope for the specified | 102 // Create a plain JSObject which materializes the local scope for the specified |
| 105 // frame. | 103 // frame. |
| 106 void FrameInspector::MaterializeStackLocals(Handle<JSObject> target, | 104 void FrameInspector::MaterializeStackLocals(Handle<JSObject> target, |
| 107 Handle<ScopeInfo> scope_info) { | 105 Handle<ScopeInfo> scope_info) { |
| 108 HandleScope scope(isolate_); | 106 HandleScope scope(isolate_); |
| 109 // First fill all parameters. | 107 // First fill all parameters. |
| 110 for (int i = 0; i < scope_info->ParameterCount(); ++i) { | 108 for (int i = 0; i < scope_info->ParameterCount(); ++i) { |
| 111 // Do not materialize the parameter if it is shadowed by a context local. | 109 // Do not materialize the parameter if it is shadowed by a context local. |
| 112 // TODO(yangguo): check whether this is necessary, now that we materialize | 110 // TODO(yangguo): check whether this is necessary, now that we materialize |
| 113 // context locals as well. | 111 // context locals as well. |
| 114 Handle<String> name(scope_info->ParameterName(i)); | 112 Handle<String> name(scope_info->ParameterName(i)); |
| 115 if (ParameterIsShadowedByContextLocal(scope_info, name)) continue; | 113 if (ParameterIsShadowedByContextLocal(scope_info, name)) continue; |
| 116 | 114 |
| 117 Handle<Object> value(i < GetParametersCount() | 115 Handle<Object> value = |
| 118 ? GetParameter(i) | 116 i < GetParametersCount() |
| 119 : isolate_->heap()->undefined_value(), | 117 ? GetParameter(i) |
| 120 isolate_); | 118 : Handle<Object>::cast(isolate_->factory()->undefined_value()); |
| 121 DCHECK(!value->IsTheHole()); | 119 DCHECK(!value->IsTheHole()); |
| 122 | 120 |
| 123 JSObject::SetOwnPropertyIgnoreAttributes(target, name, value, NONE).Check(); | 121 JSObject::SetOwnPropertyIgnoreAttributes(target, name, value, NONE).Check(); |
| 124 } | 122 } |
| 125 | 123 |
| 126 // Second fill all stack locals. | 124 // Second fill all stack locals. |
| 127 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { | 125 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { |
| 128 if (scope_info->LocalIsSynthetic(i)) continue; | 126 if (scope_info->LocalIsSynthetic(i)) continue; |
| 129 Handle<String> name(scope_info->StackLocalName(i)); | 127 Handle<String> name(scope_info->StackLocalName(i)); |
| 130 Handle<Object> value(GetExpression(scope_info->StackLocalIndex(i)), | 128 Handle<Object> value = GetExpression(scope_info->StackLocalIndex(i)); |
| 131 isolate_); | |
| 132 if (value->IsTheHole()) value = isolate_->factory()->undefined_value(); | 129 if (value->IsTheHole()) value = isolate_->factory()->undefined_value(); |
| 133 | 130 |
| 134 JSObject::SetOwnPropertyIgnoreAttributes(target, name, value, NONE).Check(); | 131 JSObject::SetOwnPropertyIgnoreAttributes(target, name, value, NONE).Check(); |
| 135 } | 132 } |
| 136 } | 133 } |
| 137 | 134 |
| 138 | 135 |
| 139 void FrameInspector::MaterializeStackLocals(Handle<JSObject> target, | 136 void FrameInspector::MaterializeStackLocals(Handle<JSObject> target, |
| 140 Handle<JSFunction> function) { | 137 Handle<JSFunction> function) { |
| 141 Handle<SharedFunctionInfo> shared(function->shared()); | 138 Handle<SharedFunctionInfo> shared(function->shared()); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 if (!frames[i].function()->shared()->IsSubjectToDebugging()) continue; | 208 if (!frames[i].function()->shared()->IsSubjectToDebugging()) continue; |
| 212 if (++count == index) return i; | 209 if (++count == index) return i; |
| 213 } | 210 } |
| 214 } | 211 } |
| 215 return -1; | 212 return -1; |
| 216 } | 213 } |
| 217 | 214 |
| 218 | 215 |
| 219 } // namespace internal | 216 } // namespace internal |
| 220 } // namespace v8 | 217 } // namespace v8 |
| OLD | NEW |