Commit 1ef7fcad authored by Wiktor Garbacz's avatar Wiktor Garbacz Committed by Commit Bot

Make isolate explicit param of DeclarationScope

A step towards removing isolate from ParseInfo.
Removing isolate from ParseInfo will make it easier to create and
execute parse tasks on background threads.

BUG=v8:6093

Change-Id: Iefd2fd01a700509f05d6f1a272cfa39cc545d39b
Reviewed-on: https://chromium-review.googlesource.com/458001Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarDaniel Vogelheim <vogelheim@chromium.org>
Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Commit-Queue: Wiktor Garbacz <wiktorg@google.com>
Cr-Commit-Position: refs/heads/master@{#44096}
parent 0cfd2feb
...@@ -619,8 +619,9 @@ void DeclarationScope::HoistSloppyBlockFunctions(AstNodeFactory* factory) { ...@@ -619,8 +619,9 @@ void DeclarationScope::HoistSloppyBlockFunctions(AstNodeFactory* factory) {
} }
} }
void DeclarationScope::Analyze(ParseInfo* info, AnalyzeMode mode) { void DeclarationScope::Analyze(ParseInfo* info, Isolate* isolate,
RuntimeCallTimerScope runtimeTimer(info->isolate(), AnalyzeMode mode) {
RuntimeCallTimerScope runtimeTimer(isolate,
&RuntimeCallStats::CompileScopeAnalysis); &RuntimeCallStats::CompileScopeAnalysis);
DCHECK(info->literal() != NULL); DCHECK(info->literal() != NULL);
DeclarationScope* scope = info->literal()->scope(); DeclarationScope* scope = info->literal()->scope();
...@@ -667,13 +668,12 @@ void DeclarationScope::Analyze(ParseInfo* info, AnalyzeMode mode) { ...@@ -667,13 +668,12 @@ void DeclarationScope::Analyze(ParseInfo* info, AnalyzeMode mode) {
info->preparsed_scope_data()->RestoreData(scope); info->preparsed_scope_data()->RestoreData(scope);
} }
scope->AllocateVariables(info, mode); scope->AllocateVariables(info, isolate, mode);
// Ensuring that the outer script scope has a scope info avoids having // Ensuring that the outer script scope has a scope info avoids having
// special case for native contexts vs other contexts. // special case for native contexts vs other contexts.
if (info->script_scope()->scope_info_.is_null()) { if (info->script_scope()->scope_info_.is_null()) {
info->script_scope()->scope_info_ = info->script_scope()->scope_info_ = handle(ScopeInfo::Empty(isolate));
handle(ScopeInfo::Empty(info->isolate()));
} }
#ifdef DEBUG #ifdef DEBUG
...@@ -1328,7 +1328,8 @@ Declaration* Scope::CheckLexDeclarationsConflictingWith( ...@@ -1328,7 +1328,8 @@ Declaration* Scope::CheckLexDeclarationsConflictingWith(
return nullptr; return nullptr;
} }
void DeclarationScope::AllocateVariables(ParseInfo* info, AnalyzeMode mode) { void DeclarationScope::AllocateVariables(ParseInfo* info, Isolate* isolate,
AnalyzeMode mode) {
// Module variables must be allocated before variable resolution // Module variables must be allocated before variable resolution
// to ensure that AccessNeedsHoleCheck() can detect import variables. // to ensure that AccessNeedsHoleCheck() can detect import variables.
if (is_module_scope()) AsModuleScope()->AllocateModuleVariables(); if (is_module_scope()) AsModuleScope()->AllocateModuleVariables();
...@@ -1339,16 +1340,16 @@ void DeclarationScope::AllocateVariables(ParseInfo* info, AnalyzeMode mode) { ...@@ -1339,16 +1340,16 @@ void DeclarationScope::AllocateVariables(ParseInfo* info, AnalyzeMode mode) {
MaybeHandle<ScopeInfo> outer_scope; MaybeHandle<ScopeInfo> outer_scope;
if (outer_scope_ != nullptr) outer_scope = outer_scope_->scope_info_; if (outer_scope_ != nullptr) outer_scope = outer_scope_->scope_info_;
AllocateScopeInfosRecursively(info->isolate(), outer_scope); AllocateScopeInfosRecursively(isolate, outer_scope);
if (mode == AnalyzeMode::kDebugger) { if (mode == AnalyzeMode::kDebugger) {
AllocateDebuggerScopeInfos(info->isolate(), outer_scope); AllocateDebuggerScopeInfos(isolate, outer_scope);
} }
// The debugger expects all shared function infos to contain a scope info. // The debugger expects all shared function infos to contain a scope info.
// Since the top-most scope will end up in a shared function info, make sure // Since the top-most scope will end up in a shared function info, make sure
// it has one, even if it doesn't need a scope info. // it has one, even if it doesn't need a scope info.
// TODO(jochen|yangguo): Remove this requirement. // TODO(jochen|yangguo): Remove this requirement.
if (scope_info_.is_null()) { if (scope_info_.is_null()) {
scope_info_ = ScopeInfo::Create(info->isolate(), zone(), this, outer_scope); scope_info_ = ScopeInfo::Create(isolate, zone(), this, outer_scope);
} }
} }
......
...@@ -836,7 +836,7 @@ class V8_EXPORT_PRIVATE DeclarationScope : public Scope { ...@@ -836,7 +836,7 @@ class V8_EXPORT_PRIVATE DeclarationScope : public Scope {
// Compute top scope and allocate variables. For lazy compilation the top // Compute top scope and allocate variables. For lazy compilation the top
// scope only contains the single lazily compiled function, so this // scope only contains the single lazily compiled function, so this
// doesn't re-allocate variables repeatedly. // doesn't re-allocate variables repeatedly.
static void Analyze(ParseInfo* info, AnalyzeMode mode); static void Analyze(ParseInfo* info, Isolate* isolate, AnalyzeMode mode);
// To be called during parsing. Do just enough scope analysis that we can // To be called during parsing. Do just enough scope analysis that we can
// discard the Scope for lazily compiled functions. In particular, this // discard the Scope for lazily compiled functions. In particular, this
...@@ -889,7 +889,7 @@ class V8_EXPORT_PRIVATE DeclarationScope : public Scope { ...@@ -889,7 +889,7 @@ class V8_EXPORT_PRIVATE DeclarationScope : public Scope {
// In the case of code compiled and run using 'eval', the context // In the case of code compiled and run using 'eval', the context
// parameter is the context in which eval was called. In all other // parameter is the context in which eval was called. In all other
// cases the context parameter is an empty handle. // cases the context parameter is an empty handle.
void AllocateVariables(ParseInfo* info, AnalyzeMode mode); void AllocateVariables(ParseInfo* info, Isolate* isolate, AnalyzeMode mode);
void SetDefaults(); void SetDefaults();
......
...@@ -1277,8 +1277,9 @@ bool Compiler::Analyze(ParseInfo* info, ...@@ -1277,8 +1277,9 @@ bool Compiler::Analyze(ParseInfo* info,
DCHECK_NOT_NULL(info->literal()); DCHECK_NOT_NULL(info->literal());
RuntimeCallTimerScope runtimeTimer(info->runtime_call_stats(), RuntimeCallTimerScope runtimeTimer(info->runtime_call_stats(),
&RuntimeCallStats::CompileAnalyse); &RuntimeCallStats::CompileAnalyse);
Isolate* isolate = info->isolate();
if (!Rewriter::Rewrite(info)) return false; if (!Rewriter::Rewrite(info)) return false;
DeclarationScope::Analyze(info, AnalyzeMode::kRegular); DeclarationScope::Analyze(info, isolate, AnalyzeMode::kRegular);
if (!Renumber(info, eager_literals)) { if (!Renumber(info, eager_literals)) {
return false; return false;
} }
......
...@@ -115,7 +115,7 @@ ScopeIterator::ScopeIterator(Isolate* isolate, FrameInspector* frame_inspector, ...@@ -115,7 +115,7 @@ ScopeIterator::ScopeIterator(Isolate* isolate, FrameInspector* frame_inspector,
CollectNonLocals(info.get(), scope); CollectNonLocals(info.get(), scope);
} }
if (!ignore_nested_scopes) { if (!ignore_nested_scopes) {
DeclarationScope::Analyze(info.get(), AnalyzeMode::kDebugger); DeclarationScope::Analyze(info.get(), isolate_, AnalyzeMode::kDebugger);
RetrieveScopeChain(scope); RetrieveScopeChain(scope);
} }
} else { } else {
......
...@@ -38,7 +38,8 @@ struct TestHelper : public HandleAndZoneScope { ...@@ -38,7 +38,8 @@ struct TestHelper : public HandleAndZoneScope {
CHECK(parsing::ParseFunction(&parse_info)); CHECK(parsing::ParseFunction(&parse_info));
CHECK(Rewriter::Rewrite(&parse_info)); CHECK(Rewriter::Rewrite(&parse_info));
DeclarationScope::Analyze(&parse_info, AnalyzeMode::kRegular); DeclarationScope::Analyze(&parse_info, info.isolate(),
AnalyzeMode::kRegular);
DeclarationScope* scope = info.literal()->scope(); DeclarationScope* scope = info.literal()->scope();
AstValueFactory* factory = parse_info.ast_value_factory(); AstValueFactory* factory = parse_info.ast_value_factory();
......
...@@ -813,7 +813,7 @@ TEST(ScopeUsesArgumentsSuperThis) { ...@@ -813,7 +813,7 @@ TEST(ScopeUsesArgumentsSuperThis) {
info.set_allow_lazy_parsing(false); info.set_allow_lazy_parsing(false);
CHECK(i::parsing::ParseProgram(&info)); CHECK(i::parsing::ParseProgram(&info));
CHECK(i::Rewriter::Rewrite(&info)); CHECK(i::Rewriter::Rewrite(&info));
i::DeclarationScope::Analyze(&info, i::AnalyzeMode::kRegular); i::DeclarationScope::Analyze(&info, isolate, i::AnalyzeMode::kRegular);
CHECK(info.literal() != NULL); CHECK(info.literal() != NULL);
i::DeclarationScope* script_scope = info.literal()->scope(); i::DeclarationScope* script_scope = info.literal()->scope();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment