| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
| 6 | 6 |
| 7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/debug/debug-evaluate.h" | 8 #include "src/debug/debug-evaluate.h" |
| 9 #include "src/debug/debug-frames.h" | 9 #include "src/debug/debug-frames.h" |
| 10 #include "src/debug/debug-scopes.h" | 10 #include "src/debug/debug-scopes.h" |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 | 599 |
| 600 // Get scope info and read from it for local variable information. | 600 // Get scope info and read from it for local variable information. |
| 601 Handle<JSFunction> function = | 601 Handle<JSFunction> function = |
| 602 Handle<JSFunction>::cast(frame_inspector.GetFunction()); | 602 Handle<JSFunction>::cast(frame_inspector.GetFunction()); |
| 603 CHECK(function->shared()->IsSubjectToDebugging()); | 603 CHECK(function->shared()->IsSubjectToDebugging()); |
| 604 Handle<SharedFunctionInfo> shared(function->shared()); | 604 Handle<SharedFunctionInfo> shared(function->shared()); |
| 605 Handle<ScopeInfo> scope_info(shared->scope_info()); | 605 Handle<ScopeInfo> scope_info(shared->scope_info()); |
| 606 DCHECK(*scope_info != ScopeInfo::Empty(isolate)); | 606 DCHECK(*scope_info != ScopeInfo::Empty(isolate)); |
| 607 | 607 |
| 608 // Get the locals names and values into a temporary array. | 608 // Get the locals names and values into a temporary array. |
| 609 int local_count = scope_info->LocalCount(); | 609 Handle<Object> maybe_context = frame_inspector.GetContext(); |
| 610 for (int slot = 0; slot < scope_info->LocalCount(); ++slot) { | 610 const int local_count_with_synthetic = maybe_context->IsContext() |
| 611 ? scope_info->LocalCount() |
| 612 : scope_info->StackLocalCount(); |
| 613 int local_count = local_count_with_synthetic; |
| 614 for (int slot = 0; slot < local_count_with_synthetic; ++slot) { |
| 611 // Hide compiler-introduced temporary variables, whether on the stack or on | 615 // Hide compiler-introduced temporary variables, whether on the stack or on |
| 612 // the context. | 616 // the context. |
| 613 if (ScopeInfo::VariableIsSynthetic(scope_info->LocalName(slot))) { | 617 if (ScopeInfo::VariableIsSynthetic(scope_info->LocalName(slot))) { |
| 614 local_count--; | 618 local_count--; |
| 615 } | 619 } |
| 616 } | 620 } |
| 617 | 621 |
| 618 List<Handle<Object>> locals; | 622 List<Handle<Object>> locals; |
| 619 // Fill in the values of the locals. | 623 // Fill in the values of the locals. |
| 620 int i = 0; | 624 int i = 0; |
| 621 for (; i < scope_info->StackLocalCount(); ++i) { | 625 for (; i < scope_info->StackLocalCount(); ++i) { |
| 622 // Use the value from the stack. | 626 // Use the value from the stack. |
| 623 if (ScopeInfo::VariableIsSynthetic(scope_info->LocalName(i))) continue; | 627 if (ScopeInfo::VariableIsSynthetic(scope_info->LocalName(i))) continue; |
| 624 locals.Add(Handle<String>(scope_info->LocalName(i), isolate)); | 628 locals.Add(Handle<String>(scope_info->LocalName(i), isolate)); |
| 625 Handle<Object> value = | 629 Handle<Object> value = |
| 626 frame_inspector.GetExpression(scope_info->StackLocalIndex(i)); | 630 frame_inspector.GetExpression(scope_info->StackLocalIndex(i)); |
| 627 // TODO(yangguo): We convert optimized out values to {undefined} when they | 631 // TODO(yangguo): We convert optimized out values to {undefined} when they |
| 628 // are passed to the debugger. Eventually we should handle them somehow. | 632 // are passed to the debugger. Eventually we should handle them somehow. |
| 629 if (value->IsOptimizedOut(isolate)) { | 633 if (value->IsOptimizedOut(isolate)) { |
| 630 value = isolate->factory()->undefined_value(); | 634 value = isolate->factory()->undefined_value(); |
| 631 } | 635 } |
| 632 locals.Add(value); | 636 locals.Add(value); |
| 633 } | 637 } |
| 634 if (locals.length() < local_count * 2) { | 638 if (locals.length() < local_count * 2) { |
| 635 // Get the context containing declarations. | 639 // Get the context containing declarations. |
| 636 Handle<Context> context( | 640 DCHECK(maybe_context->IsContext()); |
| 637 Handle<Context>::cast(frame_inspector.GetContext())->closure_context()); | 641 Handle<Context> context(Context::cast(*maybe_context)->closure_context()); |
| 642 |
| 638 for (; i < scope_info->LocalCount(); ++i) { | 643 for (; i < scope_info->LocalCount(); ++i) { |
| 639 Handle<String> name(scope_info->LocalName(i)); | 644 Handle<String> name(scope_info->LocalName(i)); |
| 640 if (ScopeInfo::VariableIsSynthetic(*name)) continue; | 645 if (ScopeInfo::VariableIsSynthetic(*name)) continue; |
| 641 VariableMode mode; | 646 VariableMode mode; |
| 642 InitializationFlag init_flag; | 647 InitializationFlag init_flag; |
| 643 MaybeAssignedFlag maybe_assigned_flag; | 648 MaybeAssignedFlag maybe_assigned_flag; |
| 644 locals.Add(name); | 649 locals.Add(name); |
| 645 int context_slot_index = ScopeInfo::ContextSlotIndex( | 650 int context_slot_index = ScopeInfo::ContextSlotIndex( |
| 646 scope_info, name, &mode, &init_flag, &maybe_assigned_flag); | 651 scope_info, name, &mode, &init_flag, &maybe_assigned_flag); |
| 647 Object* value = context->get(context_slot_index); | 652 Object* value = context->get(context_slot_index); |
| (...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1860 Handle<Script> script = Handle<Script>(Script::cast(script_val->value())); | 1865 Handle<Script> script = Handle<Script>(Script::cast(script_val->value())); |
| 1861 | 1866 |
| 1862 Handle<wasm::WasmDebugInfo> debug_info = | 1867 Handle<wasm::WasmDebugInfo> debug_info = |
| 1863 wasm::GetDebugInfo(handle(script->wasm_object(), isolate)); | 1868 wasm::GetDebugInfo(handle(script->wasm_object(), isolate)); |
| 1864 return *wasm::WasmDebugInfo::DisassembleFunction( | 1869 return *wasm::WasmDebugInfo::DisassembleFunction( |
| 1865 debug_info, script->wasm_function_index()); | 1870 debug_info, script->wasm_function_index()); |
| 1866 } | 1871 } |
| 1867 | 1872 |
| 1868 } // namespace internal | 1873 } // namespace internal |
| 1869 } // namespace v8 | 1874 } // namespace v8 |
| OLD | NEW |