OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 // True if at least one thread Enter'ed this isolate. | 484 // True if at least one thread Enter'ed this isolate. |
485 bool IsInUse() { return entry_stack_ != NULL; } | 485 bool IsInUse() { return entry_stack_ != NULL; } |
486 | 486 |
487 // Destroys the non-default isolates. | 487 // Destroys the non-default isolates. |
488 // Sets default isolate into "has_been_disposed" state rather then destroying, | 488 // Sets default isolate into "has_been_disposed" state rather then destroying, |
489 // for legacy API reasons. | 489 // for legacy API reasons. |
490 void TearDown(); | 490 void TearDown(); |
491 | 491 |
492 static void GlobalTearDown(); | 492 static void GlobalTearDown(); |
493 | 493 |
494 bool IsDefaultIsolate() const { return this == default_isolate_; } | 494 bool IsDefaultIsolate() const { return is_default_isolate_; } |
495 | 495 |
496 static void SetCrashIfDefaultIsolateInitialized(); | 496 static void SetCrashIfDefaultIsolateInitialized(); |
497 // Ensures that process-wide resources and the default isolate have been | 497 // Ensures that process-wide resources and the default isolate have been |
498 // allocated. It is only necessary to call this method in rare cases, for | 498 // allocated. It is only necessary to call this method in rare cases, for |
499 // example if you are using V8 from within the body of a static initializer. | 499 // example if you are using V8 from within the body of a static initializer. |
500 // Safe to call multiple times. | 500 // Safe to call multiple times. |
501 static void EnsureDefaultIsolate(); | 501 static Isolate* EnsureDefaultIsolate(); |
| 502 |
| 503 // Initialize all thread local variables |
| 504 static void InitializeThreadLocalStorage(); |
502 | 505 |
503 // Find the PerThread for this particular (isolate, thread) combination | 506 // Find the PerThread for this particular (isolate, thread) combination |
504 // If one does not yet exist, return null. | 507 // If one does not yet exist, return null. |
505 PerIsolateThreadData* FindPerThreadDataForThisThread(); | 508 PerIsolateThreadData* FindPerThreadDataForThisThread(); |
506 | 509 |
507 // Find the PerThread for given (isolate, thread) combination | 510 // Find the PerThread for given (isolate, thread) combination |
508 // If one does not yet exist, return null. | 511 // If one does not yet exist, return null. |
509 PerIsolateThreadData* FindPerThreadDataForThread(ThreadId thread_id); | 512 PerIsolateThreadData* FindPerThreadDataForThread(ThreadId thread_id); |
510 | 513 |
511 #ifdef ENABLE_DEBUGGER_SUPPORT | 514 #ifdef ENABLE_DEBUGGER_SUPPORT |
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 function_entry_hook_ = function_entry_hook; | 1120 function_entry_hook_ = function_entry_hook; |
1118 } | 1121 } |
1119 | 1122 |
1120 void* stress_deopt_count_address() { return &stress_deopt_count_; } | 1123 void* stress_deopt_count_address() { return &stress_deopt_count_; } |
1121 | 1124 |
1122 inline RandomNumberGenerator* random_number_generator(); | 1125 inline RandomNumberGenerator* random_number_generator(); |
1123 | 1126 |
1124 // Given an address occupied by a live code object, return that object. | 1127 // Given an address occupied by a live code object, return that object. |
1125 Object* FindCodeObject(Address a); | 1128 Object* FindCodeObject(Address a); |
1126 | 1129 |
| 1130 static Atomic32 GetLivingIsolates() { |
| 1131 return Acquire_Load(&living_isolates_); |
| 1132 } |
| 1133 |
1127 private: | 1134 private: |
1128 Isolate(); | 1135 explicit Isolate(bool is_default_isolate = false); |
1129 | 1136 |
1130 friend struct GlobalState; | 1137 friend struct GlobalState; |
1131 friend struct InitializeGlobalState; | 1138 friend struct InitializeGlobalState; |
1132 | 1139 |
1133 enum State { | 1140 enum State { |
1134 UNINITIALIZED, // Some components may not have been allocated. | 1141 UNINITIALIZED, // Some components may not have been allocated. |
1135 INITIALIZED // All components are fully initialized. | 1142 INITIALIZED // All components are fully initialized. |
1136 }; | 1143 }; |
1137 | 1144 |
1138 // These fields are accessed through the API, offsets must be kept in sync | 1145 // These fields are accessed through the API, offsets must be kept in sync |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 DISALLOW_COPY_AND_ASSIGN(EntryStackItem); | 1190 DISALLOW_COPY_AND_ASSIGN(EntryStackItem); |
1184 }; | 1191 }; |
1185 | 1192 |
1186 // This mutex protects highest_thread_id_, thread_data_table_ and | 1193 // This mutex protects highest_thread_id_, thread_data_table_ and |
1187 // default_isolate_. | 1194 // default_isolate_. |
1188 static Mutex process_wide_mutex_; | 1195 static Mutex process_wide_mutex_; |
1189 | 1196 |
1190 static Thread::LocalStorageKey per_isolate_thread_data_key_; | 1197 static Thread::LocalStorageKey per_isolate_thread_data_key_; |
1191 static Thread::LocalStorageKey isolate_key_; | 1198 static Thread::LocalStorageKey isolate_key_; |
1192 static Thread::LocalStorageKey thread_id_key_; | 1199 static Thread::LocalStorageKey thread_id_key_; |
1193 static Isolate* default_isolate_; | |
1194 static ThreadDataTable* thread_data_table_; | 1200 static ThreadDataTable* thread_data_table_; |
1195 | 1201 |
1196 // A global counter for all generated Isolates, might overflow. | 1202 // A global counter for all generated Isolates, might overflow. |
1197 static Atomic32 isolate_counter_; | 1203 static Atomic32 isolate_counter_; |
| 1204 static Atomic32 living_isolates_; |
1198 | 1205 |
1199 void Deinit(); | 1206 void Deinit(); |
1200 | 1207 |
1201 static void SetIsolateThreadLocals(Isolate* isolate, | 1208 static void SetIsolateThreadLocals(Isolate* isolate, |
1202 PerIsolateThreadData* data); | 1209 PerIsolateThreadData* data); |
1203 | 1210 |
1204 // Find the PerThread for this particular (isolate, thread) combination. | 1211 // Find the PerThread for this particular (isolate, thread) combination. |
1205 // If one does not yet exist, allocate a new one. | 1212 // If one does not yet exist, allocate a new one. |
1206 PerIsolateThreadData* FindOrAllocatePerThreadDataForThisThread(); | 1213 PerIsolateThreadData* FindOrAllocatePerThreadDataForThisThread(); |
1207 | 1214 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1299 | 1306 |
1300 // True if fatal error has been signaled for this isolate. | 1307 // True if fatal error has been signaled for this isolate. |
1301 bool has_fatal_error_; | 1308 bool has_fatal_error_; |
1302 | 1309 |
1303 // True if we are using the Crankshaft optimizing compiler. | 1310 // True if we are using the Crankshaft optimizing compiler. |
1304 bool use_crankshaft_; | 1311 bool use_crankshaft_; |
1305 | 1312 |
1306 // True if this isolate was initialized from a snapshot. | 1313 // True if this isolate was initialized from a snapshot. |
1307 bool initialized_from_snapshot_; | 1314 bool initialized_from_snapshot_; |
1308 | 1315 |
| 1316 // True only for the default isolate. |
| 1317 bool is_default_isolate_; |
| 1318 |
1309 // Time stamp at initialization. | 1319 // Time stamp at initialization. |
1310 double time_millis_at_init_; | 1320 double time_millis_at_init_; |
1311 | 1321 |
1312 #if V8_TARGET_ARCH_ARM && !defined(__arm__) || \ | 1322 #if V8_TARGET_ARCH_ARM && !defined(__arm__) || \ |
1313 V8_TARGET_ARCH_MIPS && !defined(__mips__) | 1323 V8_TARGET_ARCH_MIPS && !defined(__mips__) |
1314 bool simulator_initialized_; | 1324 bool simulator_initialized_; |
1315 HashMap* simulator_i_cache_; | 1325 HashMap* simulator_i_cache_; |
1316 Redirection* simulator_redirection_; | 1326 Redirection* simulator_redirection_; |
1317 #endif | 1327 #endif |
1318 | 1328 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1514 | 1524 |
1515 // Mark the native context with out of memory. | 1525 // Mark the native context with out of memory. |
1516 inline void Context::mark_out_of_memory() { | 1526 inline void Context::mark_out_of_memory() { |
1517 native_context()->set_out_of_memory(GetIsolate()->heap()->true_value()); | 1527 native_context()->set_out_of_memory(GetIsolate()->heap()->true_value()); |
1518 } | 1528 } |
1519 | 1529 |
1520 | 1530 |
1521 } } // namespace v8::internal | 1531 } } // namespace v8::internal |
1522 | 1532 |
1523 #endif // V8_ISOLATE_H_ | 1533 #endif // V8_ISOLATE_H_ |
OLD | NEW |