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

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

Issue 1916343002: [debugger] do not expose temporary variables introduced by the parser. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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 | « src/objects.h ('k') | test/mjsunit/debug-scopes.js » ('j') | 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 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 RUNTIME_ASSERT(function->shared()->IsSubjectToDebugging()); 564 RUNTIME_ASSERT(function->shared()->IsSubjectToDebugging());
565 Handle<SharedFunctionInfo> shared(function->shared()); 565 Handle<SharedFunctionInfo> shared(function->shared());
566 Handle<ScopeInfo> scope_info(shared->scope_info()); 566 Handle<ScopeInfo> scope_info(shared->scope_info());
567 DCHECK(*scope_info != ScopeInfo::Empty(isolate)); 567 DCHECK(*scope_info != ScopeInfo::Empty(isolate));
568 568
569 // Get the locals names and values into a temporary array. 569 // Get the locals names and values into a temporary array.
570 int local_count = scope_info->LocalCount(); 570 int local_count = scope_info->LocalCount();
571 for (int slot = 0; slot < scope_info->LocalCount(); ++slot) { 571 for (int slot = 0; slot < scope_info->LocalCount(); ++slot) {
572 // Hide compiler-introduced temporary variables, whether on the stack or on 572 // Hide compiler-introduced temporary variables, whether on the stack or on
573 // the context. 573 // the context.
574 if (scope_info->LocalIsSynthetic(slot)) local_count--; 574 if (ScopeInfo::VariableIsSynthetic(scope_info->LocalName(slot))) {
575 local_count--;
576 }
575 } 577 }
576 578
577 Handle<FixedArray> locals = 579 Handle<FixedArray> locals =
578 isolate->factory()->NewFixedArray(local_count * 2); 580 isolate->factory()->NewFixedArray(local_count * 2);
579 581
580 // Fill in the values of the locals. 582 // Fill in the values of the locals.
581 int local = 0; 583 int local = 0;
582 int i = 0; 584 int i = 0;
583 for (; i < scope_info->StackLocalCount(); ++i) { 585 for (; i < scope_info->StackLocalCount(); ++i) {
584 // Use the value from the stack. 586 // Use the value from the stack.
585 if (scope_info->LocalIsSynthetic(i)) continue; 587 if (ScopeInfo::VariableIsSynthetic(scope_info->LocalName(i))) continue;
586 locals->set(local * 2, scope_info->LocalName(i)); 588 locals->set(local * 2, scope_info->LocalName(i));
587 Handle<Object> value = frame_inspector.GetExpression(i); 589 Handle<Object> value = frame_inspector.GetExpression(i);
588 // TODO(yangguo): We convert optimized out values to {undefined} when they 590 // TODO(yangguo): We convert optimized out values to {undefined} when they
589 // are passed to the debugger. Eventually we should handle them somehow. 591 // are passed to the debugger. Eventually we should handle them somehow.
590 if (value->IsOptimizedOut()) value = isolate->factory()->undefined_value(); 592 if (value->IsOptimizedOut()) value = isolate->factory()->undefined_value();
591 locals->set(local * 2 + 1, *value); 593 locals->set(local * 2 + 1, *value);
592 local++; 594 local++;
593 } 595 }
594 if (local < local_count) { 596 if (local < local_count) {
595 // Get the context containing declarations. 597 // Get the context containing declarations.
596 Handle<Context> context( 598 Handle<Context> context(
597 Handle<Context>::cast(frame_inspector.GetContext())->closure_context()); 599 Handle<Context>::cast(frame_inspector.GetContext())->closure_context());
598 for (; i < scope_info->LocalCount(); ++i) { 600 for (; i < scope_info->LocalCount(); ++i) {
599 if (scope_info->LocalIsSynthetic(i)) continue;
600 Handle<String> name(scope_info->LocalName(i)); 601 Handle<String> name(scope_info->LocalName(i));
602 if (ScopeInfo::VariableIsSynthetic(*name)) continue;
601 VariableMode mode; 603 VariableMode mode;
602 InitializationFlag init_flag; 604 InitializationFlag init_flag;
603 MaybeAssignedFlag maybe_assigned_flag; 605 MaybeAssignedFlag maybe_assigned_flag;
604 locals->set(local * 2, *name); 606 locals->set(local * 2, *name);
605 int context_slot_index = ScopeInfo::ContextSlotIndex( 607 int context_slot_index = ScopeInfo::ContextSlotIndex(
606 scope_info, name, &mode, &init_flag, &maybe_assigned_flag); 608 scope_info, name, &mode, &init_flag, &maybe_assigned_flag);
607 Object* value = context->get(context_slot_index); 609 Object* value = context->get(context_slot_index);
608 locals->set(local * 2 + 1, value); 610 locals->set(local * 2 + 1, value);
609 local++; 611 local++;
610 } 612 }
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 return Smi::FromInt(isolate->debug()->is_active()); 1645 return Smi::FromInt(isolate->debug()->is_active());
1644 } 1646 }
1645 1647
1646 1648
1647 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { 1649 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) {
1648 UNIMPLEMENTED(); 1650 UNIMPLEMENTED();
1649 return NULL; 1651 return NULL;
1650 } 1652 }
1651 } // namespace internal 1653 } // namespace internal
1652 } // namespace v8 1654 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | test/mjsunit/debug-scopes.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698