Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1108)

Unified Diff: src/parsing/parser.cc

Issue 2399833002: Teach Scopes whether they will end up being lazily compiled or not (Closed)
Patch Set: rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parsing/parse-info.h ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index 0ae1fb619a70ff1aa8bf224fa5a613ec99ebcea4..6b21a6fe50009f62dc674e1f3b98af87d6bb44d7 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -284,8 +284,7 @@ FunctionLiteral* Parser::DefaultConstructor(const AstRawString* name,
name, function_scope, body, materialized_literal_count,
expected_property_count, parameter_count,
FunctionLiteral::kNoDuplicateParameters,
- FunctionLiteral::kAnonymousExpression,
- FunctionLiteral::kShouldLazyCompile, pos);
+ FunctionLiteral::kAnonymousExpression, default_eager_compile_hint(), pos);
function_literal->set_requires_class_field_init(requires_class_field_init);
@@ -646,6 +645,27 @@ Parser::Parser(ParseInfo* info)
// ParseInfo during background parsing.
DCHECK(!info->script().is_null() || info->source_stream() != nullptr ||
info->character_stream() != nullptr);
+ // Determine if functions can be lazily compiled. This is necessary to
+ // allow some of our builtin JS files to be lazily compiled. These
+ // builtins cannot be handled lazily by the parser, since we have to know
+ // if a function uses the special natives syntax, which is something the
+ // parser records.
+ // If the debugger requests compilation for break points, we cannot be
+ // aggressive about lazy compilation, because it might trigger compilation
+ // of functions without an outer context when setting a breakpoint through
+ // Debug::FindSharedFunctionInfoInScript
+ bool can_compile_lazily = FLAG_lazy && !info->is_debug();
+
+ // Consider compiling eagerly when targeting the code cache.
+ can_compile_lazily &= !(FLAG_serialize_eager && info->will_serialize());
+
+ // Consider compiling eagerly when compiling bytecode for Ignition.
+ can_compile_lazily &= !(FLAG_ignition && FLAG_ignition_eager &&
+ info->isolate()->serializer_enabled());
+
+ set_default_eager_compile_hint(can_compile_lazily
+ ? FunctionLiteral::kShouldLazyCompile
+ : FunctionLiteral::kShouldEagerCompile);
set_allow_lazy(FLAG_lazy && info->allow_lazy_parsing() &&
!info->is_native() && info->extension() == nullptr);
set_allow_natives(FLAG_allow_natives_syntax || info->is_native());
@@ -2566,7 +2586,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
FunctionLiteral::EagerCompileHint eager_compile_hint =
function_state_->next_function_is_parenthesized()
? FunctionLiteral::kShouldEagerCompile
- : FunctionLiteral::kShouldLazyCompile;
+ : default_eager_compile_hint();
// Determine if the function can be parsed lazily. Lazy parsing is
// different from lazy compilation; we need to parse more eagerly than we
« no previous file with comments | « src/parsing/parse-info.h ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698