OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 inline void set_try_catch_handler_address(Address address) { | 217 inline void set_try_catch_handler_address(Address address) { |
218 try_catch_handler_address_ = address; | 218 try_catch_handler_address_ = address; |
219 } | 219 } |
220 | 220 |
221 void Free() { | 221 void Free() { |
222 ASSERT(!has_pending_message_); | 222 ASSERT(!has_pending_message_); |
223 ASSERT(!external_caught_exception_); | 223 ASSERT(!external_caught_exception_); |
224 ASSERT(try_catch_handler_address_ == NULL); | 224 ASSERT(try_catch_handler_address_ == NULL); |
225 } | 225 } |
226 | 226 |
227 Isolate* isolate_; | |
227 // The context where the current execution method is created and for variable | 228 // The context where the current execution method is created and for variable |
228 // lookups. | 229 // lookups. |
229 Context* context_; | 230 Context* context_; |
230 ThreadId thread_id_; | 231 ThreadId thread_id_; |
231 MaybeObject* pending_exception_; | 232 MaybeObject* pending_exception_; |
232 bool has_pending_message_; | 233 bool has_pending_message_; |
233 Object* pending_message_obj_; | 234 Object* pending_message_obj_; |
234 Script* pending_message_script_; | 235 Script* pending_message_script_; |
235 int pending_message_start_pos_; | 236 int pending_message_start_pos_; |
236 int pending_message_end_pos_; | 237 int pending_message_end_pos_; |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
479 void TearDown(); | 480 void TearDown(); |
480 | 481 |
481 bool IsDefaultIsolate() const { return this == default_isolate_; } | 482 bool IsDefaultIsolate() const { return this == default_isolate_; } |
482 | 483 |
483 // Ensures that process-wide resources and the default isolate have been | 484 // Ensures that process-wide resources and the default isolate have been |
484 // allocated. It is only necessary to call this method in rare casses, for | 485 // allocated. It is only necessary to call this method in rare casses, for |
485 // 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. |
486 // Safe to call multiple times. | 487 // Safe to call multiple times. |
487 static void EnsureDefaultIsolate(); | 488 static void EnsureDefaultIsolate(); |
488 | 489 |
490 // Find the PerThread for this particular (isolate, thread) combination | |
491 // If one does not yet exist, return null. | |
492 PerIsolateThreadData* FindPerThreadDataForThisThread(); | |
493 | |
489 // Get the debugger from the default isolate. Preinitializes the | 494 // Get the debugger from the default isolate. Preinitializes the |
490 // default isolate if needed. | 495 // default isolate if needed. |
491 static Debugger* GetDefaultIsolateDebugger(); | 496 static Debugger* GetDefaultIsolateDebugger(); |
492 | 497 |
493 // Get the stack guard from the default isolate. Preinitializes the | 498 // Get the stack guard from the default isolate. Preinitializes the |
494 // default isolate if needed. | 499 // default isolate if needed. |
495 static StackGuard* GetDefaultIsolateStackGuard(); | 500 static StackGuard* GetDefaultIsolateStackGuard(); |
496 | 501 |
497 // Returns the key used to store the pointer to the current isolate. | 502 // 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 | 503 // Used internally for V8 threads that do not execute JavaScript but still |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1062 EntryStackItem* entry_stack_; | 1067 EntryStackItem* entry_stack_; |
1063 | 1068 |
1064 // Allocate and insert PerIsolateThreadData into the ThreadDataTable | 1069 // Allocate and insert PerIsolateThreadData into the ThreadDataTable |
1065 // (regardless of whether such data already exists). | 1070 // (regardless of whether such data already exists). |
1066 PerIsolateThreadData* AllocatePerIsolateThreadData(ThreadId thread_id); | 1071 PerIsolateThreadData* AllocatePerIsolateThreadData(ThreadId thread_id); |
1067 | 1072 |
1068 // Find the PerThread for this particular (isolate, thread) combination. | 1073 // Find the PerThread for this particular (isolate, thread) combination. |
1069 // If one does not yet exist, allocate a new one. | 1074 // If one does not yet exist, allocate a new one. |
1070 PerIsolateThreadData* FindOrAllocatePerThreadDataForThisThread(); | 1075 PerIsolateThreadData* FindOrAllocatePerThreadDataForThisThread(); |
1071 | 1076 |
1077 // Preinitialize this isolate for current thread. Thread-safe. | |
Vitaly Repeshko
2011/04/21 21:15:27
Unused? Remove.
| |
1078 // Only called from v8::Locker implementation. | |
1079 void EnsurePreinitializedForThisThread(); | |
1080 | |
1072 // PreInits and returns a default isolate. Needed when a new thread tries | 1081 // PreInits and returns a default isolate. Needed when a new thread tries |
1073 // to create a Locker for the first time (the lock itself is in the isolate). | 1082 // to create a Locker for the first time (the lock itself is in the isolate). |
1074 static Isolate* GetDefaultIsolateForLocking(); | 1083 static Isolate* GetDefaultIsolateForLocking(); |
1075 | 1084 |
1076 // Initializes the current thread to run this Isolate. | 1085 // Initializes the current thread to run this Isolate. |
1077 // Not thread-safe. Multiple threads should not Enter/Exit the same isolate | 1086 // Not thread-safe. Multiple threads should not Enter/Exit the same isolate |
1078 // at the same time, this should be prevented using external locking. | 1087 // at the same time, this should be prevented using external locking. |
1079 void Enter(); | 1088 void Enter(); |
1080 | 1089 |
1081 // Exits the current thread. The previosuly entered Isolate is restored | 1090 // Exits the current thread. The previosuly entered Isolate is restored |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1196 // between compilation units. | 1205 // between compilation units. |
1197 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ | 1206 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ |
1198 static const intptr_t name##_debug_offset_; | 1207 static const intptr_t name##_debug_offset_; |
1199 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) | 1208 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) |
1200 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) | 1209 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) |
1201 #undef ISOLATE_FIELD_OFFSET | 1210 #undef ISOLATE_FIELD_OFFSET |
1202 #endif | 1211 #endif |
1203 | 1212 |
1204 friend class ExecutionAccess; | 1213 friend class ExecutionAccess; |
1205 friend class IsolateInitializer; | 1214 friend class IsolateInitializer; |
1215 friend class ThreadManager; | |
1216 friend class StackGuard; | |
1206 friend class ThreadId; | 1217 friend class ThreadId; |
1207 friend class v8::Isolate; | 1218 friend class v8::Isolate; |
1208 friend class v8::Locker; | 1219 friend class v8::Locker; |
1220 friend class v8::Unlocker; | |
1209 | 1221 |
1210 DISALLOW_COPY_AND_ASSIGN(Isolate); | 1222 DISALLOW_COPY_AND_ASSIGN(Isolate); |
1211 }; | 1223 }; |
1212 | 1224 |
1213 | 1225 |
1214 // If the GCC version is 4.1.x or 4.2.x an additional field is added to the | 1226 // If the GCC version is 4.1.x or 4.2.x an additional field is added to the |
1215 // class as a work around for a bug in the generated code found with these | 1227 // class as a work around for a bug in the generated code found with these |
1216 // versions of GCC. See V8 issue 122 for details. | 1228 // versions of GCC. See V8 issue 122 for details. |
1217 class SaveContext BASE_EMBEDDED { | 1229 class SaveContext BASE_EMBEDDED { |
1218 public: | 1230 public: |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1379 | 1391 |
1380 } } // namespace v8::internal | 1392 } } // namespace v8::internal |
1381 | 1393 |
1382 // TODO(isolates): Get rid of these -inl.h includes and place them only where | 1394 // TODO(isolates): Get rid of these -inl.h includes and place them only where |
1383 // they're needed. | 1395 // they're needed. |
1384 #include "allocation-inl.h" | 1396 #include "allocation-inl.h" |
1385 #include "zone-inl.h" | 1397 #include "zone-inl.h" |
1386 #include "frames-inl.h" | 1398 #include "frames-inl.h" |
1387 | 1399 |
1388 #endif // V8_ISOLATE_H_ | 1400 #endif // V8_ISOLATE_H_ |
OLD | NEW |