Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(453)

Side by Side Diff: runtime/vm/isolate.cc

Issue 1709383002: Improve behaviour when we hit a stack overflow / OOM error (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 return MessageHandler::kShutdown; 647 return MessageHandler::kShutdown;
648 } 648 }
649 } 649 }
650 } 650 }
651 return MessageHandler::kError; 651 return MessageHandler::kError;
652 } 652 }
653 653
654 654
655 MessageHandler::MessageStatus IsolateMessageHandler::ProcessUnhandledException( 655 MessageHandler::MessageStatus IsolateMessageHandler::ProcessUnhandledException(
656 const Error& result) { 656 const Error& result) {
657 // Notify the debugger about specific unhandled exceptions which are withheld
658 // when being thrown.
659 if (result.IsUnhandledException()) {
660 const UnhandledException& error = UnhandledException::Cast(result);
661 RawInstance* exception = error.exception();
662 if ((exception == I->object_store()->out_of_memory()) ||
663 (exception == I->object_store()->stack_overflow())) {
664 // We didn't notify the debugger when the stack was full. Do it now.
665 if (FLAG_support_debugger) {
666 I->debugger()->SignalExceptionThrown(Instance::Handle(exception));
667 }
668 }
669 }
670
671 // Generate the error and stacktrace strings for the error message. 657 // Generate the error and stacktrace strings for the error message.
672 String& exc_str = String::Handle(T->zone()); 658 String& exc_str = String::Handle(T->zone());
673 String& stacktrace_str = String::Handle(T->zone()); 659 String& stacktrace_str = String::Handle(T->zone());
674 if (result.IsUnhandledException()) { 660 if (result.IsUnhandledException()) {
675 Zone* zone = T->zone(); 661 Zone* zone = T->zone();
676 const UnhandledException& uhe = UnhandledException::Cast(result); 662 const UnhandledException& uhe = UnhandledException::Cast(result);
677 const Instance& exception = Instance::Handle(zone, uhe.exception()); 663 const Instance& exception = Instance::Handle(zone, uhe.exception());
678 Object& tmp = Object::Handle(zone); 664 Object& tmp = Object::Handle(zone);
679 tmp = DartLibraryCalls::ToString(exception); 665 tmp = DartLibraryCalls::ToString(exception);
680 if (!tmp.IsString()) { 666 if (!tmp.IsString()) {
(...skipping 15 matching lines...) Expand all
696 // whether errors are fatal for the current isolate. 682 // whether errors are fatal for the current isolate.
697 return StoreError(T, result); 683 return StoreError(T, result);
698 } else { 684 } else {
699 bool has_listener = I->NotifyErrorListeners(exc_str, stacktrace_str); 685 bool has_listener = I->NotifyErrorListeners(exc_str, stacktrace_str);
700 if (I->ErrorsFatal()) { 686 if (I->ErrorsFatal()) {
701 if (has_listener) { 687 if (has_listener) {
702 T->clear_sticky_error(); 688 T->clear_sticky_error();
703 } else { 689 } else {
704 T->set_sticky_error(result); 690 T->set_sticky_error(result);
705 } 691 }
692 // Notify the debugger about specific unhandled exceptions which are
693 // withheld when being thrown. Do this after setting the sticky error
694 // so the isolate has an error set when paused with the unhandled
695 // exception.
696 if (result.IsUnhandledException()) {
697 const UnhandledException& error = UnhandledException::Cast(result);
698 RawInstance* exception = error.exception();
699 if ((exception == I->object_store()->out_of_memory()) ||
700 (exception == I->object_store()->stack_overflow())) {
701 // We didn't notify the debugger when the stack was full. Do it now.
702 if (FLAG_support_debugger) {
703 I->debugger()->SignalExceptionThrown(Instance::Handle(exception));
704 }
705 }
706 }
706 return kError; 707 return kError;
707 } 708 }
708 } 709 }
709 return kOK; 710 return kOK;
710 } 711 }
711 712
712 713
713 Isolate::Flags::Flags() 714 Isolate::Flags::Flags()
714 : type_checks_(FLAG_enable_type_checks), 715 : type_checks_(FLAG_enable_type_checks),
715 asserts_(FLAG_enable_asserts), 716 asserts_(FLAG_enable_asserts),
(...skipping 2102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2818 void IsolateSpawnState::DecrementSpawnCount() { 2819 void IsolateSpawnState::DecrementSpawnCount() {
2819 ASSERT(spawn_count_monitor_ != NULL); 2820 ASSERT(spawn_count_monitor_ != NULL);
2820 ASSERT(spawn_count_ != NULL); 2821 ASSERT(spawn_count_ != NULL);
2821 MonitorLocker ml(spawn_count_monitor_); 2822 MonitorLocker ml(spawn_count_monitor_);
2822 ASSERT(*spawn_count_ > 0); 2823 ASSERT(*spawn_count_ > 0);
2823 *spawn_count_ = *spawn_count_ - 1; 2824 *spawn_count_ = *spawn_count_ - 1;
2824 ml.Notify(); 2825 ml.Notify();
2825 } 2826 }
2826 2827
2827 } // namespace dart 2828 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698