| 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 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 : store_buffer_(new StoreBuffer()), | 776 : store_buffer_(new StoreBuffer()), |
| 777 heap_(NULL), | 777 heap_(NULL), |
| 778 user_tag_(0), | 778 user_tag_(0), |
| 779 current_tag_(UserTag::null()), | 779 current_tag_(UserTag::null()), |
| 780 default_tag_(UserTag::null()), | 780 default_tag_(UserTag::null()), |
| 781 object_store_(NULL), | 781 object_store_(NULL), |
| 782 class_table_(), | 782 class_table_(), |
| 783 single_step_(false), | 783 single_step_(false), |
| 784 thread_registry_(new ThreadRegistry()), | 784 thread_registry_(new ThreadRegistry()), |
| 785 safepoint_handler_(new SafepointHandler(this)), | 785 safepoint_handler_(new SafepointHandler(this)), |
| 786 memory_high_watermark_(0), | |
| 787 message_notify_callback_(NULL), | 786 message_notify_callback_(NULL), |
| 788 name_(NULL), | 787 name_(NULL), |
| 789 debugger_name_(NULL), | 788 debugger_name_(NULL), |
| 790 start_time_micros_(OS::GetCurrentMonotonicMicros()), | 789 start_time_micros_(OS::GetCurrentMonotonicMicros()), |
| 791 main_port_(0), | 790 main_port_(0), |
| 792 origin_id_(0), | 791 origin_id_(0), |
| 793 pause_capability_(0), | 792 pause_capability_(0), |
| 794 terminate_capability_(0), | 793 terminate_capability_(0), |
| 795 errors_fatal_(true), | 794 errors_fatal_(true), |
| 796 init_callback_data_(NULL), | 795 init_callback_data_(NULL), |
| (...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2111 if (!handlers.IsNull()) { | 2110 if (!handlers.IsNull()) { |
| 2112 JSONArray extensions(&jsobj, "extensionRPCs"); | 2111 JSONArray extensions(&jsobj, "extensionRPCs"); |
| 2113 String& handler_name = String::Handle(); | 2112 String& handler_name = String::Handle(); |
| 2114 for (intptr_t i = 0; i < handlers.Length(); i += kRegisteredEntrySize) { | 2113 for (intptr_t i = 0; i < handlers.Length(); i += kRegisteredEntrySize) { |
| 2115 handler_name ^= handlers.At(i + kRegisteredNameIndex); | 2114 handler_name ^= handlers.At(i + kRegisteredNameIndex); |
| 2116 extensions.AddValue(handler_name.ToCString()); | 2115 extensions.AddValue(handler_name.ToCString()); |
| 2117 } | 2116 } |
| 2118 } | 2117 } |
| 2119 } | 2118 } |
| 2120 | 2119 |
| 2121 jsobj.AddPropertyF("_memoryHighWatermark", "%" Pu "", memory_high_watermark_); | |
| 2122 jsobj.AddProperty("_threads", thread_registry_); | 2120 jsobj.AddProperty("_threads", thread_registry_); |
| 2123 } | 2121 } |
| 2124 #endif | 2122 #endif |
| 2125 | 2123 |
| 2126 | 2124 |
| 2127 void Isolate::set_tag_table(const GrowableObjectArray& value) { | 2125 void Isolate::set_tag_table(const GrowableObjectArray& value) { |
| 2128 tag_table_ = value.raw(); | 2126 tag_table_ = value.raw(); |
| 2129 } | 2127 } |
| 2130 | 2128 |
| 2131 | 2129 |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2710 thread->clear_sticky_error(); | 2708 thread->clear_sticky_error(); |
| 2711 } | 2709 } |
| 2712 } else { | 2710 } else { |
| 2713 ASSERT(thread->api_top_scope_ == NULL); | 2711 ASSERT(thread->api_top_scope_ == NULL); |
| 2714 ASSERT(thread->zone_ == NULL); | 2712 ASSERT(thread->zone_ == NULL); |
| 2715 } | 2713 } |
| 2716 if (!bypass_safepoint) { | 2714 if (!bypass_safepoint) { |
| 2717 // Ensure that the thread reports itself as being at a safepoint. | 2715 // Ensure that the thread reports itself as being at a safepoint. |
| 2718 thread->EnterSafepoint(); | 2716 thread->EnterSafepoint(); |
| 2719 } | 2717 } |
| 2720 UpdateMemoryHighWatermark(); | |
| 2721 OSThread* os_thread = thread->os_thread(); | 2718 OSThread* os_thread = thread->os_thread(); |
| 2722 ASSERT(os_thread != NULL); | 2719 ASSERT(os_thread != NULL); |
| 2723 os_thread->DisableThreadInterrupts(); | 2720 os_thread->DisableThreadInterrupts(); |
| 2724 os_thread->set_thread(NULL); | 2721 os_thread->set_thread(NULL); |
| 2725 OSThread::SetCurrent(os_thread); | 2722 OSThread::SetCurrent(os_thread); |
| 2726 if (is_mutator) { | 2723 if (is_mutator) { |
| 2727 mutator_thread_ = NULL; | 2724 mutator_thread_ = NULL; |
| 2728 } | 2725 } |
| 2729 thread->isolate_ = NULL; | 2726 thread->isolate_ = NULL; |
| 2730 thread->heap_ = NULL; | 2727 thread->heap_ = NULL; |
| 2731 thread->set_os_thread(NULL); | 2728 thread->set_os_thread(NULL); |
| 2732 thread->set_execution_state(Thread::kThreadInNative); | 2729 thread->set_execution_state(Thread::kThreadInNative); |
| 2733 thread->set_safepoint_state(Thread::SetAtSafepoint(true, 0)); | 2730 thread->set_safepoint_state(Thread::SetAtSafepoint(true, 0)); |
| 2734 thread->clear_pending_functions(); | 2731 thread->clear_pending_functions(); |
| 2735 ASSERT(thread->no_safepoint_scope_depth() == 0); | 2732 ASSERT(thread->no_safepoint_scope_depth() == 0); |
| 2736 // Return thread structure. | 2733 // Return thread structure. |
| 2737 thread_registry()->ReturnThreadLocked(is_mutator, thread); | 2734 thread_registry()->ReturnThreadLocked(is_mutator, thread); |
| 2738 } | 2735 } |
| 2739 | 2736 |
| 2740 | 2737 |
| 2741 void Isolate::UpdateMemoryHighWatermark() { | |
| 2742 const uintptr_t thread_watermarks_total = | |
| 2743 thread_registry()->ThreadHighWatermarksTotalLocked(); | |
| 2744 if (thread_watermarks_total > memory_high_watermark_) { | |
| 2745 memory_high_watermark_ = thread_watermarks_total; | |
| 2746 } | |
| 2747 } | |
| 2748 | |
| 2749 | |
| 2750 static RawInstance* DeserializeObject(Thread* thread, | 2738 static RawInstance* DeserializeObject(Thread* thread, |
| 2751 uint8_t* obj_data, | 2739 uint8_t* obj_data, |
| 2752 intptr_t obj_len) { | 2740 intptr_t obj_len) { |
| 2753 if (obj_data == NULL) { | 2741 if (obj_data == NULL) { |
| 2754 return Instance::null(); | 2742 return Instance::null(); |
| 2755 } | 2743 } |
| 2756 MessageSnapshotReader reader(obj_data, obj_len, thread); | 2744 MessageSnapshotReader reader(obj_data, obj_len, thread); |
| 2757 Zone* zone = thread->zone(); | 2745 Zone* zone = thread->zone(); |
| 2758 const Object& obj = Object::Handle(zone, reader.ReadObject()); | 2746 const Object& obj = Object::Handle(zone, reader.ReadObject()); |
| 2759 ASSERT(!obj.IsError()); | 2747 ASSERT(!obj.IsError()); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2973 void IsolateSpawnState::DecrementSpawnCount() { | 2961 void IsolateSpawnState::DecrementSpawnCount() { |
| 2974 ASSERT(spawn_count_monitor_ != NULL); | 2962 ASSERT(spawn_count_monitor_ != NULL); |
| 2975 ASSERT(spawn_count_ != NULL); | 2963 ASSERT(spawn_count_ != NULL); |
| 2976 MonitorLocker ml(spawn_count_monitor_); | 2964 MonitorLocker ml(spawn_count_monitor_); |
| 2977 ASSERT(*spawn_count_ > 0); | 2965 ASSERT(*spawn_count_ > 0); |
| 2978 *spawn_count_ = *spawn_count_ - 1; | 2966 *spawn_count_ = *spawn_count_ - 1; |
| 2979 ml.Notify(); | 2967 ml.Notify(); |
| 2980 } | 2968 } |
| 2981 | 2969 |
| 2982 } // namespace dart | 2970 } // namespace dart |
| OLD | NEW |