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 "allocation.h" | 9 #include "allocation.h" |
10 #include "assert-scope.h" | 10 #include "assert-scope.h" |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 // True if at least one thread Enter'ed this isolate. | 471 // True if at least one thread Enter'ed this isolate. |
472 bool IsInUse() { return entry_stack_ != NULL; } | 472 bool IsInUse() { return entry_stack_ != NULL; } |
473 | 473 |
474 // Destroys the non-default isolates. | 474 // Destroys the non-default isolates. |
475 // Sets default isolate into "has_been_disposed" state rather then destroying, | 475 // Sets default isolate into "has_been_disposed" state rather then destroying, |
476 // for legacy API reasons. | 476 // for legacy API reasons. |
477 void TearDown(); | 477 void TearDown(); |
478 | 478 |
479 static void GlobalTearDown(); | 479 static void GlobalTearDown(); |
480 | 480 |
| 481 bool IsDefaultIsolate() const { return this == default_isolate_; } |
| 482 |
481 static void SetCrashIfDefaultIsolateInitialized(); | 483 static void SetCrashIfDefaultIsolateInitialized(); |
482 // Ensures that process-wide resources and the default isolate have been | 484 // Ensures that process-wide resources and the default isolate have been |
483 // allocated. It is only necessary to call this method in rare cases, for | 485 // allocated. It is only necessary to call this method in rare cases, for |
484 // example if you are using V8 from within the body of a static initializer. | 486 // example if you are using V8 from within the body of a static initializer. |
485 // Safe to call multiple times. | 487 // Safe to call multiple times. |
486 static void EnsureDefaultIsolate(); | 488 static void EnsureDefaultIsolate(); |
487 | 489 |
488 // Find the PerThread for this particular (isolate, thread) combination | 490 // Find the PerThread for this particular (isolate, thread) combination |
489 // If one does not yet exist, return null. | 491 // If one does not yet exist, return null. |
490 PerIsolateThreadData* FindPerThreadDataForThisThread(); | 492 PerIsolateThreadData* FindPerThreadDataForThisThread(); |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1125 | 1127 |
1126 int entry_count; | 1128 int entry_count; |
1127 PerIsolateThreadData* previous_thread_data; | 1129 PerIsolateThreadData* previous_thread_data; |
1128 Isolate* previous_isolate; | 1130 Isolate* previous_isolate; |
1129 EntryStackItem* previous_item; | 1131 EntryStackItem* previous_item; |
1130 | 1132 |
1131 private: | 1133 private: |
1132 DISALLOW_COPY_AND_ASSIGN(EntryStackItem); | 1134 DISALLOW_COPY_AND_ASSIGN(EntryStackItem); |
1133 }; | 1135 }; |
1134 | 1136 |
1135 // This mutex protects highest_thread_id_ and thread_data_table_. | 1137 // This mutex protects highest_thread_id_, thread_data_table_ and |
| 1138 // default_isolate_. |
1136 static Mutex process_wide_mutex_; | 1139 static Mutex process_wide_mutex_; |
1137 | 1140 |
1138 static Thread::LocalStorageKey per_isolate_thread_data_key_; | 1141 static Thread::LocalStorageKey per_isolate_thread_data_key_; |
1139 static Thread::LocalStorageKey isolate_key_; | 1142 static Thread::LocalStorageKey isolate_key_; |
1140 static Thread::LocalStorageKey thread_id_key_; | 1143 static Thread::LocalStorageKey thread_id_key_; |
| 1144 static Isolate* default_isolate_; |
1141 static ThreadDataTable* thread_data_table_; | 1145 static ThreadDataTable* thread_data_table_; |
1142 | 1146 |
1143 // A global counter for all generated Isolates, might overflow. | 1147 // A global counter for all generated Isolates, might overflow. |
1144 static Atomic32 isolate_counter_; | 1148 static Atomic32 isolate_counter_; |
1145 | 1149 |
1146 void Deinit(); | 1150 void Deinit(); |
1147 | 1151 |
1148 static void SetIsolateThreadLocals(Isolate* isolate, | 1152 static void SetIsolateThreadLocals(Isolate* isolate, |
1149 PerIsolateThreadData* data); | 1153 PerIsolateThreadData* data); |
1150 | 1154 |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1484 } | 1488 } |
1485 | 1489 |
1486 EmbeddedVector<char, 128> filename_; | 1490 EmbeddedVector<char, 128> filename_; |
1487 FILE* file_; | 1491 FILE* file_; |
1488 int scope_depth_; | 1492 int scope_depth_; |
1489 }; | 1493 }; |
1490 | 1494 |
1491 } } // namespace v8::internal | 1495 } } // namespace v8::internal |
1492 | 1496 |
1493 #endif // V8_ISOLATE_H_ | 1497 #endif // V8_ISOLATE_H_ |
OLD | NEW |