Chromium Code Reviews| Index: runtime/vm/thread.cc |
| diff --git a/runtime/vm/thread.cc b/runtime/vm/thread.cc |
| index ba6db93eacd7aeb166d49bbcbba0c59c8719d911..f460ee99bb8aa70448942898e922fe64288a14e3 100644 |
| --- a/runtime/vm/thread.cc |
| +++ b/runtime/vm/thread.cc |
| @@ -5,8 +5,10 @@ |
| #include "vm/thread.h" |
| #include "vm/isolate.h" |
| +#include "vm/object.h" |
| #include "vm/os_thread.h" |
| #include "vm/profiler.h" |
| +#include "vm/stub_code.h" |
| #include "vm/thread_interrupter.h" |
| @@ -23,10 +25,21 @@ static void DeleteThread(void* thread) { |
| } |
| -void Thread::InitOnce() { |
| +void Thread::InitOnceBeforeIsolate() { |
| ASSERT(thread_key_ == OSThread::kUnsetThreadLocalKey); |
| thread_key_ = OSThread::CreateThreadLocal(DeleteThread); |
| ASSERT(thread_key_ != OSThread::kUnsetThreadLocalKey); |
| + ASSERT(Thread::Current() == NULL); |
| + // Postpone initialization of VM constants for this first thread. |
| + SetCurrent(new Thread(false)); |
| +} |
| + |
| + |
| +void Thread::InitOnceAfterObjectAndStubCode() { |
| + Thread* thread = Thread::Current(); |
| + ASSERT(thread != NULL); |
| + ASSERT(thread->isolate() == Dart::vm_isolate()); |
| + thread->InitVMConstants(); |
| } |
| @@ -53,6 +66,31 @@ void Thread::CleanUp() { |
| #endif |
| +Thread::Thread(bool init_vm_constants) |
| + : isolate_(NULL), |
| + store_buffer_block_(NULL), |
| + object_null_(NULL), |
| + bool_true_(NULL), |
| + bool_false_(NULL), |
| + update_store_buffer_entry_point_(0) { |
| + if (init_vm_constants) { |
| + InitVMConstants(); |
| + } |
| +} |
| + |
| + |
| +void Thread::InitVMConstants() { |
| + ASSERT(object_null_ == NULL); |
| + object_null_ = Object::null(); |
| + ASSERT(bool_true_ == NULL); |
| + bool_true_ = Object::bool_true().raw(); |
| + ASSERT(bool_false_ == NULL); |
| + bool_false_ = Object::bool_false().raw(); |
| + ASSERT(update_store_buffer_entry_point_ == 0); |
| + update_store_buffer_entry_point_ = StubCode::UpdateStoreBufferEntryPoint(); |
| +} |
| + |
| + |
| void Thread::EnterIsolate(Isolate* isolate) { |
| Thread* thread = Thread::Current(); |
| ASSERT(thread != NULL); |
| @@ -168,4 +206,25 @@ void Thread::set_cha(CHA* value) { |
| isolate_->cha_ = value; |
| } |
| + |
| +bool Thread::CanLoadFromThread(const Object& object) { |
| + return (object.raw() == Object::null()) |
| + || (object.raw() == Bool::True().raw()) |
|
koda
2015/07/07 13:43:57
It would be safer to connect this with the code th
Florian Schneider
2015/07/08 09:28:09
Macro sounds good since there are a few of places
|
| + || (object.raw() == Bool::False().raw()); |
| +} |
| + |
| + |
| +intptr_t Thread::OffsetFromThread(const Object& object) { |
|
koda
2015/07/07 13:43:57
ASSERT(CanLoadFromThread)
Florian Schneider
2015/07/08 09:28:09
Done.
|
| + if (object.raw() == Object::null()) { |
| + return Thread::object_null_offset(); |
| + } else if (object.raw() == Bool::True().raw()) { |
| + return Thread::bool_true_offset(); |
| + } else if (object.raw() == Bool::False().raw()) { |
| + return Thread::bool_false_offset(); |
| + } else { |
| + UNREACHABLE(); |
| + return -1; |
| + } |
| +} |
| + |
| } // namespace dart |