From 96e8fa9cb565e35dbbd0bc2e44163ebc8da8d4bd Mon Sep 17 00:00:00 2001 From: Vyacheslav Egorov Date: Tue, 30 Jun 2020 07:10:56 +0000 Subject: [PATCH] [vm/compiler] Do not notify observers if we failed to create code. CodeObservers don't expect to be notified with `null` code object. Change-Id: I4ebbe021f827faf9e01b5b3c3734470433e14787 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152803 Reviewed-by: Martin Kustermann Commit-Queue: Vyacheslav Egorov --- runtime/vm/compiler/jit/compiler.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/runtime/vm/compiler/jit/compiler.cc b/runtime/vm/compiler/jit/compiler.cc index 70215e26dfb..242e1f150c0 100644 --- a/runtime/vm/compiler/jit/compiler.cc +++ b/runtime/vm/compiler/jit/compiler.cc @@ -658,12 +658,11 @@ CodePtr CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { // thread()->isolate_group()->RunWithStoppedMutators( install_code_fun, install_code_fun, /*use_force_growth=*/true); - - // We notify code observers after finalizing the code in order to be - // outside a [SafepointOperationScope]. - Code::NotifyCodeObservers(function, *result, optimized()); } if (!result->IsNull()) { + // Must be called outside of safepoint. + Code::NotifyCodeObservers(function, *result, optimized()); + #if !defined(PRODUCT) if (!function.HasOptimizedCode()) { isolate()->debugger()->NotifyCompilation(function);