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 ThreadLocalKey Isolate::isolate_key = Thread::kInvalidThreadLocal; |
| 143 |
| 144 |
| 145 void Isolate::InitOnce() { |
| 146 ASSERT(isolate_key == Thread::kInvalidThreadLocal); |
| 147 isolate_key = Thread::CreateThreadLocal(); |
| 148 ASSERT(isolate_key != Thread::kInvalidThreadLocal); |
| 149 create_callback_ = NULL; |
| 150 } |
| 151 |
137 | 152 |
138 Isolate* Isolate::Init(const char* name_prefix) { | 153 Isolate* Isolate::Init(const char* name_prefix) { |
139 Isolate* result = new Isolate(); | 154 Isolate* result = new Isolate(); |
140 ASSERT(result != NULL); | 155 ASSERT(result != NULL); |
141 | 156 |
142 // TODO(5411455): For now just set the recently created isolate as | 157 // TODO(5411455): For now just set the recently created isolate as |
143 // the current isolate. | 158 // the current isolate. |
144 SetCurrent(result); | 159 SetCurrent(result); |
145 | 160 |
146 // Setup the isolate message handler. | 161 // Setup the isolate message handler. |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 } | 449 } |
435 | 450 |
436 | 451 |
437 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor) { | 452 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor) { |
438 if (api_state() != NULL) { | 453 if (api_state() != NULL) { |
439 api_state()->VisitWeakHandles(visitor); | 454 api_state()->VisitWeakHandles(visitor); |
440 } | 455 } |
441 } | 456 } |
442 | 457 |
443 } // namespace dart | 458 } // namespace dart |
OLD | NEW |