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 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 |
2106 jsobj.AddProperty("threads", thread_registry_); | 2107 jsobj.AddPropertyF("_memoryHighWatermark", "%" Pu "", memory_high_watermark_); |
| 2108 jsobj.AddProperty("_threads", thread_registry_); |
2107 } | 2109 } |
2108 #endif | 2110 #endif |
2109 | 2111 |
2110 | 2112 |
2111 void Isolate::set_tag_table(const GrowableObjectArray& value) { | 2113 void Isolate::set_tag_table(const GrowableObjectArray& value) { |
2112 tag_table_ = value.raw(); | 2114 tag_table_ = value.raw(); |
2113 } | 2115 } |
2114 | 2116 |
2115 | 2117 |
2116 void Isolate::set_current_tag(const UserTag& tag) { | 2118 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 | 2648 // If a safepoint operation is in progress wait for it |
2647 // to finish before scheduling this thread in. | 2649 // to finish before scheduling this thread in. |
2648 while (!bypass_safepoint && safepoint_handler()->SafepointInProgress()) { | 2650 while (!bypass_safepoint && safepoint_handler()->SafepointInProgress()) { |
2649 ml.Wait(); | 2651 ml.Wait(); |
2650 } | 2652 } |
2651 | 2653 |
2652 // Now get a free Thread structure. | 2654 // Now get a free Thread structure. |
2653 thread = thread_registry()->GetFreeThreadLocked(this, is_mutator); | 2655 thread = thread_registry()->GetFreeThreadLocked(this, is_mutator); |
2654 ASSERT(thread != NULL); | 2656 ASSERT(thread != NULL); |
2655 | 2657 |
| 2658 thread->ResetHighWatermark(); |
| 2659 |
2656 // Set up other values and set the TLS value. | 2660 // Set up other values and set the TLS value. |
2657 thread->isolate_ = this; | 2661 thread->isolate_ = this; |
2658 ASSERT(heap() != NULL); | 2662 ASSERT(heap() != NULL); |
2659 thread->heap_ = heap(); | 2663 thread->heap_ = heap(); |
2660 thread->set_os_thread(os_thread); | 2664 thread->set_os_thread(os_thread); |
2661 ASSERT(thread->execution_state() == Thread::kThreadInNative); | 2665 ASSERT(thread->execution_state() == Thread::kThreadInNative); |
2662 thread->set_execution_state(Thread::kThreadInVM); | 2666 thread->set_execution_state(Thread::kThreadInVM); |
2663 thread->set_safepoint_state(0); | 2667 thread->set_safepoint_state(0); |
2664 thread->set_vm_tag(VMTag::kVMTagId); | 2668 thread->set_vm_tag(VMTag::kVMTagId); |
2665 ASSERT(thread->no_safepoint_scope_depth() == 0); | 2669 ASSERT(thread->no_safepoint_scope_depth() == 0); |
(...skipping 26 matching lines...) Expand all Loading... |
2692 thread->clear_sticky_error(); | 2696 thread->clear_sticky_error(); |
2693 } | 2697 } |
2694 } else { | 2698 } else { |
2695 ASSERT(thread->api_top_scope_ == NULL); | 2699 ASSERT(thread->api_top_scope_ == NULL); |
2696 ASSERT(thread->zone_ == NULL); | 2700 ASSERT(thread->zone_ == NULL); |
2697 } | 2701 } |
2698 if (!bypass_safepoint) { | 2702 if (!bypass_safepoint) { |
2699 // Ensure that the thread reports itself as being at a safepoint. | 2703 // Ensure that the thread reports itself as being at a safepoint. |
2700 thread->EnterSafepoint(); | 2704 thread->EnterSafepoint(); |
2701 } | 2705 } |
| 2706 UpdateMemoryHighWatermark(); |
2702 OSThread* os_thread = thread->os_thread(); | 2707 OSThread* os_thread = thread->os_thread(); |
2703 ASSERT(os_thread != NULL); | 2708 ASSERT(os_thread != NULL); |
2704 os_thread->DisableThreadInterrupts(); | 2709 os_thread->DisableThreadInterrupts(); |
2705 os_thread->set_thread(NULL); | 2710 os_thread->set_thread(NULL); |
2706 OSThread::SetCurrent(os_thread); | 2711 OSThread::SetCurrent(os_thread); |
2707 if (is_mutator) { | 2712 if (is_mutator) { |
2708 mutator_thread_ = NULL; | 2713 mutator_thread_ = NULL; |
2709 } | 2714 } |
2710 thread->isolate_ = NULL; | 2715 thread->isolate_ = NULL; |
2711 thread->heap_ = NULL; | 2716 thread->heap_ = NULL; |
2712 thread->set_os_thread(NULL); | 2717 thread->set_os_thread(NULL); |
2713 thread->set_execution_state(Thread::kThreadInNative); | 2718 thread->set_execution_state(Thread::kThreadInNative); |
2714 thread->set_safepoint_state(Thread::SetAtSafepoint(true, 0)); | 2719 thread->set_safepoint_state(Thread::SetAtSafepoint(true, 0)); |
2715 thread->clear_pending_functions(); | 2720 thread->clear_pending_functions(); |
2716 ASSERT(thread->no_safepoint_scope_depth() == 0); | 2721 ASSERT(thread->no_safepoint_scope_depth() == 0); |
2717 // Return thread structure. | 2722 // Return thread structure. |
2718 thread_registry()->ReturnThreadLocked(is_mutator, thread); | 2723 thread_registry()->ReturnThreadLocked(is_mutator, thread); |
2719 } | 2724 } |
2720 | 2725 |
2721 | 2726 |
| 2727 void Isolate::UpdateMemoryHighWatermark() { |
| 2728 const uintptr_t thread_watermarks_total = |
| 2729 thread_registry()->ThreadHighWatermarksTotalLocked(); |
| 2730 if (thread_watermarks_total > memory_high_watermark_) { |
| 2731 memory_high_watermark_ = thread_watermarks_total; |
| 2732 } |
| 2733 } |
| 2734 |
| 2735 |
2722 static RawInstance* DeserializeObject(Thread* thread, | 2736 static RawInstance* DeserializeObject(Thread* thread, |
2723 uint8_t* obj_data, | 2737 uint8_t* obj_data, |
2724 intptr_t obj_len) { | 2738 intptr_t obj_len) { |
2725 if (obj_data == NULL) { | 2739 if (obj_data == NULL) { |
2726 return Instance::null(); | 2740 return Instance::null(); |
2727 } | 2741 } |
2728 MessageSnapshotReader reader(obj_data, obj_len, thread); | 2742 MessageSnapshotReader reader(obj_data, obj_len, thread); |
2729 Zone* zone = thread->zone(); | 2743 Zone* zone = thread->zone(); |
2730 const Object& obj = Object::Handle(zone, reader.ReadObject()); | 2744 const Object& obj = Object::Handle(zone, reader.ReadObject()); |
2731 ASSERT(!obj.IsError()); | 2745 ASSERT(!obj.IsError()); |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2948 void IsolateSpawnState::DecrementSpawnCount() { | 2962 void IsolateSpawnState::DecrementSpawnCount() { |
2949 ASSERT(spawn_count_monitor_ != NULL); | 2963 ASSERT(spawn_count_monitor_ != NULL); |
2950 ASSERT(spawn_count_ != NULL); | 2964 ASSERT(spawn_count_ != NULL); |
2951 MonitorLocker ml(spawn_count_monitor_); | 2965 MonitorLocker ml(spawn_count_monitor_); |
2952 ASSERT(*spawn_count_ > 0); | 2966 ASSERT(*spawn_count_ > 0); |
2953 *spawn_count_ = *spawn_count_ - 1; | 2967 *spawn_count_ = *spawn_count_ - 1; |
2954 ml.Notify(); | 2968 ml.Notify(); |
2955 } | 2969 } |
2956 | 2970 |
2957 } // namespace dart | 2971 } // namespace dart |
OLD | NEW |