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

Unified 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: gcmole 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 side-by-side diff with in-line comments
Download patch
Index: src/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index 603b6c8a33cc78ddbd753511bf0661fe29536845..bdfa4344c2fa929c4ed71d23502b27e97f854f70 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -942,22 +942,27 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) {
FunctionLiteral* result = NULL;
{
- // TODO(wingo): Add an outer SCRIPT_SCOPE corresponding to the native
- // context, which will have the "this" binding for script scopes.
- Scope* scope = NewScriptScope();
- info->set_script_scope(scope);
- if (!info->context().is_null() && !info->context()->IsNativeContext()) {
- scope = Scope::DeserializeScopeChain(info->isolate(), zone(),
- *info->context(), scope,
- ast_value_factory());
- // The Scope is backed up by ScopeInfo (which is in the V8 heap); this
- // means the Parser cannot operate independent of the V8 heap. Tell the
- // string table to internalize strings and values right after they're
- // created. This kind of parsing can only be done in the main thread.
- DCHECK(parsing_on_main_thread_);
- ast_value_factory()->Internalize(info->isolate());
+ Scope* scope;
+ if (info->script_scope()) {
marja 2016/08/03 08:07:48 "script_scope" as a name is very generic, could so
jochen (gone - plz use gerrit) 2016/08/03 09:14:49 well, it's corresponding to the existing set_scrip
+ scope = info->script_scope();
+ } else {
+ // TODO(wingo): Add an outer SCRIPT_SCOPE corresponding to the native
+ // context, which will have the "this" binding for script scopes.
+ scope = NewScriptScope();
+ info->set_script_scope(scope);
+ if (!info->context().is_null() && !info->context()->IsNativeContext()) {
+ scope = Scope::DeserializeScopeChain(
+ info->isolate(), zone(), *info->context(), scope,
+ ast_value_factory(), Scope::DeserializationMode::kKeepScopeInfo);
+ // The Scope is backed up by ScopeInfo (which is in the V8 heap); this
+ // means the Parser cannot operate independent of the V8 heap. Tell the
+ // string table to internalize strings and values right after they're
+ // created. This kind of parsing can only be done in the main thread.
+ DCHECK(parsing_on_main_thread_);
+ ast_value_factory()->Internalize(info->isolate());
+ }
+ original_scope_ = scope;
}
- original_scope_ = scope;
if (info->is_eval()) {
if (!scope->is_script_scope() || is_strict(info->language_mode())) {
parsing_mode = PARSE_EAGERLY;
@@ -1116,8 +1121,9 @@ FunctionLiteral* Parser::ParseLazy(Isolate* isolate, ParseInfo* info,
// Ok to use Isolate here, since lazy function parsing is only done in the
// main thread.
DCHECK(parsing_on_main_thread_);
- scope = Scope::DeserializeScopeChain(isolate, zone(), *info->context(),
- scope, ast_value_factory());
+ scope = Scope::DeserializeScopeChain(
+ isolate, zone(), *info->context(), scope, ast_value_factory(),
+ Scope::DeserializationMode::kKeepScopeInfo);
}
original_scope_ = scope;
FunctionState function_state(&function_state_, &scope_state_, scope,

Powered by Google App Engine
This is Rietveld 408576698