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

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

Issue 2609253002: Added isolate + thread high watermark tracking to Observatory (Closed)
Patch Set: Merge branch 'master' of github.com:dart-lang/sdk into resubmit Created 3 years, 11 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
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 "include/dart_native_api.h" 8 #include "include/dart_native_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/text_buffer.h" 10 #include "platform/text_buffer.h"
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 : store_buffer_(new StoreBuffer()), 769 : store_buffer_(new StoreBuffer()),
770 heap_(NULL), 770 heap_(NULL),
771 user_tag_(0), 771 user_tag_(0),
772 current_tag_(UserTag::null()), 772 current_tag_(UserTag::null()),
773 default_tag_(UserTag::null()), 773 default_tag_(UserTag::null()),
774 object_store_(NULL), 774 object_store_(NULL),
775 class_table_(), 775 class_table_(),
776 single_step_(false), 776 single_step_(false),
777 thread_registry_(new ThreadRegistry()), 777 thread_registry_(new ThreadRegistry()),
778 safepoint_handler_(new SafepointHandler(this)), 778 safepoint_handler_(new SafepointHandler(this)),
779 memory_high_watermark_(0),
779 message_notify_callback_(NULL), 780 message_notify_callback_(NULL),
780 name_(NULL), 781 name_(NULL),
781 debugger_name_(NULL), 782 debugger_name_(NULL),
782 start_time_micros_(OS::GetCurrentMonotonicMicros()), 783 start_time_micros_(OS::GetCurrentMonotonicMicros()),
783 main_port_(0), 784 main_port_(0),
784 origin_id_(0), 785 origin_id_(0),
785 pause_capability_(0), 786 pause_capability_(0),
786 terminate_capability_(0), 787 terminate_capability_(0),
787 errors_fatal_(true), 788 errors_fatal_(true),
788 init_callback_data_(NULL), 789 init_callback_data_(NULL),
(...skipping 1312 matching lines...) Expand 10 before | Expand all | Expand 10 after
2101 if (!handlers.IsNull()) { 2102 if (!handlers.IsNull()) {
2102 JSONArray extensions(&jsobj, "extensionRPCs"); 2103 JSONArray extensions(&jsobj, "extensionRPCs");
2103 String& handler_name = String::Handle(); 2104 String& handler_name = String::Handle();
2104 for (intptr_t i = 0; i < handlers.Length(); i += kRegisteredEntrySize) { 2105 for (intptr_t i = 0; i < handlers.Length(); i += kRegisteredEntrySize) {
2105 handler_name ^= handlers.At(i + kRegisteredNameIndex); 2106 handler_name ^= handlers.At(i + kRegisteredNameIndex);
2106 extensions.AddValue(handler_name.ToCString()); 2107 extensions.AddValue(handler_name.ToCString());
2107 } 2108 }
2108 } 2109 }
2109 } 2110 }
2110 2111
2111 jsobj.AddProperty("threads", thread_registry_); 2112 jsobj.AddPropertyF("_memoryHighWatermark", "%u", memory_high_watermark_);
2113 jsobj.AddProperty("_threads", thread_registry_);
2112 } 2114 }
2113 #endif 2115 #endif
2114 2116
2115 2117
2116 void Isolate::set_tag_table(const GrowableObjectArray& value) { 2118 void Isolate::set_tag_table(const GrowableObjectArray& value) {
2117 tag_table_ = value.raw(); 2119 tag_table_ = value.raw();
2118 } 2120 }
2119 2121
2120 2122
2121 void Isolate::set_current_tag(const UserTag& tag) { 2123 void Isolate::set_current_tag(const UserTag& tag) {
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
2651 // If a safepoint operation is in progress wait for it 2653 // If a safepoint operation is in progress wait for it
2652 // to finish before scheduling this thread in. 2654 // to finish before scheduling this thread in.
2653 while (!bypass_safepoint && safepoint_handler()->SafepointInProgress()) { 2655 while (!bypass_safepoint && safepoint_handler()->SafepointInProgress()) {
2654 ml.Wait(); 2656 ml.Wait();
2655 } 2657 }
2656 2658
2657 // Now get a free Thread structure. 2659 // Now get a free Thread structure.
2658 thread = thread_registry()->GetFreeThreadLocked(this, is_mutator); 2660 thread = thread_registry()->GetFreeThreadLocked(this, is_mutator);
2659 ASSERT(thread != NULL); 2661 ASSERT(thread != NULL);
2660 2662
2663 thread->ResetHighWatermark();
2664
2661 // Set up other values and set the TLS value. 2665 // Set up other values and set the TLS value.
2662 thread->isolate_ = this; 2666 thread->isolate_ = this;
2663 ASSERT(heap() != NULL); 2667 ASSERT(heap() != NULL);
2664 thread->heap_ = heap(); 2668 thread->heap_ = heap();
2665 thread->set_os_thread(os_thread); 2669 thread->set_os_thread(os_thread);
2666 ASSERT(thread->execution_state() == Thread::kThreadInNative); 2670 ASSERT(thread->execution_state() == Thread::kThreadInNative);
2667 thread->set_execution_state(Thread::kThreadInVM); 2671 thread->set_execution_state(Thread::kThreadInVM);
2668 thread->set_safepoint_state(0); 2672 thread->set_safepoint_state(0);
2669 thread->set_vm_tag(VMTag::kVMTagId); 2673 thread->set_vm_tag(VMTag::kVMTagId);
2670 ASSERT(thread->no_safepoint_scope_depth() == 0); 2674 ASSERT(thread->no_safepoint_scope_depth() == 0);
(...skipping 26 matching lines...) Expand all
2697 thread->clear_sticky_error(); 2701 thread->clear_sticky_error();
2698 } 2702 }
2699 } else { 2703 } else {
2700 ASSERT(thread->api_top_scope_ == NULL); 2704 ASSERT(thread->api_top_scope_ == NULL);
2701 ASSERT(thread->zone_ == NULL); 2705 ASSERT(thread->zone_ == NULL);
2702 } 2706 }
2703 if (!bypass_safepoint) { 2707 if (!bypass_safepoint) {
2704 // Ensure that the thread reports itself as being at a safepoint. 2708 // Ensure that the thread reports itself as being at a safepoint.
2705 thread->EnterSafepoint(); 2709 thread->EnterSafepoint();
2706 } 2710 }
2711 UpdateMemoryHighWatermark();
2707 OSThread* os_thread = thread->os_thread(); 2712 OSThread* os_thread = thread->os_thread();
2708 ASSERT(os_thread != NULL); 2713 ASSERT(os_thread != NULL);
2709 os_thread->DisableThreadInterrupts(); 2714 os_thread->DisableThreadInterrupts();
2710 os_thread->set_thread(NULL); 2715 os_thread->set_thread(NULL);
2711 OSThread::SetCurrent(os_thread); 2716 OSThread::SetCurrent(os_thread);
2712 if (is_mutator) { 2717 if (is_mutator) {
2713 mutator_thread_ = NULL; 2718 mutator_thread_ = NULL;
2714 } 2719 }
2715 thread->isolate_ = NULL; 2720 thread->isolate_ = NULL;
2716 thread->heap_ = NULL; 2721 thread->heap_ = NULL;
2717 thread->set_os_thread(NULL); 2722 thread->set_os_thread(NULL);
2718 thread->set_execution_state(Thread::kThreadInNative); 2723 thread->set_execution_state(Thread::kThreadInNative);
2719 thread->set_safepoint_state(Thread::SetAtSafepoint(true, 0)); 2724 thread->set_safepoint_state(Thread::SetAtSafepoint(true, 0));
2720 thread->clear_pending_functions(); 2725 thread->clear_pending_functions();
2721 ASSERT(thread->no_safepoint_scope_depth() == 0); 2726 ASSERT(thread->no_safepoint_scope_depth() == 0);
2722 // Return thread structure. 2727 // Return thread structure.
2723 thread_registry()->ReturnThreadLocked(is_mutator, thread); 2728 thread_registry()->ReturnThreadLocked(is_mutator, thread);
2724 } 2729 }
2725 2730
2726 2731
2732 void Isolate::UpdateMemoryHighWatermark() {
2733 const intptr_t thread_watermarks_total =
2734 thread_registry()->ThreadHighWatermarksTotalLocked();
2735 if (thread_watermarks_total > memory_high_watermark_) {
2736 memory_high_watermark_ = thread_watermarks_total;
2737 }
2738 }
2739
2740
2727 static RawInstance* DeserializeObject(Thread* thread, 2741 static RawInstance* DeserializeObject(Thread* thread,
2728 uint8_t* obj_data, 2742 uint8_t* obj_data,
2729 intptr_t obj_len) { 2743 intptr_t obj_len) {
2730 if (obj_data == NULL) { 2744 if (obj_data == NULL) {
2731 return Instance::null(); 2745 return Instance::null();
2732 } 2746 }
2733 MessageSnapshotReader reader(obj_data, obj_len, thread); 2747 MessageSnapshotReader reader(obj_data, obj_len, thread);
2734 Zone* zone = thread->zone(); 2748 Zone* zone = thread->zone();
2735 const Object& obj = Object::Handle(zone, reader.ReadObject()); 2749 const Object& obj = Object::Handle(zone, reader.ReadObject());
2736 ASSERT(!obj.IsError()); 2750 ASSERT(!obj.IsError());
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
2953 void IsolateSpawnState::DecrementSpawnCount() { 2967 void IsolateSpawnState::DecrementSpawnCount() {
2954 ASSERT(spawn_count_monitor_ != NULL); 2968 ASSERT(spawn_count_monitor_ != NULL);
2955 ASSERT(spawn_count_ != NULL); 2969 ASSERT(spawn_count_ != NULL);
2956 MonitorLocker ml(spawn_count_monitor_); 2970 MonitorLocker ml(spawn_count_monitor_);
2957 ASSERT(*spawn_count_ > 0); 2971 ASSERT(*spawn_count_ > 0);
2958 *spawn_count_ = *spawn_count_ - 1; 2972 *spawn_count_ = *spawn_count_ - 1;
2959 ml.Notify(); 2973 ml.Notify();
2960 } 2974 }
2961 2975
2962 } // namespace dart 2976 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/thread.h » ('j') | runtime/vm/thread_registry.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698