OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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/thread.h" | 5 #include "vm/thread.h" |
6 | 6 |
7 #include "vm/compiler_stats.h" | 7 #include "vm/compiler_stats.h" |
8 #include "vm/dart_api_state.h" | 8 #include "vm/dart_api_state.h" |
9 #include "vm/growable_array.h" | 9 #include "vm/growable_array.h" |
10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 ASSERT(api_top_scope() == NULL); | 42 ASSERT(api_top_scope() == NULL); |
43 // Delete the resusable api scope if there is one. | 43 // Delete the resusable api scope if there is one. |
44 if (api_reusable_scope_) { | 44 if (api_reusable_scope_) { |
45 delete api_reusable_scope_; | 45 delete api_reusable_scope_; |
46 api_reusable_scope_ = NULL; | 46 api_reusable_scope_ = NULL; |
47 } | 47 } |
48 delete thread_lock_; | 48 delete thread_lock_; |
49 thread_lock_ = NULL; | 49 thread_lock_ = NULL; |
50 } | 50 } |
51 | 51 |
52 | |
53 #if defined(DEBUG) | 52 #if defined(DEBUG) |
54 #define REUSABLE_HANDLE_SCOPE_INIT(object) \ | 53 #define REUSABLE_HANDLE_SCOPE_INIT(object) \ |
55 reusable_##object##_handle_scope_active_(false), | 54 reusable_##object##_handle_scope_active_(false), |
56 #else | 55 #else |
57 #define REUSABLE_HANDLE_SCOPE_INIT(object) | 56 #define REUSABLE_HANDLE_SCOPE_INIT(object) |
58 #endif // defined(DEBUG) | 57 #endif // defined(DEBUG) |
59 | 58 |
60 #define REUSABLE_HANDLE_INITIALIZERS(object) object##_handle_(NULL), | 59 #define REUSABLE_HANDLE_INITIALIZERS(object) object##_handle_(NULL), |
61 | 60 |
62 | 61 |
63 Thread::Thread(Isolate* isolate) | 62 Thread::Thread(Isolate* isolate) |
64 : BaseThread(false), | 63 : BaseThread(false), |
65 stack_limit_(0), | 64 stack_limit_(0), |
66 stack_overflow_flags_(0), | 65 stack_overflow_flags_(0), |
67 isolate_(NULL), | 66 isolate_(NULL), |
68 heap_(NULL), | 67 heap_(NULL), |
69 top_exit_frame_info_(0), | 68 top_exit_frame_info_(0), |
70 store_buffer_block_(NULL), | 69 store_buffer_block_(NULL), |
71 vm_tag_(0), | 70 vm_tag_(0), |
72 task_kind_(kUnknownTask), | 71 task_kind_(kUnknownTask), |
73 async_stack_trace_(StackTrace::null()), | 72 async_stack_trace_(StackTrace::null()), |
74 dart_stream_(NULL), | 73 dart_stream_(NULL), |
75 os_thread_(NULL), | 74 os_thread_(NULL), |
76 thread_lock_(new Monitor()), | 75 thread_lock_(new Monitor()), |
77 zone_(NULL), | 76 zone_(NULL), |
78 current_thread_memory_(0), | 77 current_zone_capacity_(0), |
79 memory_high_watermark_(0), | 78 zone_high_watermark_(0), |
80 api_reusable_scope_(NULL), | 79 api_reusable_scope_(NULL), |
81 api_top_scope_(NULL), | 80 api_top_scope_(NULL), |
82 top_resource_(NULL), | 81 top_resource_(NULL), |
83 long_jump_base_(NULL), | 82 long_jump_base_(NULL), |
84 no_callback_scope_depth_(0), | 83 no_callback_scope_depth_(0), |
85 #if defined(DEBUG) | 84 #if defined(DEBUG) |
86 top_handle_scope_(NULL), | 85 top_handle_scope_(NULL), |
87 no_handle_scope_depth_(0), | 86 no_handle_scope_depth_(0), |
88 no_safepoint_scope_depth_(0), | 87 no_safepoint_scope_depth_(0), |
89 #endif | 88 #endif |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 129 |
131 if (FLAG_support_compiler_stats) { | 130 if (FLAG_support_compiler_stats) { |
132 compiler_stats_ = new CompilerStats(isolate); | 131 compiler_stats_ = new CompilerStats(isolate); |
133 if (FLAG_compiler_benchmark) { | 132 if (FLAG_compiler_benchmark) { |
134 compiler_stats_->EnableBenchmark(); | 133 compiler_stats_->EnableBenchmark(); |
135 } | 134 } |
136 } | 135 } |
137 // This thread should not yet own any zones. If it does, we need to make sure | 136 // This thread should not yet own any zones. If it does, we need to make sure |
138 // we've accounted for any memory it has already allocated. | 137 // we've accounted for any memory it has already allocated. |
139 if (zone_ == NULL) { | 138 if (zone_ == NULL) { |
140 ASSERT(current_thread_memory_ == 0); | 139 ASSERT(current_zone_capacity_ == 0); |
141 } else { | 140 } else { |
142 Zone* current = zone_; | 141 Zone* current = zone_; |
143 uintptr_t total_zone_capacity = 0; | 142 uintptr_t total_zone_capacity = 0; |
144 while (current != NULL) { | 143 while (current != NULL) { |
145 total_zone_capacity += static_cast<uintptr_t>(current->CapacityInBytes()); | 144 total_zone_capacity += current->CapacityInBytes(); |
146 current = current->previous(); | 145 current = current->previous(); |
147 } | 146 } |
148 ASSERT(current_thread_memory_ == total_zone_capacity); | 147 ASSERT(current_zone_capacity_ == total_zone_capacity); |
149 } | 148 } |
150 } | 149 } |
151 | 150 |
152 | 151 |
153 static const struct ALIGN16 { | 152 static const struct ALIGN16 { |
154 uint64_t a; | 153 uint64_t a; |
155 uint64_t b; | 154 uint64_t b; |
156 } double_negate_constant = {0x8000000000000000LL, 0x8000000000000000LL}; | 155 } double_negate_constant = {0x8000000000000000LL, 0x8000000000000000LL}; |
157 | 156 |
158 static const struct ALIGN16 { | 157 static const struct ALIGN16 { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 | 221 |
223 | 222 |
224 #ifndef PRODUCT | 223 #ifndef PRODUCT |
225 // Collect information about each individual zone associated with this thread. | 224 // Collect information about each individual zone associated with this thread. |
226 void Thread::PrintJSON(JSONStream* stream) const { | 225 void Thread::PrintJSON(JSONStream* stream) const { |
227 JSONObject jsobj(stream); | 226 JSONObject jsobj(stream); |
228 jsobj.AddProperty("type", "_Thread"); | 227 jsobj.AddProperty("type", "_Thread"); |
229 jsobj.AddPropertyF("id", "threads/%" Pd "", | 228 jsobj.AddPropertyF("id", "threads/%" Pd "", |
230 OSThread::ThreadIdToIntPtr(os_thread()->trace_id())); | 229 OSThread::ThreadIdToIntPtr(os_thread()->trace_id())); |
231 jsobj.AddProperty("kind", TaskKindToCString(task_kind())); | 230 jsobj.AddProperty("kind", TaskKindToCString(task_kind())); |
232 jsobj.AddPropertyF("_memoryHighWatermark", "%" Pu "", memory_high_watermark_); | 231 jsobj.AddPropertyF("_zoneHighWatermark", "%" Pu "", zone_high_watermark_); |
| 232 jsobj.AddPropertyF("_zoneCapacity", "%" Pu "", current_zone_capacity_); |
233 } | 233 } |
234 #endif | 234 #endif |
235 | 235 |
236 | 236 |
237 RawGrowableObjectArray* Thread::pending_functions() { | 237 RawGrowableObjectArray* Thread::pending_functions() { |
238 if (pending_functions_ == GrowableObjectArray::null()) { | 238 if (pending_functions_ == GrowableObjectArray::null()) { |
239 pending_functions_ = GrowableObjectArray::New(Heap::kOld); | 239 pending_functions_ = GrowableObjectArray::New(Heap::kOld); |
240 } | 240 } |
241 return pending_functions_; | 241 return pending_functions_; |
242 } | 242 } |
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 | 907 |
908 DisableThreadInterruptsScope::~DisableThreadInterruptsScope() { | 908 DisableThreadInterruptsScope::~DisableThreadInterruptsScope() { |
909 if (thread() != NULL) { | 909 if (thread() != NULL) { |
910 OSThread* os_thread = thread()->os_thread(); | 910 OSThread* os_thread = thread()->os_thread(); |
911 ASSERT(os_thread != NULL); | 911 ASSERT(os_thread != NULL); |
912 os_thread->EnableThreadInterrupts(); | 912 os_thread->EnableThreadInterrupts(); |
913 } | 913 } |
914 } | 914 } |
915 | 915 |
916 } // namespace dart | 916 } // namespace dart |
OLD | NEW |