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

Side by Side Diff: src/parsing/parser.cc

Issue 2198043002: Add a mode to completely deserialize scope chains (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/parsing/parser.h" 5 #include "src/parsing/parser.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/ast/ast.h" 10 #include "src/ast/ast.h"
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 Mode parsing_mode = FLAG_lazy && allow_lazy() ? PARSE_LAZILY : PARSE_EAGERLY; 940 Mode parsing_mode = FLAG_lazy && allow_lazy() ? PARSE_LAZILY : PARSE_EAGERLY;
941 if (allow_natives() || extension_ != NULL) parsing_mode = PARSE_EAGERLY; 941 if (allow_natives() || extension_ != NULL) parsing_mode = PARSE_EAGERLY;
942 942
943 FunctionLiteral* result = NULL; 943 FunctionLiteral* result = NULL;
944 { 944 {
945 // TODO(wingo): Add an outer SCRIPT_SCOPE corresponding to the native 945 // TODO(wingo): Add an outer SCRIPT_SCOPE corresponding to the native
946 // context, which will have the "this" binding for script scopes. 946 // context, which will have the "this" binding for script scopes.
947 Scope* scope = NewScriptScope(); 947 Scope* scope = NewScriptScope();
948 info->set_script_scope(scope); 948 info->set_script_scope(scope);
949 if (!info->context().is_null() && !info->context()->IsNativeContext()) { 949 if (!info->context().is_null() && !info->context()->IsNativeContext()) {
950 scope = Scope::DeserializeScopeChain(info->isolate(), zone(), 950 scope = Scope::DeserializeScopeChain(
951 *info->context(), scope, 951 info->isolate(), zone(), *info->context(), scope, ast_value_factory(),
952 ast_value_factory()); 952 Scope::DeserializationMode::kKeepScopeInfo);
953 // The Scope is backed up by ScopeInfo (which is in the V8 heap); this 953 // The Scope is backed up by ScopeInfo (which is in the V8 heap); this
954 // means the Parser cannot operate independent of the V8 heap. Tell the 954 // means the Parser cannot operate independent of the V8 heap. Tell the
955 // string table to internalize strings and values right after they're 955 // string table to internalize strings and values right after they're
956 // created. This kind of parsing can only be done in the main thread. 956 // created. This kind of parsing can only be done in the main thread.
957 DCHECK(parsing_on_main_thread_); 957 DCHECK(parsing_on_main_thread_);
958 ast_value_factory()->Internalize(info->isolate()); 958 ast_value_factory()->Internalize(info->isolate());
959 } 959 }
960 original_scope_ = scope; 960 original_scope_ = scope;
961 if (info->is_eval()) { 961 if (info->is_eval()) {
962 if (!scope->is_script_scope() || is_strict(info->language_mode())) { 962 if (!scope->is_script_scope() || is_strict(info->language_mode())) {
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 FunctionLiteral* result = nullptr; 1109 FunctionLiteral* result = nullptr;
1110 1110
1111 { 1111 {
1112 // Parse the function literal. 1112 // Parse the function literal.
1113 Scope* scope = NewScriptScope(); 1113 Scope* scope = NewScriptScope();
1114 info->set_script_scope(scope); 1114 info->set_script_scope(scope);
1115 if (!info->context().is_null()) { 1115 if (!info->context().is_null()) {
1116 // Ok to use Isolate here, since lazy function parsing is only done in the 1116 // Ok to use Isolate here, since lazy function parsing is only done in the
1117 // main thread. 1117 // main thread.
1118 DCHECK(parsing_on_main_thread_); 1118 DCHECK(parsing_on_main_thread_);
1119 scope = Scope::DeserializeScopeChain(isolate, zone(), *info->context(), 1119 scope = Scope::DeserializeScopeChain(
1120 scope, ast_value_factory()); 1120 isolate, zone(), *info->context(), scope, ast_value_factory(),
1121 Scope::DeserializationMode::kKeepScopeInfo);
1121 } 1122 }
1122 original_scope_ = scope; 1123 original_scope_ = scope;
1123 FunctionState function_state(&function_state_, &scope_state_, scope, 1124 FunctionState function_state(&function_state_, &scope_state_, scope,
1124 shared_info->kind()); 1125 shared_info->kind());
1125 DCHECK(is_sloppy(scope->language_mode()) || 1126 DCHECK(is_sloppy(scope->language_mode()) ||
1126 is_strict(info->language_mode())); 1127 is_strict(info->language_mode()));
1127 DCHECK(info->language_mode() == shared_info->language_mode()); 1128 DCHECK(info->language_mode() == shared_info->language_mode());
1128 FunctionLiteral::FunctionType function_type = 1129 FunctionLiteral::FunctionType function_type =
1129 ComputeFunctionType(shared_info); 1130 ComputeFunctionType(shared_info);
1130 bool ok = true; 1131 bool ok = true;
(...skipping 5956 matching lines...) Expand 10 before | Expand all | Expand 10 after
7087 node->Print(Isolate::Current()); 7088 node->Print(Isolate::Current());
7088 } 7089 }
7089 #endif // DEBUG 7090 #endif // DEBUG
7090 7091
7091 #undef CHECK_OK 7092 #undef CHECK_OK
7092 #undef CHECK_OK_VOID 7093 #undef CHECK_OK_VOID
7093 #undef CHECK_FAILED 7094 #undef CHECK_FAILED
7094 7095
7095 } // namespace internal 7096 } // namespace internal
7096 } // namespace v8 7097 } // namespace v8
OLDNEW
« src/ast/scopes.cc ('K') | « src/ast/scopes.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698