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

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

Issue 11478012: Provide a mechanism for dumping of heap profiles on predefined events. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address review comments Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/heap.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « runtime/vm/heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698