[vm] Ignore compilation errors in CorelibCompileAll

Change-Id: Iffb1a3a191cd8cf9e3ecd13a495a73bda5592dfb
Reviewed-on: https://dart-review.googlesource.com/c/80621
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Auto-Submit: Vyacheslav Egorov <vegorov@google.com>
diff --git a/runtime/vm/benchmark_test.cc b/runtime/vm/benchmark_test.cc
index 254d1b7..c2f3f55 100644
--- a/runtime/vm/benchmark_test.cc
+++ b/runtime/vm/benchmark_test.cc
@@ -101,7 +101,8 @@
   TransitionNativeToVM transition(thread);
   Timer timer(true, "Compile all of Core lib benchmark");
   timer.Start();
-  const Error& error = Error::Handle(Library::CompileAll());
+  const Error& error =
+      Error::Handle(Library::CompileAll(/*ignore_error=*/true));
   if (!error.IsNull()) {
     OS::PrintErr("Unexpected error in CorelibCompileAll benchmark:\n%s",
                  error.ToErrorCString());
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 640e298..0b518cf 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -12464,7 +12464,7 @@
   return result.raw();
 }
 
-RawError* Library::CompileAll() {
+RawError* Library::CompileAll(bool ignore_error /* = false */) {
   Thread* thread = Thread::Current();
   Zone* zone = thread->zone();
   Error& error = Error::Handle(zone);
@@ -12479,10 +12479,12 @@
       cls = it.GetNextClass();
       error = cls.EnsureIsFinalized(thread);
       if (!error.IsNull()) {
+        if (ignore_error) continue;
         return error.raw();
       }
       error = Compiler::CompileAllFunctions(cls);
       if (!error.IsNull()) {
+        if (ignore_error) continue;
         return error.raw();
       }
     }
@@ -12500,6 +12502,7 @@
     if (!func.HasCode()) {
       result = Compiler::CompileFunction(thread, func);
       if (result.IsError()) {
+        if (ignore_error) continue;
         return Error::Cast(result).raw();
       }
     }
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index c0685db..50dfa5e 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -3983,7 +3983,7 @@
   static RawLibrary* VMServiceLibrary();
 
   // Eagerly compile all classes and functions in the library.
-  static RawError* CompileAll();
+  static RawError* CompileAll(bool ignore_error = false);
 #if !defined(DART_PRECOMPILED_RUNTIME)
   // Eagerly read all bytecode.
   static RawError* ReadAllBytecode();