OLD | NEW |
---|---|
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 Loading... | |
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 isolate_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 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2096 if (!handlers.IsNull()) { | 2097 if (!handlers.IsNull()) { |
2097 JSONArray extensions(&jsobj, "extensionRPCs"); | 2098 JSONArray extensions(&jsobj, "extensionRPCs"); |
2098 String& handler_name = String::Handle(); | 2099 String& handler_name = String::Handle(); |
2099 for (intptr_t i = 0; i < handlers.Length(); i += kRegisteredEntrySize) { | 2100 for (intptr_t i = 0; i < handlers.Length(); i += kRegisteredEntrySize) { |
2100 handler_name ^= handlers.At(i + kRegisteredNameIndex); | 2101 handler_name ^= handlers.At(i + kRegisteredNameIndex); |
2101 extensions.AddValue(handler_name.ToCString()); | 2102 extensions.AddValue(handler_name.ToCString()); |
2102 } | 2103 } |
2103 } | 2104 } |
2104 } | 2105 } |
2105 | 2106 |
2107 jsobj.AddProperty("isolateMemoryHighWatermark", | |
Cutch
2017/01/03 20:58:54
Please make this private.
bkonyi
2017/01/03 22:00:38
Done.
| |
2108 isolate_memory_high_watermark_); | |
2106 jsobj.AddProperty("threads", thread_registry_); | 2109 jsobj.AddProperty("threads", thread_registry_); |
Cutch
2017/01/03 20:58:54
this too.
bkonyi
2017/01/03 22:00:38
Done.
| |
2107 } | 2110 } |
2108 #endif | 2111 #endif |
2109 | 2112 |
2110 | 2113 |
2111 void Isolate::set_tag_table(const GrowableObjectArray& value) { | 2114 void Isolate::set_tag_table(const GrowableObjectArray& value) { |
2112 tag_table_ = value.raw(); | 2115 tag_table_ = value.raw(); |
2113 } | 2116 } |
2114 | 2117 |
2115 | 2118 |
2116 void Isolate::set_current_tag(const UserTag& tag) { | 2119 void Isolate::set_current_tag(const UserTag& tag) { |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2646 // If a safepoint operation is in progress wait for it | 2649 // If a safepoint operation is in progress wait for it |
2647 // to finish before scheduling this thread in. | 2650 // to finish before scheduling this thread in. |
2648 while (!bypass_safepoint && safepoint_handler()->SafepointInProgress()) { | 2651 while (!bypass_safepoint && safepoint_handler()->SafepointInProgress()) { |
2649 ml.Wait(); | 2652 ml.Wait(); |
2650 } | 2653 } |
2651 | 2654 |
2652 // Now get a free Thread structure. | 2655 // Now get a free Thread structure. |
2653 thread = thread_registry()->GetFreeThreadLocked(this, is_mutator); | 2656 thread = thread_registry()->GetFreeThreadLocked(this, is_mutator); |
2654 ASSERT(thread != NULL); | 2657 ASSERT(thread != NULL); |
2655 | 2658 |
2659 thread->ResetHighWatermark(); | |
Cutch
2017/01/03 20:58:54
why would we be resetting the high watermark when
bkonyi
2017/01/03 22:00:38
I was thinking once a thread was no longer being u
Cutch
2017/01/03 22:28:00
No this was me remembering the way the threads *us
| |
2660 | |
2656 // Set up other values and set the TLS value. | 2661 // Set up other values and set the TLS value. |
2657 thread->isolate_ = this; | 2662 thread->isolate_ = this; |
2658 ASSERT(heap() != NULL); | 2663 ASSERT(heap() != NULL); |
2659 thread->heap_ = heap(); | 2664 thread->heap_ = heap(); |
2660 thread->set_os_thread(os_thread); | 2665 thread->set_os_thread(os_thread); |
2661 ASSERT(thread->execution_state() == Thread::kThreadInNative); | 2666 ASSERT(thread->execution_state() == Thread::kThreadInNative); |
2662 thread->set_execution_state(Thread::kThreadInVM); | 2667 thread->set_execution_state(Thread::kThreadInVM); |
2663 thread->set_safepoint_state(0); | 2668 thread->set_safepoint_state(0); |
2664 thread->set_vm_tag(VMTag::kVMTagId); | 2669 thread->set_vm_tag(VMTag::kVMTagId); |
2665 ASSERT(thread->no_safepoint_scope_depth() == 0); | 2670 ASSERT(thread->no_safepoint_scope_depth() == 0); |
(...skipping 26 matching lines...) Expand all Loading... | |
2692 thread->clear_sticky_error(); | 2697 thread->clear_sticky_error(); |
2693 } | 2698 } |
2694 } else { | 2699 } else { |
2695 ASSERT(thread->api_top_scope_ == NULL); | 2700 ASSERT(thread->api_top_scope_ == NULL); |
2696 ASSERT(thread->zone_ == NULL); | 2701 ASSERT(thread->zone_ == NULL); |
2697 } | 2702 } |
2698 if (!bypass_safepoint) { | 2703 if (!bypass_safepoint) { |
2699 // Ensure that the thread reports itself as being at a safepoint. | 2704 // Ensure that the thread reports itself as being at a safepoint. |
2700 thread->EnterSafepoint(); | 2705 thread->EnterSafepoint(); |
2701 } | 2706 } |
2707 UpdateIsolateHighWatermark(); | |
2702 OSThread* os_thread = thread->os_thread(); | 2708 OSThread* os_thread = thread->os_thread(); |
2703 ASSERT(os_thread != NULL); | 2709 ASSERT(os_thread != NULL); |
2704 os_thread->DisableThreadInterrupts(); | 2710 os_thread->DisableThreadInterrupts(); |
2705 os_thread->set_thread(NULL); | 2711 os_thread->set_thread(NULL); |
2706 OSThread::SetCurrent(os_thread); | 2712 OSThread::SetCurrent(os_thread); |
2707 if (is_mutator) { | 2713 if (is_mutator) { |
2708 mutator_thread_ = NULL; | 2714 mutator_thread_ = NULL; |
2709 } | 2715 } |
2710 thread->isolate_ = NULL; | 2716 thread->isolate_ = NULL; |
2711 thread->heap_ = NULL; | 2717 thread->heap_ = NULL; |
2712 thread->set_os_thread(NULL); | 2718 thread->set_os_thread(NULL); |
2713 thread->set_execution_state(Thread::kThreadInNative); | 2719 thread->set_execution_state(Thread::kThreadInNative); |
2714 thread->set_safepoint_state(Thread::SetAtSafepoint(true, 0)); | 2720 thread->set_safepoint_state(Thread::SetAtSafepoint(true, 0)); |
2715 thread->clear_pending_functions(); | 2721 thread->clear_pending_functions(); |
2716 ASSERT(thread->no_safepoint_scope_depth() == 0); | 2722 ASSERT(thread->no_safepoint_scope_depth() == 0); |
2717 // Return thread structure. | 2723 // Return thread structure. |
2718 thread_registry()->ReturnThreadLocked(is_mutator, thread); | 2724 thread_registry()->ReturnThreadLocked(is_mutator, thread); |
2719 } | 2725 } |
2720 | 2726 |
2721 | 2727 |
2728 void Isolate::UpdateIsolateHighWatermark() { | |
2729 intptr_t thread_watermarks_total = | |
Cutch
2017/01/03 20:58:54
const intptr_t ...
Also, try and use more descrip
bkonyi
2017/01/03 22:00:38
Done.
| |
2730 thread_registry()->ThreadHighWatermarksTotalLocked(); | |
2731 if (thread_watermarks_total > isolate_memory_high_watermark_) { | |
2732 isolate_memory_high_watermark_ = thread_watermarks_total; | |
2733 } | |
2734 } | |
2735 | |
2736 | |
2722 static RawInstance* DeserializeObject(Thread* thread, | 2737 static RawInstance* DeserializeObject(Thread* thread, |
2723 uint8_t* obj_data, | 2738 uint8_t* obj_data, |
2724 intptr_t obj_len) { | 2739 intptr_t obj_len) { |
2725 if (obj_data == NULL) { | 2740 if (obj_data == NULL) { |
2726 return Instance::null(); | 2741 return Instance::null(); |
2727 } | 2742 } |
2728 MessageSnapshotReader reader(obj_data, obj_len, thread); | 2743 MessageSnapshotReader reader(obj_data, obj_len, thread); |
2729 Zone* zone = thread->zone(); | 2744 Zone* zone = thread->zone(); |
2730 const Object& obj = Object::Handle(zone, reader.ReadObject()); | 2745 const Object& obj = Object::Handle(zone, reader.ReadObject()); |
2731 ASSERT(!obj.IsError()); | 2746 ASSERT(!obj.IsError()); |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2948 void IsolateSpawnState::DecrementSpawnCount() { | 2963 void IsolateSpawnState::DecrementSpawnCount() { |
2949 ASSERT(spawn_count_monitor_ != NULL); | 2964 ASSERT(spawn_count_monitor_ != NULL); |
2950 ASSERT(spawn_count_ != NULL); | 2965 ASSERT(spawn_count_ != NULL); |
2951 MonitorLocker ml(spawn_count_monitor_); | 2966 MonitorLocker ml(spawn_count_monitor_); |
2952 ASSERT(*spawn_count_ > 0); | 2967 ASSERT(*spawn_count_ > 0); |
2953 *spawn_count_ = *spawn_count_ - 1; | 2968 *spawn_count_ = *spawn_count_ - 1; |
2954 ml.Notify(); | 2969 ml.Notify(); |
2955 } | 2970 } |
2956 | 2971 |
2957 } // namespace dart | 2972 } // namespace dart |
OLD | NEW |