| 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/isolate.h" | 7 #include "vm/isolate.h" |
| 8 #include "vm/os_thread.h" | 8 #include "vm/os_thread.h" |
| 9 #include "vm/profiler.h" | 9 #include "vm/profiler.h" |
| 10 #include "vm/thread_interrupter.h" | 10 #include "vm/thread_interrupter.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 } | 47 } |
| 48 SetCurrent(NULL); | 48 SetCurrent(NULL); |
| 49 } | 49 } |
| 50 | 50 |
| 51 | 51 |
| 52 void Thread::EnterIsolate(Isolate* isolate) { | 52 void Thread::EnterIsolate(Isolate* isolate) { |
| 53 EnsureInit(); | 53 EnsureInit(); |
| 54 Thread* thread = Thread::Current(); | 54 Thread* thread = Thread::Current(); |
| 55 ASSERT(thread->isolate() == NULL); | 55 ASSERT(thread->isolate() == NULL); |
| 56 ASSERT(isolate->mutator_thread() == NULL); | 56 ASSERT(isolate->mutator_thread() == NULL); |
| 57 thread->isolate_ = isolate; |
| 57 isolate->set_mutator_thread(thread); | 58 isolate->set_mutator_thread(thread); |
| 58 // TODO(koda): Migrate thread_state_ and profile_data_ to Thread, to allow | 59 // TODO(koda): Migrate thread_state_ and profile_data_ to Thread, to allow |
| 59 // helper threads concurrent with mutator. | 60 // helper threads concurrent with mutator. |
| 60 ASSERT(isolate->thread_state() == NULL); | 61 ASSERT(isolate->thread_state() == NULL); |
| 61 InterruptableThreadState* thread_state = | 62 InterruptableThreadState* thread_state = |
| 62 ThreadInterrupter::GetCurrentThreadState(); | 63 ThreadInterrupter::GetCurrentThreadState(); |
| 63 #if defined(DEBUG) | 64 #if defined(DEBUG) |
| 64 Isolate::CheckForDuplicateThreadState(thread_state); | 65 Isolate::CheckForDuplicateThreadState(thread_state); |
| 65 #endif | 66 #endif |
| 66 ASSERT(thread_state != NULL); | 67 ASSERT(thread_state != NULL); |
| 67 Profiler::BeginExecution(isolate); | 68 Profiler::BeginExecution(isolate); |
| 68 isolate->set_thread_state(thread_state); | 69 isolate->set_thread_state(thread_state); |
| 69 isolate->set_vm_tag(VMTag::kVMTagId); | 70 isolate->set_vm_tag(VMTag::kVMTagId); |
| 70 thread->isolate_ = isolate; | |
| 71 } | 71 } |
| 72 | 72 |
| 73 | 73 |
| 74 void Thread::ExitIsolate() { | 74 void Thread::ExitIsolate() { |
| 75 Thread* thread = Thread::Current(); | 75 Thread* thread = Thread::Current(); |
| 76 // TODO(koda): Audit callers; they should know whether they're in an isolate. | 76 // TODO(koda): Audit callers; they should know whether they're in an isolate. |
| 77 if (thread == NULL) return; | 77 if (thread == NULL) return; |
| 78 Isolate* isolate = thread->isolate(); | 78 Isolate* isolate = thread->isolate(); |
| 79 ASSERT(isolate != NULL); | 79 ASSERT(isolate != NULL); |
| 80 if (isolate->is_runnable()) { | 80 if (isolate->is_runnable()) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 96 return isolate_->cha_; | 96 return isolate_->cha_; |
| 97 } | 97 } |
| 98 | 98 |
| 99 | 99 |
| 100 void Thread::set_cha(CHA* value) { | 100 void Thread::set_cha(CHA* value) { |
| 101 ASSERT(isolate_ != NULL); | 101 ASSERT(isolate_ != NULL); |
| 102 isolate_->cha_ = value; | 102 isolate_->cha_ = value; |
| 103 } | 103 } |
| 104 | 104 |
| 105 } // namespace dart | 105 } // namespace dart |
| OLD | NEW |