Commit c48f5fdf authored by Leszek Swirski's avatar Leszek Swirski Committed by V8 LUCI CQ

[parser] Keep track of whether parses are re-parses

Some parses are actually re-parses of an already parsed function; things
like source position collection, CallPrinter AST walks, debugger, etc.

These may want slightly different parse behaviour -- in particular, we
likely don't want to post parallel compile tasks for them. So, keep
track externally of which parses are reparses, and suppress parallel
compile tasks for them.

Change-Id: I8b38caad1a385e08231bd247774e9804a409de0e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3291317Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80895}
parent 33ca2bcb
...@@ -1926,6 +1926,7 @@ bool Compiler::CollectSourcePositions(Isolate* isolate, ...@@ -1926,6 +1926,7 @@ bool Compiler::CollectSourcePositions(Isolate* isolate,
UnoptimizedCompileFlags flags = UnoptimizedCompileFlags flags =
UnoptimizedCompileFlags::ForFunctionCompile(isolate, *shared_info); UnoptimizedCompileFlags::ForFunctionCompile(isolate, *shared_info);
flags.set_collect_source_positions(true); flags.set_collect_source_positions(true);
flags.set_is_reparse(true);
// Prevent parallel tasks from being spawned by this job. // Prevent parallel tasks from being spawned by this job.
flags.set_post_parallel_compile_tasks_for_eager_toplevel(false); flags.set_post_parallel_compile_tasks_for_eager_toplevel(false);
flags.set_post_parallel_compile_tasks_for_lazy(false); flags.set_post_parallel_compile_tasks_for_lazy(false);
......
...@@ -254,6 +254,7 @@ void ScopeIterator::TryParseAndRetrieveScopes(ReparseStrategy strategy) { ...@@ -254,6 +254,7 @@ void ScopeIterator::TryParseAndRetrieveScopes(ReparseStrategy strategy) {
? UnoptimizedCompileFlags::ForFunctionCompile(isolate_, *shared_info) ? UnoptimizedCompileFlags::ForFunctionCompile(isolate_, *shared_info)
: UnoptimizedCompileFlags::ForScriptCompile(isolate_, *script) : UnoptimizedCompileFlags::ForScriptCompile(isolate_, *script)
.set_is_eager(true); .set_is_eager(true);
flags.set_is_reparse(true);
MaybeHandle<ScopeInfo> maybe_outer_scope; MaybeHandle<ScopeInfo> maybe_outer_scope;
if (scope_info->scope_type() == EVAL_SCOPE || script->is_wrapped()) { if (scope_info->scope_type() == EVAL_SCOPE || script->is_wrapped()) {
......
...@@ -1647,6 +1647,7 @@ bool CompileTopLevel(Isolate* isolate, Handle<Script> script) { ...@@ -1647,6 +1647,7 @@ bool CompileTopLevel(Isolate* isolate, Handle<Script> script) {
ReusableUnoptimizedCompileState reusable_state(isolate); ReusableUnoptimizedCompileState reusable_state(isolate);
UnoptimizedCompileFlags flags = UnoptimizedCompileFlags flags =
UnoptimizedCompileFlags::ForScriptCompile(isolate, *script); UnoptimizedCompileFlags::ForScriptCompile(isolate, *script);
flags.set_is_reparse(true);
ParseInfo parse_info(isolate, flags, &compile_state, &reusable_state); ParseInfo parse_info(isolate, flags, &compile_state, &reusable_state);
IsCompiledScope is_compiled_scope; IsCompiledScope is_compiled_scope;
const MaybeHandle<SharedFunctionInfo> maybe_result = const MaybeHandle<SharedFunctionInfo> maybe_result =
......
...@@ -990,6 +990,7 @@ void LiveEdit::PatchScript(Isolate* isolate, Handle<Script> script, ...@@ -990,6 +990,7 @@ void LiveEdit::PatchScript(Isolate* isolate, Handle<Script> script,
UnoptimizedCompileFlags flags = UnoptimizedCompileFlags flags =
UnoptimizedCompileFlags::ForScriptCompile(isolate, *script); UnoptimizedCompileFlags::ForScriptCompile(isolate, *script);
flags.set_is_eager(true); flags.set_is_eager(true);
flags.set_is_reparse(true);
ParseInfo parse_info(isolate, flags, &compile_state, &reusable_state); ParseInfo parse_info(isolate, flags, &compile_state, &reusable_state);
std::vector<FunctionLiteral*> literals; std::vector<FunctionLiteral*> literals;
if (!ParseScript(isolate, script, &parse_info, false, &literals, result)) if (!ParseScript(isolate, script, &parse_info, false, &literals, result))
......
...@@ -776,6 +776,7 @@ Handle<String> RenderCallSite(Isolate* isolate, Handle<Object> object, ...@@ -776,6 +776,7 @@ Handle<String> RenderCallSite(Isolate* isolate, Handle<Object> object,
if (ComputeLocation(isolate, location)) { if (ComputeLocation(isolate, location)) {
UnoptimizedCompileFlags flags = UnoptimizedCompileFlags::ForFunctionCompile( UnoptimizedCompileFlags flags = UnoptimizedCompileFlags::ForFunctionCompile(
isolate, *location->shared()); isolate, *location->shared());
flags.set_is_reparse(true);
UnoptimizedCompileState compile_state; UnoptimizedCompileState compile_state;
ReusableUnoptimizedCompileState reusable_state(isolate); ReusableUnoptimizedCompileState reusable_state(isolate);
ParseInfo info(isolate, flags, &compile_state, &reusable_state); ParseInfo info(isolate, flags, &compile_state, &reusable_state);
...@@ -836,6 +837,7 @@ Object ErrorUtils::ThrowSpreadArgError(Isolate* isolate, MessageTemplate id, ...@@ -836,6 +837,7 @@ Object ErrorUtils::ThrowSpreadArgError(Isolate* isolate, MessageTemplate id,
if (ComputeLocation(isolate, &location)) { if (ComputeLocation(isolate, &location)) {
UnoptimizedCompileFlags flags = UnoptimizedCompileFlags::ForFunctionCompile( UnoptimizedCompileFlags flags = UnoptimizedCompileFlags::ForFunctionCompile(
isolate, *location.shared()); isolate, *location.shared());
flags.set_is_reparse(true);
UnoptimizedCompileState compile_state; UnoptimizedCompileState compile_state;
ReusableUnoptimizedCompileState reusable_state(isolate); ReusableUnoptimizedCompileState reusable_state(isolate);
ParseInfo info(isolate, flags, &compile_state, &reusable_state); ParseInfo info(isolate, flags, &compile_state, &reusable_state);
...@@ -913,6 +915,7 @@ Object ErrorUtils::ThrowLoadFromNullOrUndefined(Isolate* isolate, ...@@ -913,6 +915,7 @@ Object ErrorUtils::ThrowLoadFromNullOrUndefined(Isolate* isolate,
UnoptimizedCompileFlags flags = UnoptimizedCompileFlags::ForFunctionCompile( UnoptimizedCompileFlags flags = UnoptimizedCompileFlags::ForFunctionCompile(
isolate, *location.shared()); isolate, *location.shared());
flags.set_is_reparse(true);
UnoptimizedCompileState compile_state; UnoptimizedCompileState compile_state;
ReusableUnoptimizedCompileState reusable_state(isolate); ReusableUnoptimizedCompileState reusable_state(isolate);
ParseInfo info(isolate, flags, &compile_state, &reusable_state); ParseInfo info(isolate, flags, &compile_state, &reusable_state);
......
...@@ -42,6 +42,7 @@ class Zone; ...@@ -42,6 +42,7 @@ class Zone;
V(is_toplevel, bool, 1, _) \ V(is_toplevel, bool, 1, _) \
V(is_eager, bool, 1, _) \ V(is_eager, bool, 1, _) \
V(is_eval, bool, 1, _) \ V(is_eval, bool, 1, _) \
V(is_reparse, bool, 1, _) \
V(outer_language_mode, LanguageMode, 1, _) \ V(outer_language_mode, LanguageMode, 1, _) \
V(parse_restriction, ParseRestriction, 1, _) \ V(parse_restriction, ParseRestriction, 1, _) \
V(is_module, bool, 1, _) \ V(is_module, bool, 1, _) \
......
...@@ -2705,10 +2705,10 @@ FunctionLiteral* Parser::ParseFunctionLiteral( ...@@ -2705,10 +2705,10 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
can_preparse && info()->dispatcher() && can_preparse && info()->dispatcher() &&
scanner()->stream()->can_be_cloned_for_parallel_access(); scanner()->stream()->can_be_cloned_for_parallel_access();
// If parallel compile tasks are enabled, enable parallel compile for the // If parallel compile tasks are enabled, and this isn't a re-parse, enable
// subset of functions as defined by flags. // parallel compile for the subset of functions as defined by flags.
bool should_post_parallel_task = bool should_post_parallel_task =
can_post_parallel_task && can_post_parallel_task && !flags().is_reparse() &&
((is_eager_top_level_function && ((is_eager_top_level_function &&
flags().post_parallel_compile_tasks_for_eager_toplevel()) || flags().post_parallel_compile_tasks_for_eager_toplevel()) ||
(is_lazy && flags().post_parallel_compile_tasks_for_lazy())); (is_lazy && flags().post_parallel_compile_tasks_for_lazy()));
......
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