Commit 80033652 authored by jochen's avatar jochen Committed by Commit bot

Only create ScopeInfos for eagerly parsed scopes.

If the scope was lazily parsed, the ScopeInfo won't be correct (and we
won't store it in the SharedFunctionInfo).

BUG=chromium:644106
R=marja@chromium.org

Review-Url: https://codereview.chromium.org/2345243002
Cr-Commit-Position: refs/heads/master@{#39495}
parent bb6fa481
......@@ -115,6 +115,7 @@ Scope::Scope(Zone* zone, Scope* outer_scope, ScopeType scope_type)
force_context_allocation_ =
!is_function_scope() && outer_scope->has_forced_context_allocation();
outer_scope_->AddInnerScope(this);
if (outer_scope_->is_lazily_parsed_) is_lazily_parsed_ = true;
}
Scope::Snapshot::Snapshot(Scope* scope)
......@@ -282,6 +283,8 @@ void Scope::SetDefaults() {
force_context_allocation_ = false;
is_declaration_scope_ = false;
is_lazily_parsed_ = false;
}
bool Scope::HasSimpleParameters() {
......@@ -1167,6 +1170,7 @@ void DeclarationScope::AnalyzePartially(DeclarationScope* migrate_to,
PropagateUsageFlagsToScope(migrate_to);
if (scope_uses_super_property_) migrate_to->scope_uses_super_property_ = true;
if (inner_scope_calls_eval_) migrate_to->inner_scope_calls_eval_ = true;
if (is_lazily_parsed_) migrate_to->is_lazily_parsed_ = true;
DCHECK(!force_eager_compilation_);
migrate_to->set_start_position(start_position_);
migrate_to->set_end_position(end_position_);
......@@ -1328,6 +1332,7 @@ void Scope::Print(int n) {
Indent(n1, "// scope uses 'super' property\n");
}
if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n");
if (is_lazily_parsed_) Indent(n1, "// lazily parsed\n");
if (num_stack_slots_ > 0) {
Indent(n1, "// ");
PrintF("%d stack slots\n", num_stack_slots_);
......
......@@ -411,6 +411,10 @@ class Scope: public ZoneObject {
void set_is_debug_evaluate_scope() { is_debug_evaluate_scope_ = true; }
bool is_debug_evaluate_scope() const { return is_debug_evaluate_scope_; }
void set_is_lazily_parsed(bool is_lazily_parsed) {
is_lazily_parsed_ = is_lazily_parsed;
}
protected:
explicit Scope(Zone* zone);
......@@ -437,6 +441,9 @@ class Scope: public ZoneObject {
// should also be invoked after resolution.
bool NeedsScopeInfo() const {
DCHECK(!already_resolved_);
// A lazily parsed scope doesn't contain enough information to create a
// ScopeInfo from it.
if (is_lazily_parsed_) return false;
return NeedsContext() || is_script_scope() || is_function_scope() ||
is_eval_scope() || is_module_scope();
}
......@@ -506,6 +513,8 @@ class Scope: public ZoneObject {
// True if it holds 'var' declarations.
bool is_declaration_scope_ : 1;
bool is_lazily_parsed_ : 1;
// Create a non-local variable with a given name.
// These variables are looked up dynamically at runtime.
Variable* NonLocal(const AstRawString* name, VariableMode mode);
......
......@@ -3148,6 +3148,7 @@ Parser::LazyParsingResult Parser::SkipLazyFunctionBody(
int function_block_pos = position();
DeclarationScope* scope = this->scope()->AsDeclarationScope();
DCHECK(scope->is_function_scope());
scope->set_is_lazily_parsed(true);
if (consume_cached_parse_data() && !cached_parse_data_->rejected()) {
// If we have cached data, we use it to skip parsing the function body. The
// data contains the information we need to construct the lazy function.
......@@ -3178,6 +3179,7 @@ Parser::LazyParsingResult Parser::SkipLazyFunctionBody(
ParseLazyFunctionBodyWithPreParser(&logger, may_abort);
// Return immediately if pre-parser decided to abort parsing.
if (result == PreParser::kPreParseAbort) {
scope->set_is_lazily_parsed(false);
return kLazyParsingAborted;
}
if (result == PreParser::kPreParseStackOverflow) {
......
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