Chromium Code Reviews| 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()) { |
| + scope = info->script_scope(); |
|
Toon Verwaest
2016/08/03 11:54:33
It would be nice if we would only deserialize (off
|
| + } 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( |
|
Toon Verwaest
2016/08/03 11:54:33
You probably wanted to deserialize here. Otherwise
|
| + isolate, zone(), *info->context(), scope, ast_value_factory(), |
| + Scope::DeserializationMode::kKeepScopeInfo); |
| } |
| original_scope_ = scope; |
| FunctionState function_state(&function_state_, &scope_state_, scope, |