Skip to content

Commit 3a82163

Browse files
rmacnak-googlecommit-bot@chromium.org
authored andcommitted
[vm] Fail gracefully when background compilation runs out of memory.
Bug: #42852 Change-Id: I63ba1cb71dd9ad50b583a19ea3a3859c1d667ccc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156042 Reviewed-by: Ben Konyi <[email protected]> Commit-Queue: Ryan Macnak <[email protected]>
1 parent b9205dd commit 3a82163

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

runtime/vm/object.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,9 @@ void Object::Init(Isolate* isolate) {
11251125
error_str = String::New("Background Compilation Failed", Heap::kOld);
11261126
*background_compilation_error_ =
11271127
LanguageError::New(error_str, Report::kBailout, Heap::kOld);
1128+
error_str = String::New("Out of memory", Heap::kOld);
1129+
*out_of_memory_error_ =
1130+
LanguageError::New(error_str, Report::kBailout, Heap::kOld);
11281131

11291132
// Allocate the parameter arrays for method extractor types and names.
11301133
*extractor_parameter_types_ = Array::New(1, Heap::kOld);
@@ -1215,6 +1218,8 @@ void Object::Init(Isolate* isolate) {
12151218
ASSERT(speculative_inlining_error_->IsLanguageError());
12161219
ASSERT(!background_compilation_error_->IsSmi());
12171220
ASSERT(background_compilation_error_->IsLanguageError());
1221+
ASSERT(!out_of_memory_error_->IsSmi());
1222+
ASSERT(out_of_memory_error_->IsLanguageError());
12181223
ASSERT(!vm_isolate_snapshot_object_table_->IsSmi());
12191224
ASSERT(vm_isolate_snapshot_object_table_->IsArray());
12201225
ASSERT(!extractor_parameter_types_->IsSmi());
@@ -2645,8 +2650,11 @@ ObjectPtr Object::Allocate(intptr_t cls_id, intptr_t size, Heap::Space space) {
26452650
Instance::Handle(thread->isolate()->object_store()->out_of_memory());
26462651
Exceptions::Throw(thread, exception);
26472652
UNREACHABLE();
2653+
} else if (thread->long_jump_base() != nullptr) {
2654+
Report::LongJump(Object::out_of_memory_error());
2655+
UNREACHABLE();
26482656
} else {
2649-
// No Dart to propagate an exception to.
2657+
// Nowhere to propagate an exception to.
26502658
OUT_OF_MEMORY();
26512659
}
26522660
}

runtime/vm/object.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ class Object {
449449
V(LanguageError, branch_offset_error) \
450450
V(LanguageError, speculative_inlining_error) \
451451
V(LanguageError, background_compilation_error) \
452+
V(LanguageError, out_of_memory_error) \
452453
V(Array, vm_isolate_snapshot_object_table) \
453454
V(Type, dynamic_type) \
454455
V(Type, void_type) \

0 commit comments

Comments
 (0)