OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/isolate.h" | 5 #include "vm/isolate.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "platform/json.h" | 10 #include "platform/text_buffer.h" |
11 #include "vm/class_finalizer.h" | 11 #include "vm/class_finalizer.h" |
12 #include "vm/code_observers.h" | 12 #include "vm/code_observers.h" |
13 #include "vm/compiler.h" | 13 #include "vm/compiler.h" |
14 #include "vm/compiler_stats.h" | 14 #include "vm/compiler_stats.h" |
15 #include "vm/coverage.h" | 15 #include "vm/coverage.h" |
16 #include "vm/dart_api_message.h" | 16 #include "vm/dart_api_message.h" |
17 #include "vm/dart_api_state.h" | 17 #include "vm/dart_api_state.h" |
18 #include "vm/dart_entry.h" | 18 #include "vm/dart_entry.h" |
19 #include "vm/debugger.h" | 19 #include "vm/debugger.h" |
20 #include "vm/deopt_instructions.h" | 20 #include "vm/deopt_instructions.h" |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 if (result.IsUnhandledException()) { | 624 if (result.IsUnhandledException()) { |
625 const UnhandledException& error = UnhandledException::Cast(result); | 625 const UnhandledException& error = UnhandledException::Cast(result); |
626 RawInstance* exception = error.exception(); | 626 RawInstance* exception = error.exception(); |
627 if ((exception == I->object_store()->out_of_memory()) || | 627 if ((exception == I->object_store()->out_of_memory()) || |
628 (exception == I->object_store()->stack_overflow())) { | 628 (exception == I->object_store()->stack_overflow())) { |
629 // We didn't notify the debugger when the stack was full. Do it now. | 629 // We didn't notify the debugger when the stack was full. Do it now. |
630 I->debugger()->SignalExceptionThrown(Instance::Handle(exception)); | 630 I->debugger()->SignalExceptionThrown(Instance::Handle(exception)); |
631 } | 631 } |
632 } | 632 } |
633 | 633 |
634 // Invoke the isolate's unhandled exception callback if there is one. | |
635 if (Isolate::UnhandledExceptionCallback() != NULL) { | |
636 Dart_EnterScope(); | |
637 Dart_Handle error = Api::NewHandle(T, result.raw()); | |
638 (Isolate::UnhandledExceptionCallback())(error); | |
639 Dart_ExitScope(); | |
640 } | |
641 | |
642 // Generate the error and stacktrace strings for the error message. | 634 // Generate the error and stacktrace strings for the error message. |
643 String& exc_str = String::Handle(T->zone()); | 635 String& exc_str = String::Handle(T->zone()); |
644 String& stacktrace_str = String::Handle(T->zone()); | 636 String& stacktrace_str = String::Handle(T->zone()); |
645 if (result.IsUnhandledException()) { | 637 if (result.IsUnhandledException()) { |
646 Zone* zone = T->zone(); | 638 Zone* zone = T->zone(); |
647 const UnhandledException& uhe = UnhandledException::Cast(result); | 639 const UnhandledException& uhe = UnhandledException::Cast(result); |
648 const Instance& exception = Instance::Handle(zone, uhe.exception()); | 640 const Instance& exception = Instance::Handle(zone, uhe.exception()); |
649 Object& tmp = Object::Handle(zone); | 641 Object& tmp = Object::Handle(zone); |
650 tmp = DartLibraryCalls::ToString(exception); | 642 tmp = DartLibraryCalls::ToString(exception); |
651 if (!tmp.IsString()) { | 643 if (!tmp.IsString()) { |
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1679 } | 1671 } |
1680 #endif | 1672 #endif |
1681 | 1673 |
1682 // TODO(5411455): For now just make sure there are no current isolates | 1674 // TODO(5411455): For now just make sure there are no current isolates |
1683 // as we are shutting down the isolate. | 1675 // as we are shutting down the isolate. |
1684 Thread::ExitIsolate(); | 1676 Thread::ExitIsolate(); |
1685 } | 1677 } |
1686 | 1678 |
1687 | 1679 |
1688 Dart_IsolateCreateCallback Isolate::create_callback_ = NULL; | 1680 Dart_IsolateCreateCallback Isolate::create_callback_ = NULL; |
1689 Dart_IsolateInterruptCallback Isolate::interrupt_callback_ = NULL; | |
1690 Dart_IsolateUnhandledExceptionCallback | |
1691 Isolate::unhandled_exception_callback_ = NULL; | |
1692 Dart_IsolateShutdownCallback Isolate::shutdown_callback_ = NULL; | 1681 Dart_IsolateShutdownCallback Isolate::shutdown_callback_ = NULL; |
1693 Dart_FileOpenCallback Isolate::file_open_callback_ = NULL; | 1682 Dart_FileOpenCallback Isolate::file_open_callback_ = NULL; |
1694 Dart_FileReadCallback Isolate::file_read_callback_ = NULL; | 1683 Dart_FileReadCallback Isolate::file_read_callback_ = NULL; |
1695 Dart_FileWriteCallback Isolate::file_write_callback_ = NULL; | 1684 Dart_FileWriteCallback Isolate::file_write_callback_ = NULL; |
1696 Dart_FileCloseCallback Isolate::file_close_callback_ = NULL; | 1685 Dart_FileCloseCallback Isolate::file_close_callback_ = NULL; |
1697 Dart_EntropySource Isolate::entropy_source_callback_ = NULL; | 1686 Dart_EntropySource Isolate::entropy_source_callback_ = NULL; |
1698 | 1687 |
1699 Monitor* Isolate::isolates_list_monitor_ = NULL; | 1688 Monitor* Isolate::isolates_list_monitor_ = NULL; |
1700 Isolate* Isolate::isolates_list_head_ = NULL; | 1689 Isolate* Isolate::isolates_list_head_ = NULL; |
1701 bool Isolate::creation_enabled_ = false; | 1690 bool Isolate::creation_enabled_ = false; |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2505 } | 2494 } |
2506 | 2495 |
2507 | 2496 |
2508 RawInstance* IsolateSpawnState::BuildMessage(Thread* thread) { | 2497 RawInstance* IsolateSpawnState::BuildMessage(Thread* thread) { |
2509 return DeserializeObject(thread, | 2498 return DeserializeObject(thread, |
2510 serialized_message_, serialized_message_len_); | 2499 serialized_message_, serialized_message_len_); |
2511 } | 2500 } |
2512 | 2501 |
2513 | 2502 |
2514 } // namespace dart | 2503 } // namespace dart |
OLD | NEW |