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) {
}
}
void DeclarationScope::Analyze(ParseInfo* info, AnalyzeMode mode) {
RuntimeCallTimerScope runtimeTimer(info->isolate(),
void DeclarationScope::Analyze(ParseInfo* info, Isolate* isolate,
AnalyzeMode mode) {
RuntimeCallTimerScope runtimeTimer(isolate,
&RuntimeCallStats::CompileScopeAnalysis);
DCHECK(info->literal() != NULL);
DeclarationScope* scope = info->literal()->scope();
......@@ -667,13 +668,12 @@ void DeclarationScope::Analyze(ParseInfo* info, AnalyzeMode mode) {
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
// special case for native contexts vs other contexts.
if (info->script_scope()->scope_info_.is_null()) {
info->script_scope()->scope_info_ =
handle(ScopeInfo::Empty(info->isolate()));
info->script_scope()->scope_info_ = handle(ScopeInfo::Empty(isolate));
}
#ifdef DEBUG
......@@ -1328,7 +1328,8 @@ Declaration* Scope::CheckLexDeclarationsConflictingWith(
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
// to ensure that AccessNeedsHoleCheck() can detect import variables.
if (is_module_scope()) AsModuleScope()->AllocateModuleVariables();
......@@ -1339,16 +1340,16 @@ void DeclarationScope::AllocateVariables(ParseInfo* info, AnalyzeMode mode) {
MaybeHandle<ScopeInfo> outer_scope;
if (outer_scope_ != nullptr) outer_scope = outer_scope_->scope_info_;
AllocateScopeInfosRecursively(info->isolate(), outer_scope);
AllocateScopeInfosRecursively(isolate, outer_scope);
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.
// 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.
// TODO(jochen|yangguo): Remove this requirement.
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 {
// Compute top scope and allocate variables. For lazy compilation the top
// scope only contains the single lazily compiled function, so this
// 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
// discard the Scope for lazily compiled functions. In particular, this
......@@ -889,7 +889,7 @@ class V8_EXPORT_PRIVATE DeclarationScope : public Scope {
// In the case of code compiled and run using 'eval', the context
// parameter is the context in which eval was called. In all other
// cases the context parameter is an empty handle.
void AllocateVariables(ParseInfo* info, AnalyzeMode mode);
void AllocateVariables(ParseInfo* info, Isolate* isolate, AnalyzeMode mode);
void SetDefaults();
......
......@@ -1277,8 +1277,9 @@ bool Compiler::Analyze(ParseInfo* info,
DCHECK_NOT_NULL(info->literal());
RuntimeCallTimerScope runtimeTimer(info->runtime_call_stats(),
&RuntimeCallStats::CompileAnalyse);
Isolate* isolate = info->isolate();
if (!Rewriter::Rewrite(info)) return false;
DeclarationScope::Analyze(info, AnalyzeMode::kRegular);
DeclarationScope::Analyze(info, isolate, AnalyzeMode::kRegular);
if (!Renumber(info, eager_literals)) {
return false;
}
......
......@@ -115,7 +115,7 @@ ScopeIterator::ScopeIterator(Isolate* isolate, FrameInspector* frame_inspector,
CollectNonLocals(info.get(), scope);
}
if (!ignore_nested_scopes) {
DeclarationScope::Analyze(info.get(), AnalyzeMode::kDebugger);
DeclarationScope::Analyze(info.get(), isolate_, AnalyzeMode::kDebugger);
RetrieveScopeChain(scope);
}
} else {
......
......@@ -38,7 +38,8 @@ struct TestHelper : public HandleAndZoneScope {
CHECK(parsing::ParseFunction(&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();
AstValueFactory* factory = parse_info.ast_value_factory();
......
......@@ -813,7 +813,7 @@ TEST(ScopeUsesArgumentsSuperThis) {
info.set_allow_lazy_parsing(false);
CHECK(i::parsing::ParseProgram(&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);
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