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 // True if at least one thread Enter'ed this isolate. | 479 // True if at least one thread Enter'ed this isolate. |
480 bool IsInUse() { return entry_stack_ != NULL; } | 480 bool IsInUse() { return entry_stack_ != NULL; } |
481 | 481 |
482 // Destroys the non-default isolates. | 482 // Destroys the non-default isolates. |
483 // Sets default isolate into "has_been_disposed" state rather then destroying, | 483 // Sets default isolate into "has_been_disposed" state rather then destroying, |
484 // for legacy API reasons. | 484 // for legacy API reasons. |
485 void TearDown(); | 485 void TearDown(); |
486 | 486 |
487 static void GlobalTearDown(); | 487 static void GlobalTearDown(); |
488 | 488 |
| 489 static void SetCrashIfDefaultIsolateInitialized(); |
| 490 // Ensures that process-wide resources and the default isolate have been |
| 491 // allocated. It is only necessary to call this method in rare cases, for |
| 492 // example if you are using V8 from within the body of a static initializer. |
| 493 // Safe to call multiple times. |
| 494 static void EnsureDefaultIsolate(); |
| 495 |
489 // Find the PerThread for this particular (isolate, thread) combination | 496 // Find the PerThread for this particular (isolate, thread) combination |
490 // If one does not yet exist, return null. | 497 // If one does not yet exist, return null. |
491 PerIsolateThreadData* FindPerThreadDataForThisThread(); | 498 PerIsolateThreadData* FindPerThreadDataForThisThread(); |
492 | 499 |
493 // Find the PerThread for given (isolate, thread) combination | 500 // Find the PerThread for given (isolate, thread) combination |
494 // If one does not yet exist, return null. | 501 // If one does not yet exist, return null. |
495 PerIsolateThreadData* FindPerThreadDataForThread(ThreadId thread_id); | 502 PerIsolateThreadData* FindPerThreadDataForThread(ThreadId thread_id); |
496 | 503 |
497 // Returns the key used to store the pointer to the current isolate. | 504 // Returns the key used to store the pointer to the current isolate. |
498 // Used internally for V8 threads that do not execute JavaScript but still | 505 // Used internally for V8 threads that do not execute JavaScript but still |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 void RemoveCallCompletedCallback(CallCompletedCallback callback); | 1083 void RemoveCallCompletedCallback(CallCompletedCallback callback); |
1077 void FireCallCompletedCallback(); | 1084 void FireCallCompletedCallback(); |
1078 | 1085 |
1079 void EnqueueMicrotask(Handle<Object> microtask); | 1086 void EnqueueMicrotask(Handle<Object> microtask); |
1080 void RunMicrotasks(); | 1087 void RunMicrotasks(); |
1081 | 1088 |
1082 void SetUseCounterCallback(v8::Isolate::UseCounterCallback callback); | 1089 void SetUseCounterCallback(v8::Isolate::UseCounterCallback callback); |
1083 void CountUsage(v8::Isolate::UseCounterFeature feature); | 1090 void CountUsage(v8::Isolate::UseCounterFeature feature); |
1084 | 1091 |
1085 private: | 1092 private: |
1086 static void EnsureInitialized(); | |
1087 | |
1088 Isolate(); | 1093 Isolate(); |
1089 | 1094 |
1090 friend struct GlobalState; | 1095 friend struct GlobalState; |
1091 friend struct InitializeGlobalState; | 1096 friend struct InitializeGlobalState; |
1092 | 1097 |
1093 enum State { | 1098 enum State { |
1094 UNINITIALIZED, // Some components may not have been allocated. | 1099 UNINITIALIZED, // Some components may not have been allocated. |
1095 INITIALIZED // All components are fully initialized. | 1100 INITIALIZED // All components are fully initialized. |
1096 }; | 1101 }; |
1097 | 1102 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 int entry_count; | 1142 int entry_count; |
1138 PerIsolateThreadData* previous_thread_data; | 1143 PerIsolateThreadData* previous_thread_data; |
1139 Isolate* previous_isolate; | 1144 Isolate* previous_isolate; |
1140 EntryStackItem* previous_item; | 1145 EntryStackItem* previous_item; |
1141 | 1146 |
1142 private: | 1147 private: |
1143 DISALLOW_COPY_AND_ASSIGN(EntryStackItem); | 1148 DISALLOW_COPY_AND_ASSIGN(EntryStackItem); |
1144 }; | 1149 }; |
1145 | 1150 |
1146 // This mutex protects highest_thread_id_ and thread_data_table_. | 1151 // This mutex protects highest_thread_id_ and thread_data_table_. |
1147 static base::LazyMutex process_wide_mutex_; | 1152 static base::Mutex process_wide_mutex_; |
1148 | 1153 |
1149 static base::Thread::LocalStorageKey per_isolate_thread_data_key_; | 1154 static base::Thread::LocalStorageKey per_isolate_thread_data_key_; |
1150 static base::Thread::LocalStorageKey isolate_key_; | 1155 static base::Thread::LocalStorageKey isolate_key_; |
1151 static base::Thread::LocalStorageKey thread_id_key_; | 1156 static base::Thread::LocalStorageKey thread_id_key_; |
1152 static ThreadDataTable* thread_data_table_; | 1157 static ThreadDataTable* thread_data_table_; |
1153 | 1158 |
1154 // A global counter for all generated Isolates, might overflow. | 1159 // A global counter for all generated Isolates, might overflow. |
1155 static base::Atomic32 isolate_counter_; | 1160 static base::Atomic32 isolate_counter_; |
1156 | 1161 |
1157 void Deinit(); | 1162 void Deinit(); |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1503 } | 1508 } |
1504 | 1509 |
1505 EmbeddedVector<char, 128> filename_; | 1510 EmbeddedVector<char, 128> filename_; |
1506 FILE* file_; | 1511 FILE* file_; |
1507 int scope_depth_; | 1512 int scope_depth_; |
1508 }; | 1513 }; |
1509 | 1514 |
1510 } } // namespace v8::internal | 1515 } } // namespace v8::internal |
1511 | 1516 |
1512 #endif // V8_ISOLATE_H_ | 1517 #endif // V8_ISOLATE_H_ |
OLD | NEW |