[vm] Fix notifications of code observers from background compiler

This CL fixes crash in vm/cc/DartAPI_DartInitializeCallsCodeObserver
test after kernel service is switched to bytecode (so background
compilations are more likely to happen).

Change-Id: Idfc97f16f8658c953628ba0a878b1d6dd2d46186
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113134
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
Alexander Markov 2019-08-15 16:45:10 +00:00 committed by commit-bot@chromium.org
parent 802937e5a6
commit b60def0de4
2 changed files with 4 additions and 1 deletions

View file

@ -15053,6 +15053,7 @@ void Code::NotifyCodeObservers(const Function& function,
const Code& code,
bool optimized) {
#if !defined(PRODUCT)
ASSERT(!function.IsNull());
ASSERT(!Thread::Current()->IsAtSafepoint());
// Calling ToLibNamePrefixedQualifiedCString is very expensive,
// try to avoid it.
@ -15067,6 +15068,8 @@ void Code::NotifyCodeObservers(const char* name,
const Code& code,
bool optimized) {
#if !defined(PRODUCT)
ASSERT(name != nullptr);
ASSERT(!code.IsNull());
ASSERT(!Thread::Current()->IsAtSafepoint());
if (CodeObservers::AreActive()) {
const auto& instrs = Instructions::Handle(code.instructions());

View file

@ -210,7 +210,7 @@ RawCode* StubCode::GetAllocationStubForClass(const Class& cls) {
// We notify code observers after finalizing the code in order to be
// outside a [SafepointOperationScope].
Code::NotifyCodeObservers(nullptr, stub, /*optimized=*/false);
Code::NotifyCodeObservers(name, stub, /*optimized=*/false);
}
#ifndef PRODUCT
if (FLAG_support_disassembler && FLAG_disassemble_stubs) {