diff --git a/runtime/lib/isolate.cc b/runtime/lib/isolate.cc index 2075d8b3ed5..577911646d0 100644 --- a/runtime/lib/isolate.cc +++ b/runtime/lib/isolate.cc @@ -1116,11 +1116,8 @@ DEFINE_NATIVE_ENTRY(Isolate_registerKernelBlob, 0, 1) { arguments->NativeArgAt(0)); auto register_kernel_blob_callback = Isolate::RegisterKernelBlobCallback(); if (register_kernel_blob_callback == nullptr) { - const auto& error = - String::Handle(zone, String::New("Registration of kernel blobs is not " - "supported by this Dart embedder.\n")); - Exceptions::ThrowArgumentError(error); - UNREACHABLE(); + Exceptions::ThrowUnsupportedError( + "Registration of kernel blobs is not supported by this Dart embedder."); } bool is_kernel = false; { @@ -1143,10 +1140,7 @@ DEFINE_NATIVE_ENTRY(Isolate_registerKernelBlob, 0, 1) { kernel_blob.LengthInBytes()); } if (uri == nullptr) { - const Instance& exception = Instance::Handle( - thread->isolate_group()->object_store()->out_of_memory()); - Exceptions::Throw(thread, exception); - UNREACHABLE(); + Exceptions::ThrowOOM(); } return String::New(uri); } @@ -1157,11 +1151,8 @@ DEFINE_NATIVE_ENTRY(Isolate_unregisterKernelBlob, 0, 1) { auto unregister_kernel_blob_callback = Isolate::UnregisterKernelBlobCallback(); if (unregister_kernel_blob_callback == nullptr) { - const auto& error = - String::Handle(zone, String::New("Registration of kernel blobs is not " - "supported by this Dart embedder.\n")); - Exceptions::ThrowArgumentError(error); - UNREACHABLE(); + Exceptions::ThrowUnsupportedError( + "Registration of kernel blobs is not supported by this Dart embedder."); } unregister_kernel_blob_callback(kernel_blob_uri.ToCString()); return Object::null(); diff --git a/runtime/vm/runtime_entry.cc b/runtime/vm/runtime_entry.cc index 797e265672f..caeae9bfeac 100644 --- a/runtime/vm/runtime_entry.cc +++ b/runtime/vm/runtime_entry.cc @@ -356,9 +356,7 @@ DEFINE_RUNTIME_ENTRY(AllocateArray, 2) { Array::kMaxElements); } if (len > Array::kMaxElements) { - const Instance& exception = Instance::Handle( - zone, thread->isolate_group()->object_store()->out_of_memory()); - Exceptions::Throw(thread, exception); + Exceptions::ThrowOOM(); } const Array& array = Array::Handle( @@ -432,9 +430,7 @@ DEFINE_RUNTIME_ENTRY(AllocateTypedData, 2) { if (len < 0) { Exceptions::ThrowRangeError("length", Integer::Cast(length), 0, max); } else if (len > max) { - const Instance& exception = Instance::Handle( - zone, thread->isolate_group()->object_store()->out_of_memory()); - Exceptions::Throw(thread, exception); + Exceptions::ThrowOOM(); } const auto& typed_data = TypedData::Handle(zone, TypedData::New(cid, static_cast(len)));