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

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

Issue 2632123006: Reland: [Parse] ParseInfo owns the parsing Zone. (Closed)
Patch Set: Created 3 years, 11 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
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 <memory> 7 #include <memory>
8 8
9 #include "src/ast/ast.h" 9 #include "src/ast/ast.h"
10 #include "src/ast/scopes.h" 10 #include "src/ast/scopes.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 if (scope_info->scope_type() == FUNCTION_SCOPE) { 79 if (scope_info->scope_type() == FUNCTION_SCOPE) {
80 nested_scope_chain_.Add(ExtendedScopeInfo(scope_info, 80 nested_scope_chain_.Add(ExtendedScopeInfo(scope_info,
81 shared_info->start_position(), 81 shared_info->start_position(),
82 shared_info->end_position())); 82 shared_info->end_position()));
83 } 83 }
84 if (!collect_non_locals) return; 84 if (!collect_non_locals) return;
85 } 85 }
86 86
87 // Reparse the code and analyze the scopes. 87 // Reparse the code and analyze the scopes.
88 // Check whether we are in global, eval or function code. 88 // Check whether we are in global, eval or function code.
89 Zone zone(isolate->allocator(), ZONE_NAME);
90 std::unique_ptr<ParseInfo> info; 89 std::unique_ptr<ParseInfo> info;
91 if (scope_info->scope_type() != FUNCTION_SCOPE) { 90 if (scope_info->scope_type() != FUNCTION_SCOPE) {
92 // Global or eval code. 91 // Global or eval code.
93 Handle<Script> script(Script::cast(shared_info->script())); 92 Handle<Script> script(Script::cast(shared_info->script()));
94 info.reset(new ParseInfo(&zone, script)); 93 info.reset(new ParseInfo(script));
95 if (scope_info->scope_type() == EVAL_SCOPE) { 94 if (scope_info->scope_type() == EVAL_SCOPE) {
96 info->set_eval(); 95 info->set_eval();
97 if (!function->context()->IsNativeContext()) { 96 if (!function->context()->IsNativeContext()) {
98 info->set_outer_scope_info(handle(function->context()->scope_info())); 97 info->set_outer_scope_info(handle(function->context()->scope_info()));
99 } 98 }
100 // Language mode may be inherited from the eval caller. 99 // Language mode may be inherited from the eval caller.
101 // Retrieve it from shared function info. 100 // Retrieve it from shared function info.
102 info->set_language_mode(shared_info->language_mode()); 101 info->set_language_mode(shared_info->language_mode());
103 } else if (scope_info->scope_type() == MODULE_SCOPE) { 102 } else if (scope_info->scope_type() == MODULE_SCOPE) {
104 info->set_module(); 103 info->set_module();
105 } else { 104 } else {
106 DCHECK(scope_info->scope_type() == SCRIPT_SCOPE); 105 DCHECK(scope_info->scope_type() == SCRIPT_SCOPE);
107 } 106 }
108 } else { 107 } else {
109 // Inner function. 108 // Inner function.
110 info.reset(new ParseInfo(&zone, shared_info)); 109 info.reset(new ParseInfo(shared_info));
111 } 110 }
112 if (parsing::ParseAny(info.get()) && Rewriter::Rewrite(info.get())) { 111 if (parsing::ParseAny(info.get()) && Rewriter::Rewrite(info.get())) {
113 DeclarationScope* scope = info->literal()->scope(); 112 DeclarationScope* scope = info->literal()->scope();
114 if (!ignore_nested_scopes || collect_non_locals) { 113 if (!ignore_nested_scopes || collect_non_locals) {
115 CollectNonLocals(info.get(), scope); 114 CollectNonLocals(info.get(), scope);
116 } 115 }
117 if (!ignore_nested_scopes) { 116 if (!ignore_nested_scopes) {
118 DeclarationScope::Analyze(info.get(), AnalyzeMode::kDebugger); 117 DeclarationScope::Analyze(info.get(), AnalyzeMode::kDebugger);
119 RetrieveScopeChain(scope); 118 RetrieveScopeChain(scope);
120 } 119 }
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 DCHECK((beg_pos >= 0 && end_pos >= 0) || inner_scope->is_hidden()); 855 DCHECK((beg_pos >= 0 && end_pos >= 0) || inner_scope->is_hidden());
857 if (beg_pos <= position && position < end_pos) { 856 if (beg_pos <= position && position < end_pos) {
858 GetNestedScopeChain(isolate, inner_scope, position); 857 GetNestedScopeChain(isolate, inner_scope, position);
859 return; 858 return;
860 } 859 }
861 } 860 }
862 } 861 }
863 862
864 } // namespace internal 863 } // namespace internal
865 } // namespace v8 864 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698