| 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 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1148 | 1148 |
| 1149 // The per-process lock should be acquired before the ThreadDataTable is | 1149 // The per-process lock should be acquired before the ThreadDataTable is |
| 1150 // modified. | 1150 // modified. |
| 1151 class ThreadDataTable { | 1151 class ThreadDataTable { |
| 1152 public: | 1152 public: |
| 1153 ThreadDataTable(); | 1153 ThreadDataTable(); |
| 1154 ~ThreadDataTable(); | 1154 ~ThreadDataTable(); |
| 1155 | 1155 |
| 1156 PerIsolateThreadData* Lookup(Isolate* isolate, ThreadId thread_id); | 1156 PerIsolateThreadData* Lookup(Isolate* isolate, ThreadId thread_id); |
| 1157 void Insert(PerIsolateThreadData* data); | 1157 void Insert(PerIsolateThreadData* data); |
| 1158 void Remove(Isolate* isolate, ThreadId thread_id); | |
| 1159 void Remove(PerIsolateThreadData* data); | 1158 void Remove(PerIsolateThreadData* data); |
| 1160 void RemoveAllThreads(Isolate* isolate); | 1159 void RemoveAllThreads(Isolate* isolate); |
| 1161 | 1160 |
| 1162 private: | 1161 private: |
| 1163 PerIsolateThreadData* list_; | 1162 PerIsolateThreadData* list_; |
| 1164 }; | 1163 }; |
| 1165 | 1164 |
| 1166 // These items form a stack synchronously with threads Enter'ing and Exit'ing | 1165 // These items form a stack synchronously with threads Enter'ing and Exit'ing |
| 1167 // the Isolate. The top of the stack points to a thread which is currently | 1166 // the Isolate. The top of the stack points to a thread which is currently |
| 1168 // running the Isolate. When the stack is empty, the Isolate is considered | 1167 // running the Isolate. When the stack is empty, the Isolate is considered |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1183 PerIsolateThreadData* previous_thread_data; | 1182 PerIsolateThreadData* previous_thread_data; |
| 1184 Isolate* previous_isolate; | 1183 Isolate* previous_isolate; |
| 1185 EntryStackItem* previous_item; | 1184 EntryStackItem* previous_item; |
| 1186 | 1185 |
| 1187 private: | 1186 private: |
| 1188 DISALLOW_COPY_AND_ASSIGN(EntryStackItem); | 1187 DISALLOW_COPY_AND_ASSIGN(EntryStackItem); |
| 1189 }; | 1188 }; |
| 1190 | 1189 |
| 1191 // This mutex protects highest_thread_id_, thread_data_table_ and | 1190 // This mutex protects highest_thread_id_, thread_data_table_ and |
| 1192 // default_isolate_. | 1191 // default_isolate_. |
| 1193 static RecursiveMutex process_wide_mutex_; | 1192 static Mutex process_wide_mutex_; |
| 1194 | 1193 |
| 1195 static Thread::LocalStorageKey per_isolate_thread_data_key_; | 1194 static Thread::LocalStorageKey per_isolate_thread_data_key_; |
| 1196 static Thread::LocalStorageKey isolate_key_; | 1195 static Thread::LocalStorageKey isolate_key_; |
| 1197 static Thread::LocalStorageKey thread_id_key_; | 1196 static Thread::LocalStorageKey thread_id_key_; |
| 1198 static Isolate* default_isolate_; | 1197 static Isolate* default_isolate_; |
| 1199 static ThreadDataTable* thread_data_table_; | 1198 static ThreadDataTable* thread_data_table_; |
| 1200 | 1199 |
| 1201 // A global counter for all generated Isolates, might overflow. | 1200 // A global counter for all generated Isolates, might overflow. |
| 1202 static Atomic32 isolate_counter_; | 1201 static Atomic32 isolate_counter_; |
| 1203 | 1202 |
| 1204 void Deinit(); | 1203 void Deinit(); |
| 1205 | 1204 |
| 1206 static void SetIsolateThreadLocals(Isolate* isolate, | 1205 static void SetIsolateThreadLocals(Isolate* isolate, |
| 1207 PerIsolateThreadData* data); | 1206 PerIsolateThreadData* data); |
| 1208 | 1207 |
| 1209 // Allocate and insert PerIsolateThreadData into the ThreadDataTable | |
| 1210 // (regardless of whether such data already exists). | |
| 1211 PerIsolateThreadData* AllocatePerIsolateThreadData(ThreadId thread_id); | |
| 1212 | |
| 1213 // Find the PerThread for this particular (isolate, thread) combination. | 1208 // Find the PerThread for this particular (isolate, thread) combination. |
| 1214 // If one does not yet exist, allocate a new one. | 1209 // If one does not yet exist, allocate a new one. |
| 1215 PerIsolateThreadData* FindOrAllocatePerThreadDataForThisThread(); | 1210 PerIsolateThreadData* FindOrAllocatePerThreadDataForThisThread(); |
| 1216 | 1211 |
| 1217 // Initializes the current thread to run this Isolate. | 1212 // Initializes the current thread to run this Isolate. |
| 1218 // Not thread-safe. Multiple threads should not Enter/Exit the same isolate | 1213 // Not thread-safe. Multiple threads should not Enter/Exit the same isolate |
| 1219 // at the same time, this should be prevented using external locking. | 1214 // at the same time, this should be prevented using external locking. |
| 1220 void Enter(); | 1215 void Enter(); |
| 1221 | 1216 |
| 1222 // Exits the current thread. The previosuly entered Isolate is restored | 1217 // Exits the current thread. The previosuly entered Isolate is restored |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1525 | 1520 |
| 1526 // Mark the native context with out of memory. | 1521 // Mark the native context with out of memory. |
| 1527 inline void Context::mark_out_of_memory() { | 1522 inline void Context::mark_out_of_memory() { |
| 1528 native_context()->set_out_of_memory(HEAP->true_value()); | 1523 native_context()->set_out_of_memory(HEAP->true_value()); |
| 1529 } | 1524 } |
| 1530 | 1525 |
| 1531 | 1526 |
| 1532 } } // namespace v8::internal | 1527 } } // namespace v8::internal |
| 1533 | 1528 |
| 1534 #endif // V8_ISOLATE_H_ | 1529 #endif // V8_ISOLATE_H_ |
| OLD | NEW |