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

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: 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
« runtime/vm/exceptions.cc ('K') | « 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 delete message; 108 delete message;
108 } else { 109 } else {
109 const Object& result = Object::Handle( 110 const Object& result = Object::Handle(
110 DartLibraryCalls::HandleMessage( 111 DartLibraryCalls::HandleMessage(
111 message->dest_port(), message->reply_port(), msg)); 112 message->dest_port(), message->reply_port(), msg));
112 delete message; 113 delete message;
113 if (result.IsError() || result.IsUnhandledException()) { 114 if (result.IsError() || result.IsUnhandledException()) {
114 if (result.IsError()) { 115 if (result.IsError()) {
115 isolate_->object_store()->set_sticky_error(Error::Cast(result)); 116 isolate_->object_store()->set_sticky_error(Error::Cast(result));
116 } 117 }
118 if (result.IsInstance() && FLAG_heap_profile_out_of_memory) {
siva 2012/12/07 00:33:02 This check seems incorrect, at this point result w
cshapiro 2012/12/08 07:29:46 I am really confused by this. At this point resul
119 Instance& out_of_memory =
120 Instance::Handle(isolate_->object_store()->out_of_memory());
121 if (Instance::Cast(result).Equals(out_of_memory)) {
122 const char* format = "%s-out-of-memory.hprof";
123 intptr_t len = OS::SNPrint(NULL, 0, format, isolate_->name());
124 char* filename =
125 isolate_->current_zone()->Alloc<char>(len + 1);
126 OS::SNPrint(filename, len + 1, format, isolate_->name());
127 isolate_->heap()->ProfileToFile(filename);
128 }
129 }
117 if (Isolate::UnhandledExceptionCallback() != NULL) { 130 if (Isolate::UnhandledExceptionCallback() != NULL) {
118 Dart_EnterScope(); 131 Dart_EnterScope();
119 Dart_Handle error = Api::NewHandle(isolate_, result.raw()); 132 Dart_Handle error = Api::NewHandle(isolate_, result.raw());
120 (Isolate::UnhandledExceptionCallback())(error); 133 (Isolate::UnhandledExceptionCallback())(error);
121 Dart_ExitScope(); 134 Dart_ExitScope();
122 } 135 }
123 return false; 136 return false;
124 } 137 }
125 ASSERT(result.IsNull()); 138 ASSERT(result.IsNull());
126 } 139 }
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 517
505 518
506 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor, 519 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor,
507 bool visit_prologue_weak_handles) { 520 bool visit_prologue_weak_handles) {
508 if (api_state() != NULL) { 521 if (api_state() != NULL) {
509 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles); 522 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles);
510 } 523 }
511 } 524 }
512 525
513 } // namespace dart 526 } // namespace dart
OLDNEW
« runtime/vm/exceptions.cc ('K') | « runtime/vm/heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698