| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 (ScopeInfo::VariableIsSynthetic(*name)) continue; |
| 120 if (ParameterIsShadowedByContextLocal(scope_info, name)) continue; | 120 if (ParameterIsShadowedByContextLocal(scope_info, name)) continue; |
| 121 | 121 |
| 122 Handle<Object> value = | 122 Handle<Object> value = |
| 123 i < GetParametersCount() | 123 i < GetParametersCount() |
| 124 ? GetParameter(i) | 124 ? GetParameter(i) |
| 125 : Handle<Object>::cast(isolate_->factory()->undefined_value()); | 125 : Handle<Object>::cast(isolate_->factory()->undefined_value()); |
| 126 DCHECK(!value->IsTheHole()); | 126 DCHECK(!value->IsTheHole(isolate_)); |
| 127 | 127 |
| 128 JSObject::SetOwnPropertyIgnoreAttributes(target, name, value, NONE).Check(); | 128 JSObject::SetOwnPropertyIgnoreAttributes(target, name, value, NONE).Check(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 // Second fill all stack locals. | 131 // Second fill all stack locals. |
| 132 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { | 132 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { |
| 133 Handle<String> name(scope_info->StackLocalName(i)); | 133 Handle<String> name(scope_info->StackLocalName(i)); |
| 134 if (ScopeInfo::VariableIsSynthetic(*name)) continue; | 134 if (ScopeInfo::VariableIsSynthetic(*name)) continue; |
| 135 Handle<Object> value = GetExpression(scope_info->StackLocalIndex(i)); | 135 Handle<Object> value = GetExpression(scope_info->StackLocalIndex(i)); |
| 136 // TODO(yangguo): We convert optimized out values to {undefined} when they | 136 // TODO(yangguo): We convert optimized out values to {undefined} when they |
| 137 // are passed to the debugger. Eventually we should handle them somehow. | 137 // are passed to the debugger. Eventually we should handle them somehow. |
| 138 if (value->IsTheHole()) value = isolate_->factory()->undefined_value(); | 138 if (value->IsTheHole(isolate_)) { |
| 139 value = isolate_->factory()->undefined_value(); |
| 140 } |
| 139 if (value->IsOptimizedOut()) value = isolate_->factory()->undefined_value(); | 141 if (value->IsOptimizedOut()) value = isolate_->factory()->undefined_value(); |
| 140 JSObject::SetOwnPropertyIgnoreAttributes(target, name, value, NONE).Check(); | 142 JSObject::SetOwnPropertyIgnoreAttributes(target, name, value, NONE).Check(); |
| 141 } | 143 } |
| 142 } | 144 } |
| 143 | 145 |
| 144 | 146 |
| 145 void FrameInspector::MaterializeStackLocals(Handle<JSObject> target, | 147 void FrameInspector::MaterializeStackLocals(Handle<JSObject> target, |
| 146 Handle<JSFunction> function) { | 148 Handle<JSFunction> function) { |
| 147 Handle<SharedFunctionInfo> shared(function->shared()); | 149 Handle<SharedFunctionInfo> shared(function->shared()); |
| 148 Handle<ScopeInfo> scope_info(shared->scope_info()); | 150 Handle<ScopeInfo> scope_info(shared->scope_info()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 159 | 161 |
| 160 HandleScope scope(isolate_); | 162 HandleScope scope(isolate_); |
| 161 | 163 |
| 162 // Parameters. | 164 // Parameters. |
| 163 for (int i = 0; i < scope_info->ParameterCount(); ++i) { | 165 for (int i = 0; i < scope_info->ParameterCount(); ++i) { |
| 164 // Shadowed parameters were not materialized. | 166 // Shadowed parameters were not materialized. |
| 165 Handle<String> name(scope_info->ParameterName(i)); | 167 Handle<String> name(scope_info->ParameterName(i)); |
| 166 if (ScopeInfo::VariableIsSynthetic(*name)) continue; | 168 if (ScopeInfo::VariableIsSynthetic(*name)) continue; |
| 167 if (ParameterIsShadowedByContextLocal(scope_info, name)) continue; | 169 if (ParameterIsShadowedByContextLocal(scope_info, name)) continue; |
| 168 | 170 |
| 169 DCHECK(!frame_->GetParameter(i)->IsTheHole()); | 171 DCHECK(!frame_->GetParameter(i)->IsTheHole(isolate_)); |
| 170 Handle<Object> value = | 172 Handle<Object> value = |
| 171 Object::GetPropertyOrElement(target, name).ToHandleChecked(); | 173 Object::GetPropertyOrElement(target, name).ToHandleChecked(); |
| 172 frame_->SetParameterValue(i, *value); | 174 frame_->SetParameterValue(i, *value); |
| 173 } | 175 } |
| 174 | 176 |
| 175 // Stack locals. | 177 // Stack locals. |
| 176 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { | 178 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { |
| 177 Handle<String> name(scope_info->StackLocalName(i)); | 179 Handle<String> name(scope_info->StackLocalName(i)); |
| 178 if (ScopeInfo::VariableIsSynthetic(*name)) continue; | 180 if (ScopeInfo::VariableIsSynthetic(*name)) continue; |
| 179 int index = scope_info->StackLocalIndex(i); | 181 int index = scope_info->StackLocalIndex(i); |
| 180 if (frame_->GetExpression(index)->IsTheHole()) continue; | 182 if (frame_->GetExpression(index)->IsTheHole(isolate_)) continue; |
| 181 Handle<Object> value = | 183 Handle<Object> value = |
| 182 Object::GetPropertyOrElement(target, name).ToHandleChecked(); | 184 Object::GetPropertyOrElement(target, name).ToHandleChecked(); |
| 183 frame_->SetExpression(index, *value); | 185 frame_->SetExpression(index, *value); |
| 184 } | 186 } |
| 185 } | 187 } |
| 186 | 188 |
| 187 | 189 |
| 188 bool FrameInspector::ParameterIsShadowedByContextLocal( | 190 bool FrameInspector::ParameterIsShadowedByContextLocal( |
| 189 Handle<ScopeInfo> info, Handle<String> parameter_name) { | 191 Handle<ScopeInfo> info, Handle<String> parameter_name) { |
| 190 VariableMode mode; | 192 VariableMode mode; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 217 if (!frames[i].function()->shared()->IsSubjectToDebugging()) continue; | 219 if (!frames[i].function()->shared()->IsSubjectToDebugging()) continue; |
| 218 if (++count == index) return i; | 220 if (++count == index) return i; |
| 219 } | 221 } |
| 220 } | 222 } |
| 221 return -1; | 223 return -1; |
| 222 } | 224 } |
| 223 | 225 |
| 224 | 226 |
| 225 } // namespace internal | 227 } // namespace internal |
| 226 } // namespace v8 | 228 } // namespace v8 |
| OLD | NEW |