Skip to content

Commit 7fc9a1a

Browse files
mkustermanncommit-bot@chromium.org
authored andcommitted
[vm/compiler] Remove non-background optizable bit
The background compiler no longer has bailouts due to something that cannot be done on BG compiler and has to be done on mutator (was originally introduced in [0]) All optimizing compilations can happen on the BG thread. Class finalization and other things no longer cause a bailout on BG compiler. If e.g. invalidated field guards cause a compilation to be discarded, it can be retried on BG compiler. [0] https://dart-review.googlesource.com/c/sdk/+/54886 Closes #45136 TEST=Fixes flaky hits of an assertion. Change-Id: I50313dbedf96b8dec205acdb8c1ed5731d00433b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/187901 Reviewed-by: Alexander Aprelev <[email protected]> Commit-Queue: Martin Kustermann <[email protected]>
1 parent 29268ba commit 7fc9a1a

File tree

5 files changed

+7
-35
lines changed

5 files changed

+7
-35
lines changed

runtime/vm/compiler/jit/compiler.cc

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -694,8 +694,6 @@ static ObjectPtr CompileFunctionHelper(CompilationPipeline* pipeline,
694694
intptr_t osr_id) {
695695
ASSERT(!FLAG_precompiled_mode);
696696
ASSERT(!optimized || function.WasCompiled() || function.ForceOptimize());
697-
ASSERT(function.is_background_optimizable() ||
698-
!Compiler::IsBackgroundCompilation());
699697
if (function.ForceOptimize()) optimized = true;
700698
LongJumpScope jump;
701699
if (setjmp(*jump.Set()) == 0) {
@@ -744,18 +742,13 @@ static ObjectPtr CompileFunctionHelper(CompilationPipeline* pipeline,
744742
if (error.ptr() == Object::background_compilation_error().ptr()) {
745743
if (FLAG_trace_compiler) {
746744
THR_Print(
747-
"--> disabling background optimizations for '%s' (will "
748-
"try to re-compile on isolate thread again)\n",
745+
"--> discarding background compilation for '%s' (will "
746+
"try to re-compile again later)\n",
749747
function.ToFullyQualifiedCString());
750748
}
751749

752-
// Ensure we don't attempt to re-compile the function on the
753-
// background compiler.
754-
function.set_is_background_optimizable(false);
755-
756-
// Trigger another optimization soon on the main thread.
757-
function.SetUsageCounter(
758-
optimized ? FLAG_optimization_counter_threshold : 0);
750+
// Trigger another optimization pass soon.
751+
function.SetUsageCounter(FLAG_optimization_counter_threshold - 100);
759752
return Error::null();
760753
} else if (error.IsLanguageError() &&
761754
LanguageError::Cast(error).kind() == Report::kBailout) {
@@ -1171,8 +1164,7 @@ void BackgroundCompiler::Run() {
11711164
// the background queue (unless it was passed to foreground).
11721165
if ((!old.HasOptimizedCode() && old.IsOptimizable()) ||
11731166
FLAG_stress_test_background_compilation) {
1174-
if (old.is_background_optimizable() &&
1175-
Compiler::CanOptimizeFunction(thread, old)) {
1167+
if (Compiler::CanOptimizeFunction(thread, old)) {
11761168
QueueElement* repeat_qelem = new QueueElement(old);
11771169
function_queue()->Add(repeat_qelem);
11781170
}

runtime/vm/object.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8719,7 +8719,6 @@ FunctionPtr Function::New(const FunctionType& signature,
87198719
NOT_IN_PRECOMPILED(result.set_inlining_depth(0));
87208720
NOT_IN_PRECOMPILED(result.set_kernel_offset(0));
87218721
result.set_is_optimizable(is_native ? false : true);
8722-
result.set_is_background_optimizable(is_native ? false : true);
87238722
result.set_is_inlinable(true);
87248723
result.reset_unboxed_parameters_and_return();
87258724
result.SetInstructionsSafe(StubCode::LazyCompile());

runtime/vm/object.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3655,18 +3655,6 @@ class Function : public Object {
36553655
value, untag()->packed_fields_));
36563656
}
36573657

3658-
// Indicates whether this function can be optimized on the background compiler
3659-
// thread.
3660-
bool is_background_optimizable() const {
3661-
return UntaggedFunction::PackedBackgroundOptimizable::decode(
3662-
untag()->packed_fields_);
3663-
}
3664-
3665-
void set_is_background_optimizable(bool value) const {
3666-
set_packed_fields(UntaggedFunction::PackedBackgroundOptimizable::update(
3667-
value, untag()->packed_fields_));
3668-
}
3669-
36703658
enum KindTagBits {
36713659
kKindTagPos = 0,
36723660
kKindTagSize = 5,

runtime/vm/raw_object.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,21 +1148,15 @@ class UntaggedFunction : public UntaggedObject {
11481148
// TODO(regis): Split packed_fields_ in 2 uint32_t if max values are too low.
11491149

11501150
static constexpr intptr_t kMaxOptimizableBits = 1;
1151-
static constexpr intptr_t kMaxBackgroundOptimizableBits = 1;
11521151
static constexpr intptr_t kMaxTypeParametersBits = 7;
11531152
static constexpr intptr_t kMaxHasNamedOptionalParametersBits = 1;
11541153
static constexpr intptr_t kMaxFixedParametersBits = 10;
11551154
static constexpr intptr_t kMaxOptionalParametersBits = 10;
11561155

11571156
typedef BitField<uint32_t, bool, 0, kMaxOptimizableBits> PackedOptimizable;
1158-
typedef BitField<uint32_t,
1159-
bool,
1160-
PackedOptimizable::kNextBit,
1161-
kMaxBackgroundOptimizableBits>
1162-
PackedBackgroundOptimizable;
11631157
typedef BitField<uint32_t,
11641158
uint8_t,
1165-
PackedBackgroundOptimizable::kNextBit,
1159+
PackedOptimizable::kNextBit,
11661160
kMaxTypeParametersBits>
11671161
PackedNumTypeParameters;
11681162
typedef BitField<uint32_t,

runtime/vm/runtime_entry.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2775,8 +2775,7 @@ DEFINE_RUNTIME_ENTRY(OptimizeInvokedFunction, 1) {
27752775
if (Compiler::CanOptimizeFunction(thread, function)) {
27762776
auto isolate_group = thread->isolate_group();
27772777
if (FLAG_background_compilation) {
2778-
if (function.is_background_optimizable() &&
2779-
isolate_group->background_compiler()->EnqueueCompilation(function)) {
2778+
if (isolate_group->background_compiler()->EnqueueCompilation(function)) {
27802779
// Reduce the chance of triggering a compilation while the function is
27812780
// being compiled in the background. INT32_MIN should ensure that it
27822781
// takes long time to trigger a compilation.

0 commit comments

Comments
 (0)