Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: src/runtime/runtime-debug.cc

Issue 2139613002: [debug] use handle list instead of fixed array for temporary storage. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: address comment Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 // Get the locals names and values into a temporary array. 605 // Get the locals names and values into a temporary array.
606 int local_count = scope_info->LocalCount(); 606 int local_count = scope_info->LocalCount();
607 for (int slot = 0; slot < scope_info->LocalCount(); ++slot) { 607 for (int slot = 0; slot < scope_info->LocalCount(); ++slot) {
608 // Hide compiler-introduced temporary variables, whether on the stack or on 608 // Hide compiler-introduced temporary variables, whether on the stack or on
609 // the context. 609 // the context.
610 if (ScopeInfo::VariableIsSynthetic(scope_info->LocalName(slot))) { 610 if (ScopeInfo::VariableIsSynthetic(scope_info->LocalName(slot))) {
611 local_count--; 611 local_count--;
612 } 612 }
613 } 613 }
614 614
615 Handle<FixedArray> locals = 615 List<Handle<Object>> locals;
616 isolate->factory()->NewFixedArray(local_count * 2);
617
618 // Fill in the values of the locals. 616 // Fill in the values of the locals.
619 int local = 0;
620 int i = 0; 617 int i = 0;
621 for (; i < scope_info->StackLocalCount(); ++i) { 618 for (; i < scope_info->StackLocalCount(); ++i) {
622 // Use the value from the stack. 619 // Use the value from the stack.
623 if (ScopeInfo::VariableIsSynthetic(scope_info->LocalName(i))) continue; 620 if (ScopeInfo::VariableIsSynthetic(scope_info->LocalName(i))) continue;
624 locals->set(local * 2, scope_info->LocalName(i)); 621 locals.Add(Handle<String>(scope_info->LocalName(i), isolate));
625 Handle<Object> value = 622 Handle<Object> value =
626 frame_inspector.GetExpression(scope_info->StackLocalIndex(i)); 623 frame_inspector.GetExpression(scope_info->StackLocalIndex(i));
627 // TODO(yangguo): We convert optimized out values to {undefined} when they 624 // TODO(yangguo): We convert optimized out values to {undefined} when they
628 // are passed to the debugger. Eventually we should handle them somehow. 625 // are passed to the debugger. Eventually we should handle them somehow.
629 if (value->IsOptimizedOut(isolate)) { 626 if (value->IsOptimizedOut(isolate)) {
630 value = isolate->factory()->undefined_value(); 627 value = isolate->factory()->undefined_value();
631 } 628 }
632 locals->set(local * 2 + 1, *value); 629 locals.Add(value);
633 local++;
634 } 630 }
635 if (local < local_count) { 631 if (locals.length() < local_count * 2) {
636 // Get the context containing declarations. 632 // Get the context containing declarations.
637 Handle<Context> context( 633 Handle<Context> context(
638 Handle<Context>::cast(frame_inspector.GetContext())->closure_context()); 634 Handle<Context>::cast(frame_inspector.GetContext())->closure_context());
639 for (; i < scope_info->LocalCount(); ++i) { 635 for (; i < scope_info->LocalCount(); ++i) {
640 Handle<String> name(scope_info->LocalName(i)); 636 Handle<String> name(scope_info->LocalName(i));
641 if (ScopeInfo::VariableIsSynthetic(*name)) continue; 637 if (ScopeInfo::VariableIsSynthetic(*name)) continue;
642 VariableMode mode; 638 VariableMode mode;
643 InitializationFlag init_flag; 639 InitializationFlag init_flag;
644 MaybeAssignedFlag maybe_assigned_flag; 640 MaybeAssignedFlag maybe_assigned_flag;
645 locals->set(local * 2, *name); 641 locals.Add(name);
646 int context_slot_index = ScopeInfo::ContextSlotIndex( 642 int context_slot_index = ScopeInfo::ContextSlotIndex(
647 scope_info, name, &mode, &init_flag, &maybe_assigned_flag); 643 scope_info, name, &mode, &init_flag, &maybe_assigned_flag);
648 Object* value = context->get(context_slot_index); 644 Object* value = context->get(context_slot_index);
649 locals->set(local * 2 + 1, value); 645 locals.Add(Handle<Object>(value, isolate));
650 local++;
651 } 646 }
652 } 647 }
653 648
654 // Check whether this frame is positioned at return. If not top 649 // Check whether this frame is positioned at return. If not top
655 // frame or if the frame is optimized it cannot be at a return. 650 // frame or if the frame is optimized it cannot be at a return.
656 bool at_return = false; 651 bool at_return = false;
657 if (!is_optimized && index == 0) { 652 if (!is_optimized && index == 0) {
658 at_return = isolate->debug()->IsBreakAtReturn(it.javascript_frame()); 653 at_return = isolate->debug()->IsBreakAtReturn(it.javascript_frame());
659 } 654 }
660 655
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 // Parameter value. 741 // Parameter value.
747 if (i < frame_inspector.GetParametersCount()) { 742 if (i < frame_inspector.GetParametersCount()) {
748 // Get the value from the stack. 743 // Get the value from the stack.
749 details->set(details_index++, *(frame_inspector.GetParameter(i))); 744 details->set(details_index++, *(frame_inspector.GetParameter(i)));
750 } else { 745 } else {
751 details->set(details_index++, heap->undefined_value()); 746 details->set(details_index++, heap->undefined_value());
752 } 747 }
753 } 748 }
754 749
755 // Add locals name and value from the temporary copy from the function frame. 750 // Add locals name and value from the temporary copy from the function frame.
756 for (int i = 0; i < local_count * 2; i++) { 751 for (const auto& local : locals) details->set(details_index++, *local);
757 details->set(details_index++, locals->get(i));
758 }
759 752
760 // Add the value being returned. 753 // Add the value being returned.
761 if (at_return) { 754 if (at_return) {
762 details->set(details_index++, *return_value); 755 details->set(details_index++, *return_value);
763 } 756 }
764 757
765 // Add the receiver (same as in function frame). 758 // Add the receiver (same as in function frame).
766 Handle<Object> receiver(it.frame()->receiver(), isolate); 759 Handle<Object> receiver(it.frame()->receiver(), isolate);
767 DCHECK(!function->shared()->IsBuiltin()); 760 DCHECK(!function->shared()->IsBuiltin());
768 DCHECK_IMPLIES(is_sloppy(shared->language_mode()), receiver->IsJSReceiver()); 761 DCHECK_IMPLIES(is_sloppy(shared->language_mode()), receiver->IsJSReceiver());
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after
1819 Handle<Script> script = Handle<Script>(Script::cast(script_val->value())); 1812 Handle<Script> script = Handle<Script>(Script::cast(script_val->value()));
1820 1813
1821 Handle<wasm::WasmDebugInfo> debug_info = 1814 Handle<wasm::WasmDebugInfo> debug_info =
1822 wasm::GetDebugInfo(handle(script->wasm_object(), isolate)); 1815 wasm::GetDebugInfo(handle(script->wasm_object(), isolate));
1823 return *wasm::WasmDebugInfo::DisassembleFunction( 1816 return *wasm::WasmDebugInfo::DisassembleFunction(
1824 debug_info, script->wasm_function_index()); 1817 debug_info, script->wasm_function_index());
1825 } 1818 }
1826 1819
1827 } // namespace internal 1820 } // namespace internal
1828 } // namespace v8 1821 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698