| 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_memory_usage_(0), |
| 79 memory_high_watermark_(0), | 78 current_zone_capacity_(0), |
| 79 zone_high_watermark_(0), |
| 80 api_reusable_scope_(NULL), | 80 api_reusable_scope_(NULL), |
| 81 api_top_scope_(NULL), | 81 api_top_scope_(NULL), |
| 82 top_resource_(NULL), | 82 top_resource_(NULL), |
| 83 long_jump_base_(NULL), | 83 long_jump_base_(NULL), |
| 84 no_callback_scope_depth_(0), | 84 no_callback_scope_depth_(0), |
| 85 #if defined(DEBUG) | 85 #if defined(DEBUG) |
| 86 top_handle_scope_(NULL), | 86 top_handle_scope_(NULL), |
| 87 no_handle_scope_depth_(0), | 87 no_handle_scope_depth_(0), |
| 88 no_safepoint_scope_depth_(0), | 88 no_safepoint_scope_depth_(0), |
| 89 #endif | 89 #endif |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 130 |
| 131 if (FLAG_support_compiler_stats) { | 131 if (FLAG_support_compiler_stats) { |
| 132 compiler_stats_ = new CompilerStats(isolate); | 132 compiler_stats_ = new CompilerStats(isolate); |
| 133 if (FLAG_compiler_benchmark) { | 133 if (FLAG_compiler_benchmark) { |
| 134 compiler_stats_->EnableBenchmark(); | 134 compiler_stats_->EnableBenchmark(); |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 // This thread should not yet own any zones. If it does, we need to make sure | 137 // 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. | 138 // we've accounted for any memory it has already allocated. |
| 139 if (zone_ == NULL) { | 139 if (zone_ == NULL) { |
| 140 ASSERT(current_thread_memory_ == 0); | 140 ASSERT(current_zone_capacity_ == 0); |
| 141 } else { | 141 } else { |
| 142 Zone* current = zone_; | 142 Zone* current = zone_; |
| 143 uintptr_t total_zone_capacity = 0; | 143 uintptr_t total_zone_capacity = 0; |
| 144 while (current != NULL) { | 144 while (current != NULL) { |
| 145 total_zone_capacity += static_cast<uintptr_t>(current->CapacityInBytes()); | 145 total_zone_capacity += current->CapacityInBytes(); |
| 146 current = current->previous(); | 146 current = current->previous(); |
| 147 } | 147 } |
| 148 ASSERT(current_thread_memory_ == total_zone_capacity); | 148 ASSERT(current_zone_capacity_ == total_zone_capacity); |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 | 151 |
| 152 | 152 |
| 153 static const struct ALIGN16 { | 153 static const struct ALIGN16 { |
| 154 uint64_t a; | 154 uint64_t a; |
| 155 uint64_t b; | 155 uint64_t b; |
| 156 } double_negate_constant = {0x8000000000000000LL, 0x8000000000000000LL}; | 156 } double_negate_constant = {0x8000000000000000LL, 0x8000000000000000LL}; |
| 157 | 157 |
| 158 static const struct ALIGN16 { | 158 static const struct ALIGN16 { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 222 |
| 223 | 223 |
| 224 #ifndef PRODUCT | 224 #ifndef PRODUCT |
| 225 // Collect information about each individual zone associated with this thread. | 225 // Collect information about each individual zone associated with this thread. |
| 226 void Thread::PrintJSON(JSONStream* stream) const { | 226 void Thread::PrintJSON(JSONStream* stream) const { |
| 227 JSONObject jsobj(stream); | 227 JSONObject jsobj(stream); |
| 228 jsobj.AddProperty("type", "_Thread"); | 228 jsobj.AddProperty("type", "_Thread"); |
| 229 jsobj.AddPropertyF("id", "threads/%" Pd "", | 229 jsobj.AddPropertyF("id", "threads/%" Pd "", |
| 230 OSThread::ThreadIdToIntPtr(os_thread()->trace_id())); | 230 OSThread::ThreadIdToIntPtr(os_thread()->trace_id())); |
| 231 jsobj.AddProperty("kind", TaskKindToCString(task_kind())); | 231 jsobj.AddProperty("kind", TaskKindToCString(task_kind())); |
| 232 jsobj.AddPropertyF("_memoryHighWatermark", "%" Pu "", memory_high_watermark_); | 232 jsobj.AddPropertyF("_zoneHighWatermark", "%" Pu "", zone_high_watermark_); |
| 233 jsobj.AddPropertyF("_zoneCapacity", "%" Pu "", current_zone_capacity_); |
| 234 jsobj.AddPropertyF("_zoneUsage", "%" Pu "", current_zone_memory_usage_); |
| 233 } | 235 } |
| 234 #endif | 236 #endif |
| 235 | 237 |
| 236 | 238 |
| 237 RawGrowableObjectArray* Thread::pending_functions() { | 239 RawGrowableObjectArray* Thread::pending_functions() { |
| 238 if (pending_functions_ == GrowableObjectArray::null()) { | 240 if (pending_functions_ == GrowableObjectArray::null()) { |
| 239 pending_functions_ = GrowableObjectArray::New(Heap::kOld); | 241 pending_functions_ = GrowableObjectArray::New(Heap::kOld); |
| 240 } | 242 } |
| 241 return pending_functions_; | 243 return pending_functions_; |
| 242 } | 244 } |
| (...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 | 909 |
| 908 DisableThreadInterruptsScope::~DisableThreadInterruptsScope() { | 910 DisableThreadInterruptsScope::~DisableThreadInterruptsScope() { |
| 909 if (thread() != NULL) { | 911 if (thread() != NULL) { |
| 910 OSThread* os_thread = thread()->os_thread(); | 912 OSThread* os_thread = thread()->os_thread(); |
| 911 ASSERT(os_thread != NULL); | 913 ASSERT(os_thread != NULL); |
| 912 os_thread->EnableThreadInterrupts(); | 914 os_thread->EnableThreadInterrupts(); |
| 913 } | 915 } |
| 914 } | 916 } |
| 915 | 917 |
| 916 } // namespace dart | 918 } // namespace dart |
| OLD | NEW |