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

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

Issue 2534393002: Split parsing of functions and top-level code into two separate methods (Closed)
Patch Set: Created 4 years 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/scopes.h" 10 #include "src/ast/scopes.h"
10 #include "src/debug/debug.h" 11 #include "src/debug/debug.h"
11 #include "src/frames-inl.h" 12 #include "src/frames-inl.h"
12 #include "src/globals.h" 13 #include "src/globals.h"
13 #include "src/isolate-inl.h" 14 #include "src/isolate-inl.h"
14 #include "src/parsing/parse-info.h" 15 #include "src/parsing/parse-info.h"
15 #include "src/parsing/parser.h" 16 #include "src/parsing/parsing.h"
16 #include "src/parsing/rewriter.h" 17 #include "src/parsing/rewriter.h"
17 18
18 namespace v8 { 19 namespace v8 {
19 namespace internal { 20 namespace internal {
20 21
21 ScopeIterator::ScopeIterator(Isolate* isolate, FrameInspector* frame_inspector, 22 ScopeIterator::ScopeIterator(Isolate* isolate, FrameInspector* frame_inspector,
22 ScopeIterator::Option option) 23 ScopeIterator::Option option)
23 : isolate_(isolate), 24 : isolate_(isolate),
24 frame_inspector_(frame_inspector), 25 frame_inspector_(frame_inspector),
25 nested_scope_chain_(4), 26 nested_scope_chain_(4),
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 shared_info->start_position(), 82 shared_info->start_position(),
82 shared_info->end_position())); 83 shared_info->end_position()));
83 } 84 }
84 if (!collect_non_locals) return; 85 if (!collect_non_locals) return;
85 } 86 }
86 87
87 // Reparse the code and analyze the scopes. 88 // Reparse the code and analyze the scopes.
88 // Check whether we are in global, eval or function code. 89 // Check whether we are in global, eval or function code.
89 Zone zone(isolate->allocator(), ZONE_NAME); 90 Zone zone(isolate->allocator(), ZONE_NAME);
90 std::unique_ptr<ParseInfo> info; 91 std::unique_ptr<ParseInfo> info;
92 bool successfully_parsed = false;
91 if (scope_info->scope_type() != FUNCTION_SCOPE) { 93 if (scope_info->scope_type() != FUNCTION_SCOPE) {
92 // Global or eval code. 94 // Global or eval code.
93 Handle<Script> script(Script::cast(shared_info->script())); 95 Handle<Script> script(Script::cast(shared_info->script()));
94 info.reset(new ParseInfo(&zone, script)); 96 info.reset(new ParseInfo(&zone, script));
95 if (scope_info->scope_type() == EVAL_SCOPE) { 97 if (scope_info->scope_type() == EVAL_SCOPE) {
96 info->set_eval(); 98 info->set_eval();
97 if (!function->context()->IsNativeContext()) { 99 if (!function->context()->IsNativeContext()) {
98 info->set_outer_scope_info(handle(function->context()->scope_info())); 100 info->set_outer_scope_info(handle(function->context()->scope_info()));
99 } 101 }
100 // Language mode may be inherited from the eval caller. 102 // Language mode may be inherited from the eval caller.
101 // Retrieve it from shared function info. 103 // Retrieve it from shared function info.
102 info->set_language_mode(shared_info->language_mode()); 104 info->set_language_mode(shared_info->language_mode());
103 } else if (scope_info->scope_type() == MODULE_SCOPE) { 105 } else if (scope_info->scope_type() == MODULE_SCOPE) {
104 info->set_module(); 106 info->set_module();
105 } else { 107 } else {
106 DCHECK(scope_info->scope_type() == SCRIPT_SCOPE); 108 DCHECK(scope_info->scope_type() == SCRIPT_SCOPE);
107 } 109 }
110 successfully_parsed = parsing::ParseProgram(info.get());
108 } else { 111 } else {
109 // Inner function. 112 // Inner function.
110 info.reset(new ParseInfo(&zone, shared_info)); 113 info.reset(new ParseInfo(&zone, shared_info));
114 successfully_parsed = parsing::ParseFunction(info.get());
111 } 115 }
112 if (Parser::ParseStatic(info.get()) && Rewriter::Rewrite(info.get())) { 116 if (successfully_parsed && Rewriter::Rewrite(info.get())) {
113 DeclarationScope* scope = info->literal()->scope(); 117 DeclarationScope* scope = info->literal()->scope();
114 if (!ignore_nested_scopes || collect_non_locals) { 118 if (!ignore_nested_scopes || collect_non_locals) {
115 CollectNonLocals(info.get(), scope); 119 CollectNonLocals(info.get(), scope);
116 } 120 }
117 if (!ignore_nested_scopes) { 121 if (!ignore_nested_scopes) {
118 DeclarationScope::Analyze(info.get(), AnalyzeMode::kDebugger); 122 DeclarationScope::Analyze(info.get(), AnalyzeMode::kDebugger);
119 RetrieveScopeChain(scope); 123 RetrieveScopeChain(scope);
120 } 124 }
121 } else { 125 } else {
122 // A failed reparse indicates that the preparser has diverged from the 126 // A failed reparse indicates that the preparser has diverged from the
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 DCHECK((beg_pos >= 0 && end_pos >= 0) || inner_scope->is_hidden()); 860 DCHECK((beg_pos >= 0 && end_pos >= 0) || inner_scope->is_hidden());
857 if (beg_pos <= position && position < end_pos) { 861 if (beg_pos <= position && position < end_pos) {
858 GetNestedScopeChain(isolate, inner_scope, position); 862 GetNestedScopeChain(isolate, inner_scope, position);
859 return; 863 return;
860 } 864 }
861 } 865 }
862 } 866 }
863 867
864 } // namespace internal 868 } // namespace internal
865 } // namespace v8 869 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | src/parsing/parser.h » ('j') | src/parsing/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698