Chromium Code Reviews| 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/growable_array.h" | 7 #include "vm/growable_array.h" |
| 8 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
| 9 #include "vm/lockers.h" | 9 #include "vm/lockers.h" |
| 10 #include "vm/log.h" | |
| 10 #include "vm/object.h" | 11 #include "vm/object.h" |
| 11 #include "vm/os_thread.h" | 12 #include "vm/os_thread.h" |
| 12 #include "vm/profiler.h" | 13 #include "vm/profiler.h" |
| 13 #include "vm/runtime_entry.h" | 14 #include "vm/runtime_entry.h" |
| 14 #include "vm/stub_code.h" | 15 #include "vm/stub_code.h" |
| 15 #include "vm/symbols.h" | 16 #include "vm/symbols.h" |
| 16 #include "vm/thread_interrupter.h" | 17 #include "vm/thread_interrupter.h" |
| 17 #include "vm/thread_registry.h" | 18 #include "vm/thread_registry.h" |
| 18 | 19 |
| 19 namespace dart { | 20 namespace dart { |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 45 delete reinterpret_cast<Thread*>(thread); | 46 delete reinterpret_cast<Thread*>(thread); |
| 46 } | 47 } |
| 47 | 48 |
| 48 | 49 |
| 49 Thread::~Thread() { | 50 Thread::~Thread() { |
| 50 // We should cleanly exit any isolate before destruction. | 51 // We should cleanly exit any isolate before destruction. |
| 51 ASSERT(isolate_ == NULL); | 52 ASSERT(isolate_ == NULL); |
| 52 // Clear |this| from all isolate's thread registry. | 53 // Clear |this| from all isolate's thread registry. |
| 53 ThreadPruner pruner(this); | 54 ThreadPruner pruner(this); |
| 54 Isolate::VisitIsolates(&pruner); | 55 Isolate::VisitIsolates(&pruner); |
| 56 delete log_; | |
| 57 log_ = NULL; | |
| 55 } | 58 } |
| 56 | 59 |
| 57 | 60 |
| 58 void Thread::InitOnceBeforeIsolate() { | 61 void Thread::InitOnceBeforeIsolate() { |
| 59 ASSERT(thread_key_ == OSThread::kUnsetThreadLocalKey); | 62 ASSERT(thread_key_ == OSThread::kUnsetThreadLocalKey); |
| 60 thread_key_ = OSThread::CreateThreadLocal(DeleteThread); | 63 thread_key_ = OSThread::CreateThreadLocal(DeleteThread); |
| 61 ASSERT(thread_key_ != OSThread::kUnsetThreadLocalKey); | 64 ASSERT(thread_key_ != OSThread::kUnsetThreadLocalKey); |
| 62 ASSERT(Thread::Current() == NULL); | 65 ASSERT(Thread::Current() == NULL); |
| 63 // Allocate a new Thread and postpone initialization of VM constants for | 66 // Allocate a new Thread and postpone initialization of VM constants for |
| 64 // this first thread. | 67 // this first thread. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 } | 104 } |
| 102 #endif | 105 #endif |
| 103 | 106 |
| 104 | 107 |
| 105 Thread::Thread(bool init_vm_constants) | 108 Thread::Thread(bool init_vm_constants) |
| 106 : id_(OSThread::GetCurrentThreadId()), | 109 : id_(OSThread::GetCurrentThreadId()), |
| 107 thread_interrupt_callback_(NULL), | 110 thread_interrupt_callback_(NULL), |
| 108 thread_interrupt_data_(NULL), | 111 thread_interrupt_data_(NULL), |
| 109 isolate_(NULL), | 112 isolate_(NULL), |
| 110 heap_(NULL), | 113 heap_(NULL), |
| 111 store_buffer_block_(NULL) { | 114 store_buffer_block_(NULL), |
| 115 log_(new class Log()) { | |
|
Ivan Posva
2015/09/10 15:40:32
Now we can drop the "class" here.
| |
| 112 ClearState(); | 116 ClearState(); |
| 113 | 117 |
| 114 #define DEFAULT_INIT(type_name, member_name, init_expr, default_init_value) \ | 118 #define DEFAULT_INIT(type_name, member_name, init_expr, default_init_value) \ |
| 115 member_name = default_init_value; | 119 member_name = default_init_value; |
| 116 CACHED_CONSTANTS_LIST(DEFAULT_INIT) | 120 CACHED_CONSTANTS_LIST(DEFAULT_INIT) |
| 117 #undef DEFAULT_INIT | 121 #undef DEFAULT_INIT |
| 118 | 122 |
| 119 #define DEFAULT_INIT(name) \ | 123 #define DEFAULT_INIT(name) \ |
| 120 name##_entry_point_ = 0; | 124 name##_entry_point_ = 0; |
| 121 RUNTIME_ENTRY_LIST(DEFAULT_INIT) | 125 RUNTIME_ENTRY_LIST(DEFAULT_INIT) |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 return isolate_->cha_; | 304 return isolate_->cha_; |
| 301 } | 305 } |
| 302 | 306 |
| 303 | 307 |
| 304 void Thread::set_cha(CHA* value) { | 308 void Thread::set_cha(CHA* value) { |
| 305 ASSERT(isolate_ != NULL); | 309 ASSERT(isolate_ != NULL); |
| 306 isolate_->cha_ = value; | 310 isolate_->cha_ = value; |
| 307 } | 311 } |
| 308 | 312 |
| 309 | 313 |
| 314 Log* Thread::log() const { | |
| 315 return log_; | |
| 316 } | |
| 317 | |
| 318 | |
| 310 void Thread::SetThreadInterrupter(ThreadInterruptCallback callback, | 319 void Thread::SetThreadInterrupter(ThreadInterruptCallback callback, |
| 311 void* data) { | 320 void* data) { |
| 312 ASSERT(Thread::Current() == this); | 321 ASSERT(Thread::Current() == this); |
| 313 thread_interrupt_callback_ = callback; | 322 thread_interrupt_callback_ = callback; |
| 314 thread_interrupt_data_ = data; | 323 thread_interrupt_data_ = data; |
| 315 } | 324 } |
| 316 | 325 |
| 317 | 326 |
| 318 bool Thread::IsThreadInterrupterEnabled(ThreadInterruptCallback* callback, | 327 bool Thread::IsThreadInterrupterEnabled(ThreadInterruptCallback* callback, |
| 319 void** data) const { | 328 void** data) const { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 return Thread::name##_entry_point_offset(); \ | 374 return Thread::name##_entry_point_offset(); \ |
| 366 } | 375 } |
| 367 LEAF_RUNTIME_ENTRY_LIST(COMPUTE_OFFSET) | 376 LEAF_RUNTIME_ENTRY_LIST(COMPUTE_OFFSET) |
| 368 #undef COMPUTE_OFFSET | 377 #undef COMPUTE_OFFSET |
| 369 | 378 |
| 370 UNREACHABLE(); | 379 UNREACHABLE(); |
| 371 return -1; | 380 return -1; |
| 372 } | 381 } |
| 373 | 382 |
| 374 } // namespace dart | 383 } // namespace dart |
| OLD | NEW |