From 85e41a88e58821aec10d97a5a30c4dfe3afb65c9 Mon Sep 17 00:00:00 2001 From: machenbach Date: Fri, 5 Aug 2016 05:35:04 -0700 Subject: [PATCH] Revert of Remove redundant ParseInfo::scope_. (patchset #4 id:60001 of https://codereview.chromium.org/2216563003/ ) Reason for revert: Reverting to revert https://codereview.chromium.org/2209573002 Original issue's description: > Remove redundant ParseInfo::scope_. > > This was always set to the literal's scope. > > (Additional change: mark getters as const.) > > R=adamk@chromium.org > BUG= > > Committed: https://crrev.com/23ea0782977ed3a4dd113462af9ecbfd6ff0ce94 > Cr-Commit-Position: refs/heads/master@{#38372} TBR=adamk@chromium.org,marja@chromium.org,neis@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG= Review-Url: https://codereview.chromium.org/2222503002 Cr-Commit-Position: refs/heads/master@{#38379} --- src/ast/scopes.cc | 2 ++ src/compiler.cc | 1 + src/parsing/parser.cc | 3 ++- src/parsing/parser.h | 48 +++++++++++++++++++++---------------------- 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc index 5211e082e0..f272931b92 100644 --- a/src/ast/scopes.cc +++ b/src/ast/scopes.cc @@ -368,6 +368,7 @@ int Scope::num_parameters() const { bool Scope::Analyze(ParseInfo* info) { DCHECK(info->literal() != NULL); + DCHECK(info->scope() == NULL); DeclarationScope* scope = info->literal()->scope(); DeclarationScope* top = scope; @@ -395,6 +396,7 @@ bool Scope::Analyze(ParseInfo* info) { scope->CheckZones(); #endif + info->set_scope(scope); return true; } diff --git a/src/compiler.cc b/src/compiler.cc index f5fc155c5f..d9b55667bd 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -1778,6 +1778,7 @@ Handle Compiler::GetSharedFunctionInfo( CompilationInfo info(&parse_info, Handle::null()); parse_info.set_literal(literal); parse_info.set_shared_info(result); + parse_info.set_scope(literal->scope()); parse_info.set_language_mode(literal->scope()->language_mode()); if (outer_info->will_serialize()) info.PrepareForSerializing(); if (outer_info->is_debug()) info.MarkAsDebug(); diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc index ecdcad4d3d..b2e78281cf 100644 --- a/src/parsing/parser.cc +++ b/src/parsing/parser.cc @@ -58,7 +58,8 @@ ParseInfo::ParseInfo(Zone* zone) isolate_(nullptr), cached_data_(nullptr), ast_value_factory_(nullptr), - literal_(nullptr) {} + literal_(nullptr), + scope_(nullptr) {} ParseInfo::ParseInfo(Zone* zone, Handle function) : ParseInfo(zone, Handle(function->shared())) { diff --git a/src/parsing/parser.h b/src/parsing/parser.h index 2fef73d060..022ca03994 100644 --- a/src/parsing/parser.h +++ b/src/parsing/parser.h @@ -40,7 +40,7 @@ class ParseInfo { ast_value_factory_ = nullptr; } - Zone* zone() const { return zone_; } + Zone* zone() { return zone_; } // Convenience accessor methods for flags. #define FLAG_ACCESSOR(flag, getter, setter) \ @@ -73,14 +73,14 @@ class ParseInfo { : NO_PARSE_RESTRICTION; } - ScriptCompiler::ExternalSourceStream* source_stream() const { + ScriptCompiler::ExternalSourceStream* source_stream() { return source_stream_; } void set_source_stream(ScriptCompiler::ExternalSourceStream* source_stream) { source_stream_ = source_stream; } - ScriptCompiler::StreamedSource::Encoding source_stream_encoding() const { + ScriptCompiler::StreamedSource::Encoding source_stream_encoding() { return source_stream_encoding_; } void set_source_stream_encoding( @@ -93,43 +93,42 @@ class ParseInfo { character_stream_ = character_stream; } - v8::Extension* extension() const { return extension_; } + v8::Extension* extension() { return extension_; } void set_extension(v8::Extension* extension) { extension_ = extension; } - ScriptData** cached_data() const { return cached_data_; } + ScriptData** cached_data() { return cached_data_; } void set_cached_data(ScriptData** cached_data) { cached_data_ = cached_data; } - ScriptCompiler::CompileOptions compile_options() const { - return compile_options_; - } + ScriptCompiler::CompileOptions compile_options() { return compile_options_; } void set_compile_options(ScriptCompiler::CompileOptions compile_options) { compile_options_ = compile_options; } - DeclarationScope* script_scope() const { return script_scope_; } + DeclarationScope* script_scope() { return script_scope_; } void set_script_scope(DeclarationScope* script_scope) { script_scope_ = script_scope; } - AstValueFactory* ast_value_factory() const { return ast_value_factory_; } + AstValueFactory* ast_value_factory() { return ast_value_factory_; } void set_ast_value_factory(AstValueFactory* ast_value_factory) { ast_value_factory_ = ast_value_factory; } - FunctionLiteral* literal() const { return literal_; } + FunctionLiteral* literal() { return literal_; } void set_literal(FunctionLiteral* literal) { literal_ = literal; } - DeclarationScope* scope() const { return literal()->scope(); } + DeclarationScope* scope() { return scope_; } + void set_scope(DeclarationScope* scope) { scope_ = scope; } - UnicodeCache* unicode_cache() const { return unicode_cache_; } + UnicodeCache* unicode_cache() { return unicode_cache_; } void set_unicode_cache(UnicodeCache* unicode_cache) { unicode_cache_ = unicode_cache; } - uintptr_t stack_limit() const { return stack_limit_; } + uintptr_t stack_limit() { return stack_limit_; } void set_stack_limit(uintptr_t stack_limit) { stack_limit_ = stack_limit; } - uint32_t hash_seed() const { return hash_seed_; } + uint32_t hash_seed() { return hash_seed_; } void set_hash_seed(uint32_t hash_seed) { hash_seed_ = hash_seed; } int compiler_hints() const { return compiler_hints_; } @@ -155,10 +154,10 @@ class ParseInfo { //-------------------------------------------------------------------------- // TODO(titzer): these should not be part of ParseInfo. //-------------------------------------------------------------------------- - Isolate* isolate() const { return isolate_; } - Handle shared_info() const { return shared_; } - Handle