Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Side by Side Diff: src/isolate.h

Issue 6788023: Per-isolate v8::Locker and v8::Unlocker (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: New tests for IsLocker Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 inline void set_try_catch_handler_address(Address address) { 213 inline void set_try_catch_handler_address(Address address) {
214 try_catch_handler_address_ = address; 214 try_catch_handler_address_ = address;
215 } 215 }
216 216
217 void Free() { 217 void Free() {
218 ASSERT(!has_pending_message_); 218 ASSERT(!has_pending_message_);
219 ASSERT(!external_caught_exception_); 219 ASSERT(!external_caught_exception_);
220 ASSERT(try_catch_handler_address_ == NULL); 220 ASSERT(try_catch_handler_address_ == NULL);
221 } 221 }
222 222
223 Isolate* isolate_;
223 // The context where the current execution method is created and for variable 224 // The context where the current execution method is created and for variable
224 // lookups. 225 // lookups.
225 Context* context_; 226 Context* context_;
226 ThreadId thread_id_; 227 ThreadId thread_id_;
227 MaybeObject* pending_exception_; 228 MaybeObject* pending_exception_;
228 bool has_pending_message_; 229 bool has_pending_message_;
229 Object* pending_message_obj_; 230 Object* pending_message_obj_;
230 Script* pending_message_script_; 231 Script* pending_message_script_;
231 int pending_message_start_pos_; 232 int pending_message_start_pos_;
232 int pending_message_end_pos_; 233 int pending_message_end_pos_;
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 void TearDown(); 474 void TearDown();
474 475
475 bool IsDefaultIsolate() const { return this == default_isolate_; } 476 bool IsDefaultIsolate() const { return this == default_isolate_; }
476 477
477 // Ensures that process-wide resources and the default isolate have been 478 // Ensures that process-wide resources and the default isolate have been
478 // allocated. It is only necessary to call this method in rare casses, for 479 // allocated. It is only necessary to call this method in rare casses, for
479 // example if you are using V8 from within the body of a static initializer. 480 // example if you are using V8 from within the body of a static initializer.
480 // Safe to call multiple times. 481 // Safe to call multiple times.
481 static void EnsureDefaultIsolate(); 482 static void EnsureDefaultIsolate();
482 483
484 // Find the PerThread for this particular (isolate, thread) combination
485 // If one does not yet exist, return null.
486 PerIsolateThreadData* FindPerThreadDataForThisThread();
487
483 // Get the debugger from the default isolate. Preinitializes the 488 // Get the debugger from the default isolate. Preinitializes the
484 // default isolate if needed. 489 // default isolate if needed.
485 static Debugger* GetDefaultIsolateDebugger(); 490 static Debugger* GetDefaultIsolateDebugger();
486 491
487 // Get the stack guard from the default isolate. Preinitializes the 492 // Get the stack guard from the default isolate. Preinitializes the
488 // default isolate if needed. 493 // default isolate if needed.
489 static StackGuard* GetDefaultIsolateStackGuard(); 494 static StackGuard* GetDefaultIsolateStackGuard();
490 495
491 // Returns the key used to store the pointer to the current isolate. 496 // Returns the key used to store the pointer to the current isolate.
492 // Used internally for V8 threads that do not execute JavaScript but still 497 // Used internally for V8 threads that do not execute JavaScript but still
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 EntryStackItem* entry_stack_; 1061 EntryStackItem* entry_stack_;
1057 1062
1058 // Allocate and insert PerIsolateThreadData into the ThreadDataTable 1063 // Allocate and insert PerIsolateThreadData into the ThreadDataTable
1059 // (regardless of whether such data already exists). 1064 // (regardless of whether such data already exists).
1060 PerIsolateThreadData* AllocatePerIsolateThreadData(ThreadId thread_id); 1065 PerIsolateThreadData* AllocatePerIsolateThreadData(ThreadId thread_id);
1061 1066
1062 // Find the PerThread for this particular (isolate, thread) combination. 1067 // Find the PerThread for this particular (isolate, thread) combination.
1063 // If one does not yet exist, allocate a new one. 1068 // If one does not yet exist, allocate a new one.
1064 PerIsolateThreadData* FindOrAllocatePerThreadDataForThisThread(); 1069 PerIsolateThreadData* FindOrAllocatePerThreadDataForThisThread();
1065 1070
1071 // Preinitialize this isolate for current thread. Thread-safe.
1072 // Only called from v8::Locker implementation.
1073 void EnsurePreinitializedForThisThread();
1074
1066 // PreInits and returns a default isolate. Needed when a new thread tries 1075 // PreInits and returns a default isolate. Needed when a new thread tries
1067 // to create a Locker for the first time (the lock itself is in the isolate). 1076 // to create a Locker for the first time (the lock itself is in the isolate).
1068 static Isolate* GetDefaultIsolateForLocking(); 1077 static Isolate* GetDefaultIsolateForLocking();
1069 1078
1070 // Initializes the current thread to run this Isolate. 1079 // Initializes the current thread to run this Isolate.
1071 // Not thread-safe. Multiple threads should not Enter/Exit the same isolate 1080 // Not thread-safe. Multiple threads should not Enter/Exit the same isolate
1072 // at the same time, this should be prevented using external locking. 1081 // at the same time, this should be prevented using external locking.
1073 void Enter(); 1082 void Enter();
1074 1083
1075 // Exits the current thread. The previosuly entered Isolate is restored 1084 // Exits the current thread. The previosuly entered Isolate is restored
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 // between compilation units. 1199 // between compilation units.
1191 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ 1200 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \
1192 static const intptr_t name##_debug_offset_; 1201 static const intptr_t name##_debug_offset_;
1193 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) 1202 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET)
1194 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) 1203 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET)
1195 #undef ISOLATE_FIELD_OFFSET 1204 #undef ISOLATE_FIELD_OFFSET
1196 #endif 1205 #endif
1197 1206
1198 friend class ExecutionAccess; 1207 friend class ExecutionAccess;
1199 friend class IsolateInitializer; 1208 friend class IsolateInitializer;
1209 friend class ThreadManager;
1210 friend class StackGuard;
1200 friend class ThreadId; 1211 friend class ThreadId;
1201 friend class v8::Isolate; 1212 friend class v8::Isolate;
1202 friend class v8::Locker; 1213 friend class v8::Locker;
1214 friend class v8::Unlocker;
1203 1215
1204 DISALLOW_COPY_AND_ASSIGN(Isolate); 1216 DISALLOW_COPY_AND_ASSIGN(Isolate);
1205 }; 1217 };
1206 1218
1207 1219
1208 // If the GCC version is 4.1.x or 4.2.x an additional field is added to the 1220 // If the GCC version is 4.1.x or 4.2.x an additional field is added to the
1209 // class as a work around for a bug in the generated code found with these 1221 // class as a work around for a bug in the generated code found with these
1210 // versions of GCC. See V8 issue 122 for details. 1222 // versions of GCC. See V8 issue 122 for details.
1211 class SaveContext BASE_EMBEDDED { 1223 class SaveContext BASE_EMBEDDED {
1212 public: 1224 public:
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 1385
1374 } } // namespace v8::internal 1386 } } // namespace v8::internal
1375 1387
1376 // TODO(isolates): Get rid of these -inl.h includes and place them only where 1388 // TODO(isolates): Get rid of these -inl.h includes and place them only where
1377 // they're needed. 1389 // they're needed.
1378 #include "allocation-inl.h" 1390 #include "allocation-inl.h"
1379 #include "zone-inl.h" 1391 #include "zone-inl.h"
1380 #include "frames-inl.h" 1392 #include "frames-inl.h"
1381 1393
1382 #endif // V8_ISOLATE_H_ 1394 #endif // V8_ISOLATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698