Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit b10a36b

Browse files
alexmarkovcommit-bot@chromium.org
authored andcommitted
[vm] Set WasCompiled at safepoint
Setting WasCompiled on a function after unoptimized compilation in the background thread could race with other modifications of function tags. To avoid this potential problem, setting of WasCompiled is moved to FinalizeCompilation which is called at safepoint. This is a possible fix for flaky assertion failure ../../runtime/vm/compiler/jit/compiler.cc: 901: error: expected: !optimized || function.WasCompiled() on dartkb/debug bots. Change-Id: Ia38ddf892438be3314e181cd77c8f8d6cf69978d Reviewed-on: https://dart-review.googlesource.com/c/80381 Auto-Submit: Alexander Markov <alexmarkov@google.com> Reviewed-by: Siva Annamalai <asiva@google.com> Commit-Queue: Alexander Markov <alexmarkov@google.com>
1 parent 27b3f0b commit b10a36b

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

runtime/vm/compiler/jit/compiler.cc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@ RawCode* CompileParsedFunctionHelper::FinalizeCompilation(
675675
}
676676
function.set_unoptimized_code(code);
677677
function.AttachCode(code);
678+
function.SetWasCompiled(true);
678679
}
679680
if (parsed_function()->HasDeferredPrefixes()) {
680681
ASSERT(!FLAG_load_deferred_eagerly);
@@ -947,11 +948,7 @@ static RawObject* CompileFunctionHelper(CompilationPipeline* pipeline,
947948

948949
const Code& result = Code::Handle(helper.Compile(pipeline));
949950

950-
if (!result.IsNull()) {
951-
if (!optimized) {
952-
function.SetWasCompiled(true);
953-
}
954-
} else {
951+
if (result.IsNull()) {
955952
if (Compiler::IsBackgroundCompilation()) {
956953
// Try again later, background compilation may abort because of
957954
// state change during compilation.
@@ -1216,7 +1213,8 @@ RawObject* Compiler::CompileOptimizedFunction(Thread* thread,
12161213

12171214
// If running with interpreter, do the unoptimized compilation first.
12181215
const bool optimized = !FLAG_enable_interpreter ||
1219-
(function.unoptimized_code() != Object::null());
1216+
((function.unoptimized_code() != Object::null()) &&
1217+
function.WasCompiled());
12201218

12211219
// If we are in the optimizing in the mutator/Dart thread, then
12221220
// this is either an OSR compilation or background compilation is

0 commit comments

Comments
 (0)