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

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

Issue 51653006: Track live instance and allocation counts for classes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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
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 "platform/assert.h" 8 #include "platform/assert.h"
9 #include "platform/json.h" 9 #include "platform/json.h"
10 #include "lib/mirrors.h" 10 #include "lib/mirrors.h"
11 #include "vm/code_observers.h" 11 #include "vm/code_observers.h"
12 #include "vm/compiler_stats.h" 12 #include "vm/compiler_stats.h"
13 #include "vm/coverage.h" 13 #include "vm/coverage.h"
14 #include "vm/dart_api_state.h" 14 #include "vm/dart_api_state.h"
15 #include "vm/dart_entry.h" 15 #include "vm/dart_entry.h"
16 #include "vm/debugger.h" 16 #include "vm/debugger.h"
17 #include "vm/deopt_instructions.h" 17 #include "vm/deopt_instructions.h"
18 #include "vm/heap.h" 18 #include "vm/heap.h"
19 #include "vm/heap_class_stats.h"
19 #include "vm/heap_histogram.h" 20 #include "vm/heap_histogram.h"
20 #include "vm/message_handler.h" 21 #include "vm/message_handler.h"
21 #include "vm/object_id_ring.h" 22 #include "vm/object_id_ring.h"
22 #include "vm/object_store.h" 23 #include "vm/object_store.h"
23 #include "vm/parser.h" 24 #include "vm/parser.h"
24 #include "vm/port.h" 25 #include "vm/port.h"
25 #include "vm/reusable_handles.h" 26 #include "vm/reusable_handles.h"
26 #include "vm/service.h" 27 #include "vm/service.h"
27 #include "vm/simulator.h" 28 #include "vm/simulator.h"
28 #include "vm/stack_frame.h" 29 #include "vm/stack_frame.h"
29 #include "vm/stub_code.h" 30 #include "vm/stub_code.h"
30 #include "vm/symbols.h" 31 #include "vm/symbols.h"
31 #include "vm/thread.h" 32 #include "vm/thread.h"
32 #include "vm/timer.h" 33 #include "vm/timer.h"
33 #include "vm/visitor.h" 34 #include "vm/visitor.h"
34 35
35 36
36 namespace dart { 37 namespace dart {
37 38
38 DEFINE_FLAG(bool, report_usage_count, false, 39 DEFINE_FLAG(bool, report_usage_count, false,
39 "Track function usage and report."); 40 "Track function usage and report.");
40 DEFINE_FLAG(bool, trace_isolates, false, 41 DEFINE_FLAG(bool, trace_isolates, false,
41 "Trace isolate creation and shut down."); 42 "Trace isolate creation and shut down.");
42 43
43 44
44 void Isolate::RegisterClass(const Class& cls) { 45 void Isolate::RegisterClass(const Class& cls) {
45 class_table()->Register(cls); 46 class_table()->Register(cls);
46 if (object_histogram() != NULL) object_histogram()->RegisterClass(cls); 47 if (object_histogram() != NULL) object_histogram()->RegisterClass(cls);
48 if (heap_class_stats() != NULL) heap_class_stats()->RegisterClass(cls);
47 } 49 }
48 50
49 51
50 class IsolateMessageHandler : public MessageHandler { 52 class IsolateMessageHandler : public MessageHandler {
51 public: 53 public:
52 explicit IsolateMessageHandler(Isolate* isolate); 54 explicit IsolateMessageHandler(Isolate* isolate);
53 ~IsolateMessageHandler(); 55 ~IsolateMessageHandler();
54 56
55 const char* name() const; 57 const char* name() const;
56 void MessageNotify(Message::Priority priority); 58 void MessageNotify(Message::Priority priority);
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 spawn_data_(0), 302 spawn_data_(0),
301 is_runnable_(false), 303 is_runnable_(false),
302 gc_prologue_callbacks_(), 304 gc_prologue_callbacks_(),
303 gc_epilogue_callbacks_(), 305 gc_epilogue_callbacks_(),
304 defer_finalization_count_(0), 306 defer_finalization_count_(0),
305 deopt_context_(NULL), 307 deopt_context_(NULL),
306 stacktrace_(NULL), 308 stacktrace_(NULL),
307 stack_frame_index_(-1), 309 stack_frame_index_(-1),
308 object_histogram_(NULL), 310 object_histogram_(NULL),
309 object_id_ring_(NULL), 311 object_id_ring_(NULL),
312 heap_class_stats_(NULL),
310 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS) 313 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS)
311 reusable_handles_() { 314 reusable_handles_() {
312 if (FLAG_print_object_histogram && (Dart::vm_isolate() != NULL)) { 315 if (FLAG_print_object_histogram && (Dart::vm_isolate() != NULL)) {
313 object_histogram_ = new ObjectHistogram(this); 316 object_histogram_ = new ObjectHistogram(this);
314 } 317 }
318 heap_class_stats_ = new HeapClassStatistics(this);
315 } 319 }
316 #undef REUSABLE_HANDLE_INITIALIZERS 320 #undef REUSABLE_HANDLE_INITIALIZERS
317 321
318 322
319 Isolate::~Isolate() { 323 Isolate::~Isolate() {
320 delete [] name_; 324 delete [] name_;
321 delete heap_; 325 delete heap_;
322 delete object_store_; 326 delete object_store_;
323 delete api_state_; 327 delete api_state_;
324 delete stub_code_; 328 delete stub_code_;
325 delete debugger_; 329 delete debugger_;
326 #if defined(USING_SIMULATOR) 330 #if defined(USING_SIMULATOR)
327 delete simulator_; 331 delete simulator_;
328 #endif 332 #endif
329 delete mutex_; 333 delete mutex_;
330 mutex_ = NULL; // Fail fast if interrupts are scheduled on a dead isolate. 334 mutex_ = NULL; // Fail fast if interrupts are scheduled on a dead isolate.
331 delete message_handler_; 335 delete message_handler_;
332 message_handler_ = NULL; // Fail fast if we send messages to a dead isolate. 336 message_handler_ = NULL; // Fail fast if we send messages to a dead isolate.
333 ASSERT(deopt_context_ == NULL); // No deopt in progress when isolate deleted. 337 ASSERT(deopt_context_ == NULL); // No deopt in progress when isolate deleted.
334 delete object_histogram_; 338 delete object_histogram_;
339 delete heap_class_stats_;
335 } 340 }
336 341
337 void Isolate::SetCurrent(Isolate* current) { 342 void Isolate::SetCurrent(Isolate* current) {
338 Thread::SetThreadLocal(isolate_key, reinterpret_cast<uword>(current)); 343 Thread::SetThreadLocal(isolate_key, reinterpret_cast<uword>(current));
339 } 344 }
340 345
341 346
342 // The single thread local key which stores all the thread local data 347 // The single thread local key which stores all the thread local data
343 // for a thread. Since an Isolate is the central repository for 348 // for a thread. Since an Isolate is the central repository for
344 // storing all isolate specific information a single thread local key 349 // storing all isolate specific information a single thread local key
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 return func.raw(); 1066 return func.raw();
1062 } 1067 }
1063 1068
1064 1069
1065 void IsolateSpawnState::Cleanup() { 1070 void IsolateSpawnState::Cleanup() {
1066 SwitchIsolateScope switch_scope(isolate()); 1071 SwitchIsolateScope switch_scope(isolate());
1067 Dart::ShutdownIsolate(); 1072 Dart::ShutdownIsolate();
1068 } 1073 }
1069 1074
1070 } // namespace dart 1075 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698