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/text_buffer.h" | 10 #include "platform/text_buffer.h" |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 return MessageHandler::kShutdown; | 648 return MessageHandler::kShutdown; |
649 } | 649 } |
650 } | 650 } |
651 } | 651 } |
652 return MessageHandler::kError; | 652 return MessageHandler::kError; |
653 } | 653 } |
654 | 654 |
655 | 655 |
656 MessageHandler::MessageStatus IsolateMessageHandler::ProcessUnhandledException( | 656 MessageHandler::MessageStatus IsolateMessageHandler::ProcessUnhandledException( |
657 const Error& result) { | 657 const Error& result) { |
658 // Notify the debugger about specific unhandled exceptions which are withheld | |
659 // when being thrown. | |
660 if (result.IsUnhandledException()) { | |
661 const UnhandledException& error = UnhandledException::Cast(result); | |
662 RawInstance* exception = error.exception(); | |
663 if ((exception == I->object_store()->out_of_memory()) || | |
664 (exception == I->object_store()->stack_overflow())) { | |
665 // We didn't notify the debugger when the stack was full. Do it now. | |
666 if (FLAG_support_debugger) { | |
667 I->debugger()->SignalExceptionThrown(Instance::Handle(exception)); | |
668 } | |
669 } | |
670 } | |
671 | |
672 // Generate the error and stacktrace strings for the error message. | 658 // Generate the error and stacktrace strings for the error message. |
673 String& exc_str = String::Handle(T->zone()); | 659 String& exc_str = String::Handle(T->zone()); |
674 String& stacktrace_str = String::Handle(T->zone()); | 660 String& stacktrace_str = String::Handle(T->zone()); |
675 if (result.IsUnhandledException()) { | 661 if (result.IsUnhandledException()) { |
676 Zone* zone = T->zone(); | 662 Zone* zone = T->zone(); |
677 const UnhandledException& uhe = UnhandledException::Cast(result); | 663 const UnhandledException& uhe = UnhandledException::Cast(result); |
678 const Instance& exception = Instance::Handle(zone, uhe.exception()); | 664 const Instance& exception = Instance::Handle(zone, uhe.exception()); |
679 Object& tmp = Object::Handle(zone); | 665 Object& tmp = Object::Handle(zone); |
680 tmp = DartLibraryCalls::ToString(exception); | 666 tmp = DartLibraryCalls::ToString(exception); |
681 if (!tmp.IsString()) { | 667 if (!tmp.IsString()) { |
(...skipping 15 matching lines...) Expand all Loading... |
697 // whether errors are fatal for the current isolate. | 683 // whether errors are fatal for the current isolate. |
698 return StoreError(T, result); | 684 return StoreError(T, result); |
699 } else { | 685 } else { |
700 bool has_listener = I->NotifyErrorListeners(exc_str, stacktrace_str); | 686 bool has_listener = I->NotifyErrorListeners(exc_str, stacktrace_str); |
701 if (I->ErrorsFatal()) { | 687 if (I->ErrorsFatal()) { |
702 if (has_listener) { | 688 if (has_listener) { |
703 T->clear_sticky_error(); | 689 T->clear_sticky_error(); |
704 } else { | 690 } else { |
705 T->set_sticky_error(result); | 691 T->set_sticky_error(result); |
706 } | 692 } |
| 693 // Notify the debugger about specific unhandled exceptions which are |
| 694 // withheld when being thrown. Do this after setting the sticky error |
| 695 // so the isolate has an error set when paused with the unhandled |
| 696 // exception. |
| 697 if (result.IsUnhandledException()) { |
| 698 const UnhandledException& error = UnhandledException::Cast(result); |
| 699 RawInstance* exception = error.exception(); |
| 700 if ((exception == I->object_store()->out_of_memory()) || |
| 701 (exception == I->object_store()->stack_overflow())) { |
| 702 // We didn't notify the debugger when the stack was full. Do it now. |
| 703 if (FLAG_support_debugger) { |
| 704 I->debugger()->SignalExceptionThrown(Instance::Handle(exception)); |
| 705 } |
| 706 } |
| 707 } |
707 return kError; | 708 return kError; |
708 } | 709 } |
709 } | 710 } |
710 return kOK; | 711 return kOK; |
711 } | 712 } |
712 | 713 |
713 | 714 |
714 Isolate::Flags::Flags() | 715 Isolate::Flags::Flags() |
715 : type_checks_(FLAG_enable_type_checks), | 716 : type_checks_(FLAG_enable_type_checks), |
716 asserts_(FLAG_enable_asserts), | 717 asserts_(FLAG_enable_asserts), |
(...skipping 2106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2823 void IsolateSpawnState::DecrementSpawnCount() { | 2824 void IsolateSpawnState::DecrementSpawnCount() { |
2824 ASSERT(spawn_count_monitor_ != NULL); | 2825 ASSERT(spawn_count_monitor_ != NULL); |
2825 ASSERT(spawn_count_ != NULL); | 2826 ASSERT(spawn_count_ != NULL); |
2826 MonitorLocker ml(spawn_count_monitor_); | 2827 MonitorLocker ml(spawn_count_monitor_); |
2827 ASSERT(*spawn_count_ > 0); | 2828 ASSERT(*spawn_count_ > 0); |
2828 *spawn_count_ = *spawn_count_ - 1; | 2829 *spawn_count_ = *spawn_count_ - 1; |
2829 ml.Notify(); | 2830 ml.Notify(); |
2830 } | 2831 } |
2831 | 2832 |
2832 } // namespace dart | 2833 } // namespace dart |
OLD | NEW |