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

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

Issue 16077018: Implemented an averaging object histogram in the vm. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/object.cc » ('j') | 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) 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/dart_api_state.h" 13 #include "vm/dart_api_state.h"
14 #include "vm/dart_entry.h" 14 #include "vm/dart_entry.h"
15 #include "vm/debugger.h" 15 #include "vm/debugger.h"
16 #include "vm/heap.h" 16 #include "vm/heap.h"
17 #include "vm/heap_histogram.h"
17 #include "vm/message_handler.h" 18 #include "vm/message_handler.h"
18 #include "vm/object_store.h" 19 #include "vm/object_store.h"
19 #include "vm/parser.h" 20 #include "vm/parser.h"
20 #include "vm/port.h" 21 #include "vm/port.h"
21 #include "vm/simulator.h" 22 #include "vm/simulator.h"
22 #include "vm/stack_frame.h" 23 #include "vm/stack_frame.h"
23 #include "vm/stub_code.h" 24 #include "vm/stub_code.h"
24 #include "vm/symbols.h" 25 #include "vm/symbols.h"
25 #include "vm/thread.h" 26 #include "vm/thread.h"
26 #include "vm/timer.h" 27 #include "vm/timer.h"
27 #include "vm/visitor.h" 28 #include "vm/visitor.h"
28 29
29 namespace dart { 30 namespace dart {
30 31
31 DEFINE_FLAG(bool, report_usage_count, false, 32 DEFINE_FLAG(bool, report_usage_count, false,
32 "Track function usage and report."); 33 "Track function usage and report.");
33 DEFINE_FLAG(bool, trace_isolates, false, 34 DEFINE_FLAG(bool, trace_isolates, false,
34 "Trace isolate creation and shut down."); 35 "Trace isolate creation and shut down.");
35 DECLARE_FLAG(bool, trace_deoptimization_verbose); 36 DECLARE_FLAG(bool, trace_deoptimization_verbose);
36 37
38
39 void Isolate::RegisterClass(const Class& cls) {
40 class_table()->Register(cls);
41 if (object_histogram() != NULL) object_histogram()->RegisterClass(cls);
42 }
43
44
37 class IsolateMessageHandler : public MessageHandler { 45 class IsolateMessageHandler : public MessageHandler {
38 public: 46 public:
39 explicit IsolateMessageHandler(Isolate* isolate); 47 explicit IsolateMessageHandler(Isolate* isolate);
40 ~IsolateMessageHandler(); 48 ~IsolateMessageHandler();
41 49
42 const char* name() const; 50 const char* name() const;
43 void MessageNotify(Message::Priority priority); 51 void MessageNotify(Message::Priority priority);
44 bool HandleMessage(Message* message); 52 bool HandleMessage(Message* message);
45 53
46 #if defined(DEBUG) 54 #if defined(DEBUG)
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 gc_epilogue_callbacks_(), 401 gc_epilogue_callbacks_(),
394 deopt_cpu_registers_copy_(NULL), 402 deopt_cpu_registers_copy_(NULL),
395 deopt_fpu_registers_copy_(NULL), 403 deopt_fpu_registers_copy_(NULL),
396 deopt_frame_copy_(NULL), 404 deopt_frame_copy_(NULL),
397 deopt_frame_copy_size_(0), 405 deopt_frame_copy_size_(0),
398 deferred_boxes_(NULL), 406 deferred_boxes_(NULL),
399 deferred_object_refs_(NULL), 407 deferred_object_refs_(NULL),
400 deferred_objects_count_(0), 408 deferred_objects_count_(0),
401 deferred_objects_(NULL), 409 deferred_objects_(NULL),
402 stacktrace_(NULL), 410 stacktrace_(NULL),
403 stack_frame_index_(-1) { 411 stack_frame_index_(-1),
412 object_histogram_(NULL) {
413 if (FLAG_print_object_histogram && (Dart::vm_isolate() != NULL)) {
414 object_histogram_ = new ObjectHistogram(this);
415 }
404 } 416 }
405 417
406 418
407 Isolate::~Isolate() { 419 Isolate::~Isolate() {
408 delete [] name_; 420 delete [] name_;
409 delete heap_; 421 delete heap_;
410 delete object_store_; 422 delete object_store_;
411 delete api_state_; 423 delete api_state_;
412 delete stub_code_; 424 delete stub_code_;
413 delete debugger_; 425 delete debugger_;
414 #if defined(USING_SIMULATOR) 426 #if defined(USING_SIMULATOR)
415 delete simulator_; 427 delete simulator_;
416 #endif 428 #endif
417 delete mutex_; 429 delete mutex_;
418 mutex_ = NULL; // Fail fast if interrupts are scheduled on a dead isolate. 430 mutex_ = NULL; // Fail fast if interrupts are scheduled on a dead isolate.
419 delete message_handler_; 431 delete message_handler_;
420 message_handler_ = NULL; // Fail fast if we send messages to a dead isolate. 432 message_handler_ = NULL; // Fail fast if we send messages to a dead isolate.
433 delete object_histogram_;
421 } 434 }
422 435
423 void Isolate::SetCurrent(Isolate* current) { 436 void Isolate::SetCurrent(Isolate* current) {
424 Thread::SetThreadLocal(isolate_key, reinterpret_cast<uword>(current)); 437 Thread::SetThreadLocal(isolate_key, reinterpret_cast<uword>(current));
425 } 438 }
426 439
427 440
428 // The single thread local key which stores all the thread local data 441 // The single thread local key which stores all the thread local data
429 // for a thread. Since an Isolate is the central repository for 442 // for a thread. Since an Isolate is the central repository for
430 // storing all isolate specific information a single thread local key 443 // storing all isolate specific information a single thread local key
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 private: 735 private:
723 DISALLOW_COPY_AND_ASSIGN(FinalizeWeakPersistentHandlesVisitor); 736 DISALLOW_COPY_AND_ASSIGN(FinalizeWeakPersistentHandlesVisitor);
724 }; 737 };
725 738
726 739
727 void Isolate::Shutdown() { 740 void Isolate::Shutdown() {
728 ASSERT(this == Isolate::Current()); 741 ASSERT(this == Isolate::Current());
729 ASSERT(top_resource() == NULL); 742 ASSERT(top_resource() == NULL);
730 ASSERT((heap_ == NULL) || heap_->Verify()); 743 ASSERT((heap_ == NULL) || heap_->Verify());
731 744
745 if (FLAG_print_object_histogram) {
746 StackZone stack_zone(this);
747 HandleScope handle_scope(this);
748 heap()->CollectAllGarbage();
749 object_histogram()->Print();
750 }
751
732 // Clean up debugger resources. Shutting down the debugger 752 // Clean up debugger resources. Shutting down the debugger
733 // requires a handle zone. We must set up a temporary zone because 753 // requires a handle zone. We must set up a temporary zone because
734 // Isolate::Shutdown is called without a zone. 754 // Isolate::Shutdown is called without a zone.
735 { 755 {
736 StackZone zone(this); 756 StackZone zone(this);
737 HandleScope handle_scope(this); 757 HandleScope handle_scope(this);
738 debugger_->Shutdown(); 758 debugger_->Shutdown();
739 } 759 }
740 760
741 // Close all the ports owned by this isolate. 761 // Close all the ports owned by this isolate.
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 return func.raw(); 1158 return func.raw();
1139 } 1159 }
1140 1160
1141 1161
1142 void IsolateSpawnState::Cleanup() { 1162 void IsolateSpawnState::Cleanup() {
1143 SwitchIsolateScope switch_scope(isolate()); 1163 SwitchIsolateScope switch_scope(isolate());
1144 Dart::ShutdownIsolate(); 1164 Dart::ShutdownIsolate();
1145 } 1165 }
1146 1166
1147 } // namespace dart 1167 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698