| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/isolate.h" | 5 #include "vm/isolate.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/bigint_store.h" | 9 #include "vm/bigint_store.h" |
| 10 #include "vm/code_index_table.h" | 10 #include "vm/code_index_table.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 delete api_state_; | 127 delete api_state_; |
| 128 delete stub_code_; | 128 delete stub_code_; |
| 129 delete code_index_table_; | 129 delete code_index_table_; |
| 130 delete debugger_; | 130 delete debugger_; |
| 131 delete mutex_; | 131 delete mutex_; |
| 132 mutex_ = NULL; // Fail fast if interrupts are scheduled on a dead isolate. | 132 mutex_ = NULL; // Fail fast if interrupts are scheduled on a dead isolate. |
| 133 delete message_handler_; | 133 delete message_handler_; |
| 134 message_handler_ = NULL; // Fail fast if we send messages to a dead isolate. | 134 message_handler_ = NULL; // Fail fast if we send messages to a dead isolate. |
| 135 } | 135 } |
| 136 | 136 |
| 137 void Isolate::SetCurrent(Isolate* current) { |
| 138 Thread::SetThreadLocal(isolate_key, reinterpret_cast<uword>(current)); |
| 139 } |
| 140 |
| 141 |
| 142 // The single thread local key which stores all the thread local data |
| 143 // for a thread. Since an Isolate is the central repository for |
| 144 // storing all isolate specific information a single thread local key |
| 145 // is sufficient. |
| 146 ThreadLocalKey Isolate::isolate_key = Thread::kUnsetThreadLocalKey; |
| 147 |
| 148 |
| 149 void Isolate::InitOnce() { |
| 150 ASSERT(isolate_key == Thread::kUnsetThreadLocalKey); |
| 151 isolate_key = Thread::CreateThreadLocal(); |
| 152 ASSERT(isolate_key != Thread::kUnsetThreadLocalKey); |
| 153 create_callback_ = NULL; |
| 154 } |
| 155 |
| 137 | 156 |
| 138 Isolate* Isolate::Init(const char* name_prefix) { | 157 Isolate* Isolate::Init(const char* name_prefix) { |
| 139 Isolate* result = new Isolate(); | 158 Isolate* result = new Isolate(); |
| 140 ASSERT(result != NULL); | 159 ASSERT(result != NULL); |
| 141 | 160 |
| 142 // TODO(5411455): For now just set the recently created isolate as | 161 // TODO(5411455): For now just set the recently created isolate as |
| 143 // the current isolate. | 162 // the current isolate. |
| 144 SetCurrent(result); | 163 SetCurrent(result); |
| 145 | 164 |
| 146 // Setup the isolate message handler. | 165 // Setup the isolate message handler. |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 } | 453 } |
| 435 | 454 |
| 436 | 455 |
| 437 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor) { | 456 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor) { |
| 438 if (api_state() != NULL) { | 457 if (api_state() != NULL) { |
| 439 api_state()->VisitWeakHandles(visitor); | 458 api_state()->VisitWeakHandles(visitor); |
| 440 } | 459 } |
| 441 } | 460 } |
| 442 | 461 |
| 443 } // namespace dart | 462 } // namespace dart |
| OLD | NEW |