Index: runtime/vm/thread.cc |
diff --git a/runtime/vm/thread.cc b/runtime/vm/thread.cc |
index fdd3272e340ecf1029b9a87c5c067bbcd3b80440..144eba0a14dfe54cbd99e70dff6607e6c2c03b93 100644 |
--- a/runtime/vm/thread.cc |
+++ b/runtime/vm/thread.cc |
@@ -27,6 +27,7 @@ static void DeleteThread(void* thread) { |
Thread::~Thread() { |
+ delete thread_state_; |
// We should cleanly exit any isolate before destruction. |
ASSERT(isolate_ == NULL); |
} |
@@ -58,6 +59,7 @@ void Thread::SetCurrent(Thread* current) { |
void Thread::EnsureInit() { |
if (Thread::Current() == NULL) { |
SetCurrent(new Thread()); |
+ ThreadInterrupter::GetCurrentThreadState(); |
} |
} |
@@ -75,7 +77,8 @@ void Thread::CleanUp() { |
Thread::Thread(bool init_vm_constants) |
: isolate_(NULL), |
- store_buffer_block_(NULL) { |
+ store_buffer_block_(NULL), |
+ thread_state_(NULL) { |
ClearState(); |
#define DEFAULT_INIT(type_name, member_name, init_expr, default_init_value) \ |
member_name = default_init_value; |
@@ -131,7 +134,6 @@ void Thread::EnterIsolate(Isolate* isolate) { |
ASSERT(isolate->heap() != NULL); |
thread->heap_ = isolate->heap(); |
thread->Schedule(isolate); |
- ASSERT(thread->thread_state() == NULL); |
InterruptableThreadState* thread_state = |
ThreadInterrupter::GetCurrentThreadState(); |
#if defined(DEBUG) |
@@ -151,7 +153,6 @@ void Thread::ExitIsolate() { |
if (thread == NULL || thread->isolate() == NULL) return; |
Isolate* isolate = thread->isolate(); |
Profiler::EndExecution(isolate); |
- thread->set_thread_state(NULL); |
thread->Unschedule(); |
// TODO(koda): Move store_buffer_block_ into State. |
thread->StoreBufferRelease(); |
@@ -178,7 +179,6 @@ void Thread::EnterIsolateAsHelper(Isolate* isolate) { |
thread->isolate()->store_buffer()->PopEmptyBlock(); |
ASSERT(isolate->heap() != NULL); |
thread->heap_ = isolate->heap(); |
- ASSERT(thread->thread_state() == NULL); |
// Do not update isolate->mutator_thread, but perform sanity check: |
// this thread should not be both the main mutator and helper. |
ASSERT(!isolate->MutatorThreadIsCurrentThread()); |
@@ -193,7 +193,6 @@ void Thread::ExitIsolateAsHelper() { |
thread->Unschedule(); |
// TODO(koda): Move store_buffer_block_ into State. |
thread->StoreBufferRelease(); |
- thread->set_thread_state(NULL); |
thread->isolate_ = NULL; |
thread->heap_ = NULL; |
ASSERT(!isolate->MutatorThreadIsCurrentThread()); |