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 2085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2096 if (!handlers.IsNull()) { | 2096 if (!handlers.IsNull()) { |
2097 JSONArray extensions(&jsobj, "extensionRPCs"); | 2097 JSONArray extensions(&jsobj, "extensionRPCs"); |
2098 String& handler_name = String::Handle(); | 2098 String& handler_name = String::Handle(); |
2099 for (intptr_t i = 0; i < handlers.Length(); i += kRegisteredEntrySize) { | 2099 for (intptr_t i = 0; i < handlers.Length(); i += kRegisteredEntrySize) { |
2100 handler_name ^= handlers.At(i + kRegisteredNameIndex); | 2100 handler_name ^= handlers.At(i + kRegisteredNameIndex); |
2101 extensions.AddValue(handler_name.ToCString()); | 2101 extensions.AddValue(handler_name.ToCString()); |
2102 } | 2102 } |
2103 } | 2103 } |
2104 } | 2104 } |
2105 | 2105 |
| 2106 jsobj.AddProperty("isolateMemoryHighWatermark", |
| 2107 isolate_memory_high_watermark_); |
2106 jsobj.AddProperty("threads", thread_registry_); | 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 |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2692 thread->clear_sticky_error(); | 2694 thread->clear_sticky_error(); |
2693 } | 2695 } |
2694 } else { | 2696 } else { |
2695 ASSERT(thread->api_top_scope_ == NULL); | 2697 ASSERT(thread->api_top_scope_ == NULL); |
2696 ASSERT(thread->zone_ == NULL); | 2698 ASSERT(thread->zone_ == NULL); |
2697 } | 2699 } |
2698 if (!bypass_safepoint) { | 2700 if (!bypass_safepoint) { |
2699 // Ensure that the thread reports itself as being at a safepoint. | 2701 // Ensure that the thread reports itself as being at a safepoint. |
2700 thread->EnterSafepoint(); | 2702 thread->EnterSafepoint(); |
2701 } | 2703 } |
| 2704 UpdateIsolateHighWatermark(); |
2702 OSThread* os_thread = thread->os_thread(); | 2705 OSThread* os_thread = thread->os_thread(); |
2703 ASSERT(os_thread != NULL); | 2706 ASSERT(os_thread != NULL); |
2704 os_thread->DisableThreadInterrupts(); | 2707 os_thread->DisableThreadInterrupts(); |
2705 os_thread->set_thread(NULL); | 2708 os_thread->set_thread(NULL); |
2706 OSThread::SetCurrent(os_thread); | 2709 OSThread::SetCurrent(os_thread); |
2707 if (is_mutator) { | 2710 if (is_mutator) { |
2708 mutator_thread_ = NULL; | 2711 mutator_thread_ = NULL; |
2709 } | 2712 } |
2710 thread->isolate_ = NULL; | 2713 thread->isolate_ = NULL; |
2711 thread->heap_ = NULL; | 2714 thread->heap_ = NULL; |
2712 thread->set_os_thread(NULL); | 2715 thread->set_os_thread(NULL); |
2713 thread->set_execution_state(Thread::kThreadInNative); | 2716 thread->set_execution_state(Thread::kThreadInNative); |
2714 thread->set_safepoint_state(Thread::SetAtSafepoint(true, 0)); | 2717 thread->set_safepoint_state(Thread::SetAtSafepoint(true, 0)); |
2715 thread->clear_pending_functions(); | 2718 thread->clear_pending_functions(); |
| 2719 thread->ClearThreadMemoryUsageStats(); |
2716 ASSERT(thread->no_safepoint_scope_depth() == 0); | 2720 ASSERT(thread->no_safepoint_scope_depth() == 0); |
2717 // Return thread structure. | 2721 // Return thread structure. |
2718 thread_registry()->ReturnThreadLocked(is_mutator, thread); | 2722 thread_registry()->ReturnThreadLocked(is_mutator, thread); |
2719 } | 2723 } |
2720 | 2724 |
2721 | 2725 |
| 2726 void Isolate::UpdateIsolateHighWatermark() { |
| 2727 intptr_t thread_watermarks_total = |
| 2728 thread_registry()->ThreadHighWatermarksTotalLocked(); |
| 2729 if (thread_watermarks_total > isolate_memory_high_watermark_) { |
| 2730 isolate_memory_high_watermark_ = thread_watermarks_total; |
| 2731 } |
| 2732 } |
| 2733 |
| 2734 |
2722 static RawInstance* DeserializeObject(Thread* thread, | 2735 static RawInstance* DeserializeObject(Thread* thread, |
2723 uint8_t* obj_data, | 2736 uint8_t* obj_data, |
2724 intptr_t obj_len) { | 2737 intptr_t obj_len) { |
2725 if (obj_data == NULL) { | 2738 if (obj_data == NULL) { |
2726 return Instance::null(); | 2739 return Instance::null(); |
2727 } | 2740 } |
2728 MessageSnapshotReader reader(obj_data, obj_len, thread); | 2741 MessageSnapshotReader reader(obj_data, obj_len, thread); |
2729 Zone* zone = thread->zone(); | 2742 Zone* zone = thread->zone(); |
2730 const Object& obj = Object::Handle(zone, reader.ReadObject()); | 2743 const Object& obj = Object::Handle(zone, reader.ReadObject()); |
2731 ASSERT(!obj.IsError()); | 2744 ASSERT(!obj.IsError()); |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2948 void IsolateSpawnState::DecrementSpawnCount() { | 2961 void IsolateSpawnState::DecrementSpawnCount() { |
2949 ASSERT(spawn_count_monitor_ != NULL); | 2962 ASSERT(spawn_count_monitor_ != NULL); |
2950 ASSERT(spawn_count_ != NULL); | 2963 ASSERT(spawn_count_ != NULL); |
2951 MonitorLocker ml(spawn_count_monitor_); | 2964 MonitorLocker ml(spawn_count_monitor_); |
2952 ASSERT(*spawn_count_ > 0); | 2965 ASSERT(*spawn_count_ > 0); |
2953 *spawn_count_ = *spawn_count_ - 1; | 2966 *spawn_count_ = *spawn_count_ - 1; |
2954 ml.Notify(); | 2967 ml.Notify(); |
2955 } | 2968 } |
2956 | 2969 |
2957 } // namespace dart | 2970 } // namespace dart |
OLD | NEW |