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

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

Issue 1957303002: [debugger] keep scope and context chain for hidden scopes in sync. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix test 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/debug/debug-scopes.h ('k') | test/mjsunit/es6/regress/regress-468661.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 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-scopes.h" 5 #include "src/debug/debug-scopes.h"
6 6
7 #include "src/ast/scopes.h" 7 #include "src/ast/scopes.h"
8 #include "src/debug/debug.h" 8 #include "src/debug/debug.h"
9 #include "src/frames-inl.h" 9 #include "src/frames-inl.h"
10 #include "src/globals.h" 10 #include "src/globals.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 if (!nested_scope_chain_.is_empty()) { 194 if (!nested_scope_chain_.is_empty()) {
195 DCHECK_EQ(nested_scope_chain_.last().scope_info->scope_type(), 195 DCHECK_EQ(nested_scope_chain_.last().scope_info->scope_type(),
196 SCRIPT_SCOPE); 196 SCRIPT_SCOPE);
197 nested_scope_chain_.RemoveLast(); 197 nested_scope_chain_.RemoveLast();
198 DCHECK(nested_scope_chain_.is_empty()); 198 DCHECK(nested_scope_chain_.is_empty());
199 } 199 }
200 CHECK(context_->IsNativeContext()); 200 CHECK(context_->IsNativeContext());
201 } else if (nested_scope_chain_.is_empty()) { 201 } else if (nested_scope_chain_.is_empty()) {
202 context_ = Handle<Context>(context_->previous(), isolate_); 202 context_ = Handle<Context>(context_->previous(), isolate_);
203 } else { 203 } else {
204 if (nested_scope_chain_.last().scope_info->HasContext()) { 204 do {
205 DCHECK(context_->previous() != NULL); 205 if (nested_scope_chain_.last().scope_info->HasContext()) {
206 context_ = Handle<Context>(context_->previous(), isolate_); 206 DCHECK(context_->previous() != NULL);
207 } 207 context_ = Handle<Context>(context_->previous(), isolate_);
208 nested_scope_chain_.RemoveLast(); 208 }
209 nested_scope_chain_.RemoveLast();
210 if (nested_scope_chain_.is_empty()) break;
211 // Repeat to skip hidden scopes.
212 } while (nested_scope_chain_.last().is_hidden());
209 } 213 }
210 UnwrapEvaluationContext(); 214 UnwrapEvaluationContext();
211 } 215 }
212 216
213 217
214 // Return the type of the current scope. 218 // Return the type of the current scope.
215 ScopeIterator::ScopeType ScopeIterator::Type() { 219 ScopeIterator::ScopeType ScopeIterator::Type() {
216 DCHECK(!failed_); 220 DCHECK(!failed_);
217 if (!nested_scope_chain_.is_empty()) { 221 if (!nested_scope_chain_.is_empty()) {
218 Handle<ScopeInfo> scope_info = nested_scope_chain_.last().scope_info; 222 Handle<ScopeInfo> scope_info = nested_scope_chain_.last().scope_info;
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 isolate_, value, Object::GetPropertyOrElement(extension, key), false); 793 isolate_, value, Object::GetPropertyOrElement(extension, key), false);
790 RETURN_ON_EXCEPTION_VALUE( 794 RETURN_ON_EXCEPTION_VALUE(
791 isolate_, JSObject::SetOwnPropertyIgnoreAttributes( 795 isolate_, JSObject::SetOwnPropertyIgnoreAttributes(
792 scope_object, key, value, NONE), false); 796 scope_object, key, value, NONE), false);
793 } 797 }
794 return true; 798 return true;
795 } 799 }
796 800
797 void ScopeIterator::GetNestedScopeChain(Isolate* isolate, Scope* scope, 801 void ScopeIterator::GetNestedScopeChain(Isolate* isolate, Scope* scope,
798 int position) { 802 int position) {
799 if (!scope->is_eval_scope() && !scope->is_hidden()) { 803 if (!scope->is_eval_scope()) {
800 nested_scope_chain_.Add(ExtendedScopeInfo(scope->GetScopeInfo(isolate), 804 if (scope->is_hidden()) {
801 scope->start_position(), 805 // We need to add this chain element in case the scope has a context
802 scope->end_position())); 806 // associated. We need to keep the scope chain and context chain in sync.
807 nested_scope_chain_.Add(ExtendedScopeInfo(scope->GetScopeInfo(isolate)));
808 } else {
809 nested_scope_chain_.Add(ExtendedScopeInfo(scope->GetScopeInfo(isolate),
810 scope->start_position(),
811 scope->end_position()));
812 }
803 } 813 }
804 for (int i = 0; i < scope->inner_scopes()->length(); i++) { 814 for (int i = 0; i < scope->inner_scopes()->length(); i++) {
805 Scope* inner_scope = scope->inner_scopes()->at(i); 815 Scope* inner_scope = scope->inner_scopes()->at(i);
806 int beg_pos = inner_scope->start_position(); 816 int beg_pos = inner_scope->start_position();
807 int end_pos = inner_scope->end_position(); 817 int end_pos = inner_scope->end_position();
808 DCHECK((beg_pos >= 0 && end_pos >= 0) || inner_scope->is_hidden()); 818 DCHECK((beg_pos >= 0 && end_pos >= 0) || inner_scope->is_hidden());
809 if (beg_pos <= position && position < end_pos) { 819 if (beg_pos <= position && position < end_pos) {
810 GetNestedScopeChain(isolate, inner_scope, position); 820 GetNestedScopeChain(isolate, inner_scope, position);
811 return; 821 return;
812 } 822 }
813 } 823 }
814 } 824 }
815 825
816 } // namespace internal 826 } // namespace internal
817 } // namespace v8 827 } // namespace v8
OLDNEW
« no previous file with comments | « src/debug/debug-scopes.h ('k') | test/mjsunit/es6/regress/regress-468661.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698