| Index: runtime/vm/isolate.cc
|
| ===================================================================
|
| --- runtime/vm/isolate.cc (revision 42724)
|
| +++ runtime/vm/isolate.cc (working copy)
|
| @@ -97,8 +97,6 @@
|
| #endif
|
| bool IsCurrentIsolate() const;
|
| virtual Isolate* isolate() const { return isolate_; }
|
| - bool UnhandledExceptionCallbackHandler(const Object& message,
|
| - const UnhandledException& error);
|
|
|
| private:
|
| // Keep in sync with isolate_patch.dart.
|
| @@ -117,8 +115,7 @@
|
| // processing of further events.
|
| bool HandleLibMessage(const Array& message);
|
|
|
| - bool ProcessUnhandledException(const Object& message, const Error& result);
|
| - RawFunction* ResolveCallbackFunction();
|
| + bool ProcessUnhandledException(const Error& result);
|
| Isolate* isolate_;
|
| };
|
|
|
| @@ -272,8 +269,7 @@
|
| msg_handler = DartLibraryCalls::LookupHandler(message->dest_port());
|
| if (msg_handler.IsError()) {
|
| delete message;
|
| - return ProcessUnhandledException(Object::null_instance(),
|
| - Error::Cast(msg_handler));
|
| + return ProcessUnhandledException(Error::Cast(msg_handler));
|
| }
|
| if (msg_handler.IsNull()) {
|
| // If the port has been closed then the message will be dropped at this
|
| @@ -293,8 +289,7 @@
|
| if (msg_obj.IsError()) {
|
| // An error occurred while reading the message.
|
| delete message;
|
| - return ProcessUnhandledException(Object::null_instance(),
|
| - Error::Cast(msg_obj));
|
| + return ProcessUnhandledException(Error::Cast(msg_obj));
|
| }
|
| if (!msg_obj.IsNull() && !msg_obj.IsInstance()) {
|
| // TODO(turnidge): We need to decide what an isolate does with
|
| @@ -356,7 +351,7 @@
|
| const Object& result = Object::Handle(I,
|
| DartLibraryCalls::HandleMessage(msg_handler, msg));
|
| if (result.IsError()) {
|
| - success = ProcessUnhandledException(msg, Error::Cast(result));
|
| + success = ProcessUnhandledException(Error::Cast(result));
|
| } else {
|
| ASSERT(result.IsNull());
|
| }
|
| @@ -366,71 +361,6 @@
|
| }
|
|
|
|
|
| -RawFunction* IsolateMessageHandler::ResolveCallbackFunction() {
|
| - ASSERT(I->object_store()->unhandled_exception_handler() != NULL);
|
| - String& callback_name = String::Handle(I);
|
| - if (I->object_store()->unhandled_exception_handler() != String::null()) {
|
| - callback_name = I->object_store()->unhandled_exception_handler();
|
| - } else {
|
| - callback_name = String::New("_unhandledExceptionCallback");
|
| - }
|
| - Library& lib = Library::Handle(I, I->object_store()->isolate_library());
|
| - Function& func = Function::Handle(I, lib.LookupLocalFunction(callback_name));
|
| - if (func.IsNull()) {
|
| - lib = I->object_store()->root_library();
|
| - // Note: bootstrap code in builtin library may attempt to resolve a
|
| - // callback function before the script is fully loaded, in which case
|
| - // the root library may not be registered yet.
|
| - if (!lib.IsNull()) {
|
| - func = lib.LookupLocalFunction(callback_name);
|
| - }
|
| - }
|
| - return func.raw();
|
| -}
|
| -
|
| -
|
| -bool IsolateMessageHandler::UnhandledExceptionCallbackHandler(
|
| - const Object& message, const UnhandledException& error) {
|
| - const Instance& cause = Instance::Handle(I, error.exception());
|
| - const Instance& stacktrace = Instance::Handle(I, error.stacktrace());
|
| -
|
| - // Wrap these args into an IsolateUncaughtException object.
|
| - const Array& exception_args = Array::Handle(I, Array::New(3));
|
| - exception_args.SetAt(0, message);
|
| - exception_args.SetAt(1, cause);
|
| - exception_args.SetAt(2, stacktrace);
|
| - const Object& exception = Object::Handle(I,
|
| - Exceptions::Create(Exceptions::kIsolateUnhandledException,
|
| - exception_args));
|
| - if (exception.IsError()) {
|
| - return false;
|
| - }
|
| - ASSERT(exception.IsInstance());
|
| -
|
| - // Invoke script's callback function.
|
| - Object& function = Object::Handle(I, ResolveCallbackFunction());
|
| - if (function.IsNull() || function.IsError()) {
|
| - return false;
|
| - }
|
| - const Array& callback_args = Array::Handle(I, Array::New(1));
|
| - callback_args.SetAt(0, exception);
|
| - const Object& result = Object::Handle(I,
|
| - DartEntry::InvokeFunction(Function::Cast(function), callback_args));
|
| - if (result.IsError()) {
|
| - const Error& err = Error::Cast(result);
|
| - OS::PrintErr("failed calling unhandled exception callback: %s\n",
|
| - err.ToErrorCString());
|
| - return false;
|
| - }
|
| -
|
| - ASSERT(result.IsBool());
|
| - bool continue_from_exception = Bool::Cast(result).value();
|
| - if (continue_from_exception) {
|
| - I->object_store()->clear_sticky_error();
|
| - }
|
| - return continue_from_exception;
|
| -}
|
| -
|
| #if defined(DEBUG)
|
| void IsolateMessageHandler::CheckAccess() {
|
| ASSERT(IsCurrentIsolate());
|
| @@ -443,10 +373,10 @@
|
| }
|
|
|
|
|
| -bool IsolateMessageHandler::ProcessUnhandledException(
|
| - const Object& message, const Error& result) {
|
| +bool IsolateMessageHandler::ProcessUnhandledException(const Error& result) {
|
| + // Notify the debugger about specific unhandled exceptions which are withheld
|
| + // when being thrown.
|
| if (result.IsUnhandledException()) {
|
| - // Invoke the isolate's uncaught exception handler, if it exists.
|
| const UnhandledException& error = UnhandledException::Cast(result);
|
| RawInstance* exception = error.exception();
|
| if ((exception == I->object_store()->out_of_memory()) ||
|
| @@ -454,12 +384,6 @@
|
| // We didn't notify the debugger when the stack was full. Do it now.
|
| I->debugger()->SignalExceptionThrown(Instance::Handle(exception));
|
| }
|
| - if ((exception != I->object_store()->out_of_memory()) &&
|
| - (exception != I->object_store()->stack_overflow())) {
|
| - if (UnhandledExceptionCallbackHandler(message, error)) {
|
| - return true;
|
| - }
|
| - }
|
| }
|
|
|
| // Invoke the isolate's unhandled exception callback if there is one.
|
| @@ -929,12 +853,6 @@
|
| return false;
|
| }
|
|
|
| - // Set up specific unhandled exception handler.
|
| - const String& callback_name = String::Handle(
|
| - isolate, String::New(state->exception_callback_name()));
|
| - isolate->object_store()->
|
| - set_unhandled_exception_handler(callback_name);
|
| -
|
| Object& result = Object::Handle();
|
| result = state->ResolveFunction();
|
| bool is_spawn_uri = state->is_spawn_uri();
|
| @@ -1551,7 +1469,6 @@
|
| library_url_(NULL),
|
| class_name_(NULL),
|
| function_name_(NULL),
|
| - exception_callback_name_(NULL),
|
| serialized_args_(NULL),
|
| serialized_args_len_(0),
|
| serialized_message_(NULL),
|
| @@ -1569,7 +1486,6 @@
|
| const String& class_name = String::Handle(cls.Name());
|
| class_name_ = strdup(class_name.ToCString());
|
| }
|
| - exception_callback_name_ = strdup("_unhandledExceptionCallback");
|
| SerializeObject(message, &serialized_message_, &serialized_message_len_);
|
| }
|
|
|
| @@ -1586,7 +1502,6 @@
|
| library_url_(NULL),
|
| class_name_(NULL),
|
| function_name_(NULL),
|
| - exception_callback_name_(NULL),
|
| serialized_args_(NULL),
|
| serialized_args_len_(0),
|
| serialized_message_(NULL),
|
| @@ -1598,7 +1513,6 @@
|
| }
|
| library_url_ = NULL;
|
| function_name_ = strdup("main");
|
| - exception_callback_name_ = strdup("_unhandledExceptionCallback");
|
| SerializeObject(args, &serialized_args_, &serialized_args_len_);
|
| SerializeObject(message, &serialized_message_, &serialized_message_len_);
|
| }
|
| @@ -1610,7 +1524,6 @@
|
| free(library_url_);
|
| free(function_name_);
|
| free(class_name_);
|
| - free(exception_callback_name_);
|
| free(serialized_args_);
|
| free(serialized_message_);
|
| }
|
|
|