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