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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
488 // True if at least one thread Enter'ed this isolate. | 488 // True if at least one thread Enter'ed this isolate. |
489 bool IsInUse() { return entry_stack_ != NULL; } | 489 bool IsInUse() { return entry_stack_ != NULL; } |
490 | 490 |
491 // Destroys the non-default isolates. | 491 // Destroys the non-default isolates. |
492 // Sets default isolate into "has_been_disposed" state rather then destroying, | 492 // Sets default isolate into "has_been_disposed" state rather then destroying, |
493 // for legacy API reasons. | 493 // for legacy API reasons. |
494 void TearDown(); | 494 void TearDown(); |
495 | 495 |
496 static void GlobalTearDown(); | 496 static void GlobalTearDown(); |
497 | 497 |
498 bool IsDefaultIsolate() const { return this == default_isolate_; } | 498 bool IsDefaultIsolate() const { return is_default_isolate_; } |
499 | 499 |
500 static void SetCrashIfDefaultIsolateInitialized(); | 500 static void SetCrashIfDefaultIsolateInitialized(); |
501 // Ensures that process-wide resources and the default isolate have been | 501 // Ensures that process-wide resources and the default isolate have been |
502 // allocated. It is only necessary to call this method in rare cases, for | 502 // allocated. It is only necessary to call this method in rare cases, for |
503 // example if you are using V8 from within the body of a static initializer. | 503 // example if you are using V8 from within the body of a static initializer. |
504 // Safe to call multiple times. | 504 // Safe to call multiple times. |
505 static void EnsureDefaultIsolate(); | 505 static Isolate* EnsureDefaultIsolate(); |
506 | |
507 // Initialize all thread local variables | |
508 static void InitializeThreadLocalStorage(); | |
506 | 509 |
507 // Find the PerThread for this particular (isolate, thread) combination | 510 // Find the PerThread for this particular (isolate, thread) combination |
508 // If one does not yet exist, return null. | 511 // If one does not yet exist, return null. |
509 PerIsolateThreadData* FindPerThreadDataForThisThread(); | 512 PerIsolateThreadData* FindPerThreadDataForThisThread(); |
510 | 513 |
511 // Find the PerThread for given (isolate, thread) combination | 514 // Find the PerThread for given (isolate, thread) combination |
512 // If one does not yet exist, return null. | 515 // If one does not yet exist, return null. |
513 PerIsolateThreadData* FindPerThreadDataForThread(ThreadId thread_id); | 516 PerIsolateThreadData* FindPerThreadDataForThread(ThreadId thread_id); |
514 | 517 |
515 #ifdef ENABLE_DEBUGGER_SUPPORT | 518 #ifdef ENABLE_DEBUGGER_SUPPORT |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1125 function_entry_hook_ = function_entry_hook; | 1128 function_entry_hook_ = function_entry_hook; |
1126 } | 1129 } |
1127 | 1130 |
1128 void* stress_deopt_count_address() { return &stress_deopt_count_; } | 1131 void* stress_deopt_count_address() { return &stress_deopt_count_; } |
1129 | 1132 |
1130 inline RandomNumberGenerator* random_number_generator(); | 1133 inline RandomNumberGenerator* random_number_generator(); |
1131 | 1134 |
1132 // Given an address occupied by a live code object, return that object. | 1135 // Given an address occupied by a live code object, return that object. |
1133 Object* FindCodeObject(Address a); | 1136 Object* FindCodeObject(Address a); |
1134 | 1137 |
1138 static Atomic32 GetLivingIsolates() { | |
1139 return Acquire_Load(&living_isolates_); | |
1140 } | |
1141 | |
1135 private: | 1142 private: |
1136 Isolate(); | 1143 explicit Isolate(bool is_default_isolate = false); |
1137 | 1144 |
1138 friend struct GlobalState; | 1145 friend struct GlobalState; |
1139 friend struct InitializeGlobalState; | 1146 friend struct InitializeGlobalState; |
1140 | 1147 |
1141 enum State { | 1148 enum State { |
1142 UNINITIALIZED, // Some components may not have been allocated. | 1149 UNINITIALIZED, // Some components may not have been allocated. |
1143 INITIALIZED // All components are fully initialized. | 1150 INITIALIZED // All components are fully initialized. |
1144 }; | 1151 }; |
1145 | 1152 |
1146 // These fields are accessed through the API, offsets must be kept in sync | 1153 // 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... | |
1191 DISALLOW_COPY_AND_ASSIGN(EntryStackItem); | 1198 DISALLOW_COPY_AND_ASSIGN(EntryStackItem); |
1192 }; | 1199 }; |
1193 | 1200 |
1194 // This mutex protects highest_thread_id_, thread_data_table_ and | 1201 // This mutex protects highest_thread_id_, thread_data_table_ and |
1195 // default_isolate_. | 1202 // default_isolate_. |
1196 static Mutex process_wide_mutex_; | 1203 static Mutex process_wide_mutex_; |
1197 | 1204 |
1198 static Thread::LocalStorageKey per_isolate_thread_data_key_; | 1205 static Thread::LocalStorageKey per_isolate_thread_data_key_; |
1199 static Thread::LocalStorageKey isolate_key_; | 1206 static Thread::LocalStorageKey isolate_key_; |
1200 static Thread::LocalStorageKey thread_id_key_; | 1207 static Thread::LocalStorageKey thread_id_key_; |
1201 static Isolate* default_isolate_; | |
1202 static ThreadDataTable* thread_data_table_; | 1208 static ThreadDataTable* thread_data_table_; |
1203 | 1209 |
1204 // A global counter for all generated Isolates, might overflow. | 1210 // A global counter for all generated Isolates, might overflow. |
1205 static Atomic32 isolate_counter_; | 1211 static Atomic32 isolate_counter_; |
1212 static Atomic32 living_isolates_; | |
1206 | 1213 |
1207 void Deinit(); | 1214 void Deinit(); |
1208 | 1215 |
1209 static void SetIsolateThreadLocals(Isolate* isolate, | 1216 static void SetIsolateThreadLocals(Isolate* isolate, |
1210 PerIsolateThreadData* data); | 1217 PerIsolateThreadData* data); |
1211 | 1218 |
1212 // Find the PerThread for this particular (isolate, thread) combination. | 1219 // Find the PerThread for this particular (isolate, thread) combination. |
1213 // If one does not yet exist, allocate a new one. | 1220 // If one does not yet exist, allocate a new one. |
1214 PerIsolateThreadData* FindOrAllocatePerThreadDataForThisThread(); | 1221 PerIsolateThreadData* FindOrAllocatePerThreadDataForThisThread(); |
1215 | 1222 |
(...skipping 21 matching lines...) Expand all Loading... | |
1237 void FillCache(); | 1244 void FillCache(); |
1238 | 1245 |
1239 void PropagatePendingExceptionToExternalTryCatch(); | 1246 void PropagatePendingExceptionToExternalTryCatch(); |
1240 | 1247 |
1241 void InitializeDebugger(); | 1248 void InitializeDebugger(); |
1242 | 1249 |
1243 // Traverse prototype chain to find out whether the object is derived from | 1250 // Traverse prototype chain to find out whether the object is derived from |
1244 // the Error object. | 1251 // the Error object. |
1245 bool IsErrorObject(Handle<Object> obj); | 1252 bool IsErrorObject(Handle<Object> obj); |
1246 | 1253 |
1254 bool is_default_isolate_; | |
Michael Starzinger
2013/10/01 14:19:08
nit: Let's move this down to the other boolean fla
| |
1247 Atomic32 id_; | 1255 Atomic32 id_; |
1248 EntryStackItem* entry_stack_; | 1256 EntryStackItem* entry_stack_; |
1249 int stack_trace_nesting_level_; | 1257 int stack_trace_nesting_level_; |
1250 StringStream* incomplete_message_; | 1258 StringStream* incomplete_message_; |
1251 // The preallocated memory thread singleton. | 1259 // The preallocated memory thread singleton. |
1252 PreallocatedMemoryThread* preallocated_memory_thread_; | 1260 PreallocatedMemoryThread* preallocated_memory_thread_; |
1253 Address isolate_addresses_[kIsolateAddressCount + 1]; // NOLINT | 1261 Address isolate_addresses_[kIsolateAddressCount + 1]; // NOLINT |
1254 NoAllocationStringAllocator* preallocated_message_space_; | 1262 NoAllocationStringAllocator* preallocated_message_space_; |
1255 Bootstrapper* bootstrapper_; | 1263 Bootstrapper* bootstrapper_; |
1256 RuntimeProfiler* runtime_profiler_; | 1264 RuntimeProfiler* runtime_profiler_; |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1524 | 1532 |
1525 // Mark the native context with out of memory. | 1533 // Mark the native context with out of memory. |
1526 inline void Context::mark_out_of_memory() { | 1534 inline void Context::mark_out_of_memory() { |
1527 native_context()->set_out_of_memory(GetIsolate()->heap()->true_value()); | 1535 native_context()->set_out_of_memory(GetIsolate()->heap()->true_value()); |
1528 } | 1536 } |
1529 | 1537 |
1530 | 1538 |
1531 } } // namespace v8::internal | 1539 } } // namespace v8::internal |
1532 | 1540 |
1533 #endif // V8_ISOLATE_H_ | 1541 #endif // V8_ISOLATE_H_ |
OLD | NEW |