Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "lib/mirrors.h" | 9 #include "lib/mirrors.h" |
| 10 #include "vm/compiler_stats.h" | 10 #include "vm/compiler_stats.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 #include "vm/thread.h" | 23 #include "vm/thread.h" |
| 24 #include "vm/timer.h" | 24 #include "vm/timer.h" |
| 25 #include "vm/visitor.h" | 25 #include "vm/visitor.h" |
| 26 | 26 |
| 27 namespace dart { | 27 namespace dart { |
| 28 | 28 |
| 29 DEFINE_FLAG(bool, report_usage_count, false, | 29 DEFINE_FLAG(bool, report_usage_count, false, |
| 30 "Track function usage and report."); | 30 "Track function usage and report."); |
| 31 DEFINE_FLAG(bool, trace_isolates, false, | 31 DEFINE_FLAG(bool, trace_isolates, false, |
| 32 "Trace isolate creation and shut down."); | 32 "Trace isolate creation and shut down."); |
| 33 DECLARE_FLAG(bool, heap_profile_out_of_memory); | |
| 33 DECLARE_FLAG(bool, generate_gdb_symbols); | 34 DECLARE_FLAG(bool, generate_gdb_symbols); |
| 34 | 35 |
| 35 | 36 |
| 36 class IsolateMessageHandler : public MessageHandler { | 37 class IsolateMessageHandler : public MessageHandler { |
| 37 public: | 38 public: |
| 38 explicit IsolateMessageHandler(Isolate* isolate); | 39 explicit IsolateMessageHandler(Isolate* isolate); |
| 39 ~IsolateMessageHandler(); | 40 ~IsolateMessageHandler(); |
| 40 | 41 |
| 41 const char* name() const; | 42 const char* name() const; |
| 42 void MessageNotify(Message::Priority priority); | 43 void MessageNotify(Message::Priority priority); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 #endif | 133 #endif |
| 133 | 134 |
| 134 | 135 |
| 135 bool IsolateMessageHandler::IsCurrentIsolate() const { | 136 bool IsolateMessageHandler::IsCurrentIsolate() const { |
| 136 return (isolate_ == Isolate::Current()); | 137 return (isolate_ == Isolate::Current()); |
| 137 } | 138 } |
| 138 | 139 |
| 139 | 140 |
| 140 bool IsolateMessageHandler::ProcessUnhandledException(const Object& result) { | 141 bool IsolateMessageHandler::ProcessUnhandledException(const Object& result) { |
| 141 isolate_->object_store()->set_sticky_error(Error::Cast(result)); | 142 isolate_->object_store()->set_sticky_error(Error::Cast(result)); |
| 143 if (FLAG_heap_profile_out_of_memory) { | |
| 144 Instance& exception = Instance::Handle(); | |
| 145 if (result.IsUnhandledException()) { | |
| 146 exception ^= UnhandledException::Cast(result).exception(); | |
| 147 } else { | |
| 148 ASSERT(result.IsError()); | |
| 149 exception ^= result.raw(); | |
|
siva
2012/12/10 05:06:36
I think this else part is not needed and the OOM c
| |
| 150 } | |
| 151 if (exception.raw() == isolate_->object_store()->out_of_memory()) { | |
| 152 isolate_->heap()->ProfileToFile("out-of-memory"); | |
| 153 } | |
| 154 } | |
| 142 // Invoke the dart unhandled exception callback if there is one. | 155 // Invoke the dart unhandled exception callback if there is one. |
| 143 if (Isolate::UnhandledExceptionCallback() != NULL) { | 156 if (Isolate::UnhandledExceptionCallback() != NULL) { |
| 144 Dart_EnterScope(); | 157 Dart_EnterScope(); |
| 145 Dart_Handle error = Api::NewHandle(isolate_, result.raw()); | 158 Dart_Handle error = Api::NewHandle(isolate_, result.raw()); |
| 146 (Isolate::UnhandledExceptionCallback())(error); | 159 (Isolate::UnhandledExceptionCallback())(error); |
| 147 Dart_ExitScope(); | 160 Dart_ExitScope(); |
| 148 } | 161 } |
| 149 return false; | 162 return false; |
| 150 } | 163 } |
| 151 | 164 |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 514 | 527 |
| 515 | 528 |
| 516 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor, | 529 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor, |
| 517 bool visit_prologue_weak_handles) { | 530 bool visit_prologue_weak_handles) { |
| 518 if (api_state() != NULL) { | 531 if (api_state() != NULL) { |
| 519 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles); | 532 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles); |
| 520 } | 533 } |
| 521 } | 534 } |
| 522 | 535 |
| 523 } // namespace dart | 536 } // namespace dart |
| OLD | NEW |