OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_ISOLATE_H_ | 5 #ifndef V8_ISOLATE_H_ |
6 #define V8_ISOLATE_H_ | 6 #define V8_ISOLATE_H_ |
7 | 7 |
8 #include "include/v8-debug.h" | 8 #include "include/v8-debug.h" |
9 #include "src/allocation.h" | 9 #include "src/allocation.h" |
10 #include "src/assert-scope.h" | 10 #include "src/assert-scope.h" |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 | 479 |
480 // Returns the PerIsolateThreadData for the current thread (or NULL if one is | 480 // Returns the PerIsolateThreadData for the current thread (or NULL if one is |
481 // not currently set). | 481 // not currently set). |
482 static PerIsolateThreadData* CurrentPerIsolateThreadData() { | 482 static PerIsolateThreadData* CurrentPerIsolateThreadData() { |
483 return reinterpret_cast<PerIsolateThreadData*>( | 483 return reinterpret_cast<PerIsolateThreadData*>( |
484 base::Thread::GetThreadLocal(per_isolate_thread_data_key_)); | 484 base::Thread::GetThreadLocal(per_isolate_thread_data_key_)); |
485 } | 485 } |
486 | 486 |
487 // Returns the isolate inside which the current thread is running. | 487 // Returns the isolate inside which the current thread is running. |
488 INLINE(static Isolate* Current()) { | 488 INLINE(static Isolate* Current()) { |
| 489 DCHECK(base::NoBarrier_Load(&isolate_key_created_) == 1); |
489 Isolate* isolate = reinterpret_cast<Isolate*>( | 490 Isolate* isolate = reinterpret_cast<Isolate*>( |
490 base::Thread::GetExistingThreadLocal(isolate_key_)); | 491 base::Thread::GetExistingThreadLocal(isolate_key_)); |
491 DCHECK(isolate != NULL); | 492 DCHECK(isolate != NULL); |
492 return isolate; | 493 return isolate; |
493 } | 494 } |
494 | 495 |
495 INLINE(static Isolate* UncheckedCurrent()) { | 496 INLINE(static Isolate* UncheckedCurrent()) { |
| 497 DCHECK(base::NoBarrier_Load(&isolate_key_created_) == 1); |
496 return reinterpret_cast<Isolate*>( | 498 return reinterpret_cast<Isolate*>( |
497 base::Thread::GetThreadLocal(isolate_key_)); | 499 base::Thread::GetThreadLocal(isolate_key_)); |
498 } | 500 } |
499 | 501 |
500 // Like UncheckedCurrent, but skips the check that |isolate_key_| was | 502 // Like UncheckedCurrent, but skips the check that |isolate_key_| was |
501 // initialized. Callers have to ensure that themselves. | 503 // initialized. Callers have to ensure that themselves. |
502 INLINE(static Isolate* UnsafeCurrent()) { | 504 INLINE(static Isolate* UnsafeCurrent()) { |
503 return reinterpret_cast<Isolate*>( | 505 return reinterpret_cast<Isolate*>( |
504 base::Thread::GetThreadLocal(isolate_key_)); | 506 base::Thread::GetThreadLocal(isolate_key_)); |
505 } | 507 } |
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1170 static base::LazyMutex thread_data_table_mutex_; | 1172 static base::LazyMutex thread_data_table_mutex_; |
1171 | 1173 |
1172 static base::Thread::LocalStorageKey per_isolate_thread_data_key_; | 1174 static base::Thread::LocalStorageKey per_isolate_thread_data_key_; |
1173 static base::Thread::LocalStorageKey isolate_key_; | 1175 static base::Thread::LocalStorageKey isolate_key_; |
1174 static base::Thread::LocalStorageKey thread_id_key_; | 1176 static base::Thread::LocalStorageKey thread_id_key_; |
1175 static ThreadDataTable* thread_data_table_; | 1177 static ThreadDataTable* thread_data_table_; |
1176 | 1178 |
1177 // A global counter for all generated Isolates, might overflow. | 1179 // A global counter for all generated Isolates, might overflow. |
1178 static base::Atomic32 isolate_counter_; | 1180 static base::Atomic32 isolate_counter_; |
1179 | 1181 |
| 1182 #if DEBUG |
| 1183 static base::Atomic32 isolate_key_created_; |
| 1184 #endif |
| 1185 |
1180 void Deinit(); | 1186 void Deinit(); |
1181 | 1187 |
1182 static void SetIsolateThreadLocals(Isolate* isolate, | 1188 static void SetIsolateThreadLocals(Isolate* isolate, |
1183 PerIsolateThreadData* data); | 1189 PerIsolateThreadData* data); |
1184 | 1190 |
1185 // Find the PerThread for this particular (isolate, thread) combination. | 1191 // Find the PerThread for this particular (isolate, thread) combination. |
1186 // If one does not yet exist, allocate a new one. | 1192 // If one does not yet exist, allocate a new one. |
1187 PerIsolateThreadData* FindOrAllocatePerThreadDataForThisThread(); | 1193 PerIsolateThreadData* FindOrAllocatePerThreadDataForThisThread(); |
1188 | 1194 |
1189 // Initializes the current thread to run this Isolate. | 1195 // Initializes the current thread to run this Isolate. |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1547 } | 1553 } |
1548 | 1554 |
1549 EmbeddedVector<char, 128> filename_; | 1555 EmbeddedVector<char, 128> filename_; |
1550 FILE* file_; | 1556 FILE* file_; |
1551 int scope_depth_; | 1557 int scope_depth_; |
1552 }; | 1558 }; |
1553 | 1559 |
1554 } } // namespace v8::internal | 1560 } } // namespace v8::internal |
1555 | 1561 |
1556 #endif // V8_ISOLATE_H_ | 1562 #endif // V8_ISOLATE_H_ |
OLD | NEW |