| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // frame. | 109 // frame. |
| 110 void FrameInspector::MaterializeStackLocals(Handle<JSObject> target, | 110 void FrameInspector::MaterializeStackLocals(Handle<JSObject> target, |
| 111 Handle<ScopeInfo> scope_info) { | 111 Handle<ScopeInfo> scope_info) { |
| 112 HandleScope scope(isolate_); | 112 HandleScope scope(isolate_); |
| 113 // First fill all parameters. | 113 // First fill all parameters. |
| 114 for (int i = 0; i < scope_info->ParameterCount(); ++i) { | 114 for (int i = 0; i < scope_info->ParameterCount(); ++i) { |
| 115 // Do not materialize the parameter if it is shadowed by a context local. | 115 // Do not materialize the parameter if it is shadowed by a context local. |
| 116 // TODO(yangguo): check whether this is necessary, now that we materialize | 116 // TODO(yangguo): check whether this is necessary, now that we materialize |
| 117 // context locals as well. | 117 // context locals as well. |
| 118 Handle<String> name(scope_info->ParameterName(i)); | 118 Handle<String> name(scope_info->ParameterName(i)); |
| 119 if (ScopeInfo::VariableIsSynthetic(*name)) continue; |
| 119 if (ParameterIsShadowedByContextLocal(scope_info, name)) continue; | 120 if (ParameterIsShadowedByContextLocal(scope_info, name)) continue; |
| 120 | 121 |
| 121 Handle<Object> value = | 122 Handle<Object> value = |
| 122 i < GetParametersCount() | 123 i < GetParametersCount() |
| 123 ? GetParameter(i) | 124 ? GetParameter(i) |
| 124 : Handle<Object>::cast(isolate_->factory()->undefined_value()); | 125 : Handle<Object>::cast(isolate_->factory()->undefined_value()); |
| 125 DCHECK(!value->IsTheHole()); | 126 DCHECK(!value->IsTheHole()); |
| 126 | 127 |
| 127 JSObject::SetOwnPropertyIgnoreAttributes(target, name, value, NONE).Check(); | 128 JSObject::SetOwnPropertyIgnoreAttributes(target, name, value, NONE).Check(); |
| 128 } | 129 } |
| 129 | 130 |
| 130 // Second fill all stack locals. | 131 // Second fill all stack locals. |
| 131 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { | 132 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { |
| 132 if (scope_info->LocalIsSynthetic(i)) continue; | |
| 133 Handle<String> name(scope_info->StackLocalName(i)); | 133 Handle<String> name(scope_info->StackLocalName(i)); |
| 134 if (ScopeInfo::VariableIsSynthetic(*name)) continue; |
| 134 Handle<Object> value = GetExpression(scope_info->StackLocalIndex(i)); | 135 Handle<Object> value = GetExpression(scope_info->StackLocalIndex(i)); |
| 135 // TODO(yangguo): We convert optimized out values to {undefined} when they | 136 // TODO(yangguo): We convert optimized out values to {undefined} when they |
| 136 // are passed to the debugger. Eventually we should handle them somehow. | 137 // are passed to the debugger. Eventually we should handle them somehow. |
| 137 if (value->IsTheHole()) value = isolate_->factory()->undefined_value(); | 138 if (value->IsTheHole()) value = isolate_->factory()->undefined_value(); |
| 138 if (value->IsOptimizedOut()) value = isolate_->factory()->undefined_value(); | 139 if (value->IsOptimizedOut()) value = isolate_->factory()->undefined_value(); |
| 139 JSObject::SetOwnPropertyIgnoreAttributes(target, name, value, NONE).Check(); | 140 JSObject::SetOwnPropertyIgnoreAttributes(target, name, value, NONE).Check(); |
| 140 } | 141 } |
| 141 } | 142 } |
| 142 | 143 |
| 143 | 144 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 155 // Optimized frames are not supported. Simply give up. | 156 // Optimized frames are not supported. Simply give up. |
| 156 return; | 157 return; |
| 157 } | 158 } |
| 158 | 159 |
| 159 HandleScope scope(isolate_); | 160 HandleScope scope(isolate_); |
| 160 | 161 |
| 161 // Parameters. | 162 // Parameters. |
| 162 for (int i = 0; i < scope_info->ParameterCount(); ++i) { | 163 for (int i = 0; i < scope_info->ParameterCount(); ++i) { |
| 163 // Shadowed parameters were not materialized. | 164 // Shadowed parameters were not materialized. |
| 164 Handle<String> name(scope_info->ParameterName(i)); | 165 Handle<String> name(scope_info->ParameterName(i)); |
| 166 if (ScopeInfo::VariableIsSynthetic(*name)) continue; |
| 165 if (ParameterIsShadowedByContextLocal(scope_info, name)) continue; | 167 if (ParameterIsShadowedByContextLocal(scope_info, name)) continue; |
| 166 | 168 |
| 167 DCHECK(!frame_->GetParameter(i)->IsTheHole()); | 169 DCHECK(!frame_->GetParameter(i)->IsTheHole()); |
| 168 Handle<Object> value = | 170 Handle<Object> value = |
| 169 Object::GetPropertyOrElement(target, name).ToHandleChecked(); | 171 Object::GetPropertyOrElement(target, name).ToHandleChecked(); |
| 170 frame_->SetParameterValue(i, *value); | 172 frame_->SetParameterValue(i, *value); |
| 171 } | 173 } |
| 172 | 174 |
| 173 // Stack locals. | 175 // Stack locals. |
| 174 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { | 176 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { |
| 175 if (scope_info->LocalIsSynthetic(i)) continue; | 177 Handle<String> name(scope_info->StackLocalName(i)); |
| 178 if (ScopeInfo::VariableIsSynthetic(*name)) continue; |
| 176 int index = scope_info->StackLocalIndex(i); | 179 int index = scope_info->StackLocalIndex(i); |
| 177 if (frame_->GetExpression(index)->IsTheHole()) continue; | 180 if (frame_->GetExpression(index)->IsTheHole()) continue; |
| 178 Handle<Object> value = | 181 Handle<Object> value = |
| 179 Object::GetPropertyOrElement( | 182 Object::GetPropertyOrElement(target, name).ToHandleChecked(); |
| 180 target, handle(scope_info->StackLocalName(i), isolate_)) | |
| 181 .ToHandleChecked(); | |
| 182 frame_->SetExpression(index, *value); | 183 frame_->SetExpression(index, *value); |
| 183 } | 184 } |
| 184 } | 185 } |
| 185 | 186 |
| 186 | 187 |
| 187 bool FrameInspector::ParameterIsShadowedByContextLocal( | 188 bool FrameInspector::ParameterIsShadowedByContextLocal( |
| 188 Handle<ScopeInfo> info, Handle<String> parameter_name) { | 189 Handle<ScopeInfo> info, Handle<String> parameter_name) { |
| 189 VariableMode mode; | 190 VariableMode mode; |
| 190 InitializationFlag init_flag; | 191 InitializationFlag init_flag; |
| 191 MaybeAssignedFlag maybe_assigned_flag; | 192 MaybeAssignedFlag maybe_assigned_flag; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 216 if (!frames[i].function()->shared()->IsSubjectToDebugging()) continue; | 217 if (!frames[i].function()->shared()->IsSubjectToDebugging()) continue; |
| 217 if (++count == index) return i; | 218 if (++count == index) return i; |
| 218 } | 219 } |
| 219 } | 220 } |
| 220 return -1; | 221 return -1; |
| 221 } | 222 } |
| 222 | 223 |
| 223 | 224 |
| 224 } // namespace internal | 225 } // namespace internal |
| 225 } // namespace v8 | 226 } // namespace v8 |
| OLD | NEW |