55 |
#ifdef JS_THREADSAFE |
#ifdef JS_THREADSAFE |
56 |
|
|
57 |
#if (defined(_WIN32) && defined(_M_IX86)) || \ |
#if (defined(_WIN32) && defined(_M_IX86)) || \ |
58 |
(defined(__GNUC__) && defined(__i386__)) || \ |
(defined(_WIN64) && (defined(_M_AMD64) || defined(_M_X64))) || \ |
59 |
(defined(__GNUC__) && defined(__x86_64__)) || \ |
(defined(__i386) && (defined(__GNUC__) || defined(__SUNPRO_CC))) || \ |
60 |
(defined(SOLARIS) && defined(sparc) && defined(ULTRA_SPARC)) || \ |
(defined(__x86_64) && (defined(__GNUC__) || defined(__SUNPRO_CC))) || \ |
61 |
|
(defined(__sparc) && (defined(__GNUC__) || defined(__SUNPRO_CC))) || \ |
62 |
defined(AIX) || \ |
defined(AIX) || \ |
63 |
defined(USE_ARM_KUSER) |
defined(USE_ARM_KUSER) |
64 |
# define JS_HAS_NATIVE_COMPARE_AND_SWAP 1 |
# define JS_HAS_NATIVE_COMPARE_AND_SWAP 1 |
161 |
#define JS_UNLOCK_OBJ(cx,obj) ((OBJ_SCOPE(obj)->title.ownercx == (cx)) \ |
#define JS_UNLOCK_OBJ(cx,obj) ((OBJ_SCOPE(obj)->title.ownercx == (cx)) \ |
162 |
? (void)0 : js_UnlockObj(cx, obj)) |
? (void)0 : js_UnlockObj(cx, obj)) |
163 |
|
|
164 |
|
/* |
165 |
|
* Lock object only if its scope has the given shape. |
166 |
|
*/ |
167 |
|
#define JS_LOCK_OBJ_IF_SHAPE(cx,obj,shape) \ |
168 |
|
(OBJ_SHAPE(obj) == (shape) \ |
169 |
|
? (OBJ_SCOPE(obj)->title.ownercx == (cx) \ |
170 |
|
? true \ |
171 |
|
: js_LockObjIfShape(cx, obj, shape)) \ |
172 |
|
: false) |
173 |
|
|
174 |
#define JS_LOCK_TITLE(cx,title) \ |
#define JS_LOCK_TITLE(cx,title) \ |
175 |
((title)->ownercx == (cx) ? (void)0 \ |
((title)->ownercx == (cx) ? (void)0 \ |
176 |
: (js_LockTitle(cx, (title)), \ |
: (js_LockTitle(cx, (title)), \ |
192 |
extern void js_UnlockRuntime(JSRuntime *rt); |
extern void js_UnlockRuntime(JSRuntime *rt); |
193 |
extern void js_LockObj(JSContext *cx, JSObject *obj); |
extern void js_LockObj(JSContext *cx, JSObject *obj); |
194 |
extern void js_UnlockObj(JSContext *cx, JSObject *obj); |
extern void js_UnlockObj(JSContext *cx, JSObject *obj); |
195 |
|
#ifdef __cplusplus /* Allow inclusion from LiveConnect C files. */ |
196 |
|
extern bool js_LockObjIfShape(JSContext *cx, JSObject *obj, uint32 shape); |
197 |
|
#else |
198 |
|
extern JSBool js_LockObjIfShape(JSContext *cx, JSObject *obj, uint32 shape); |
199 |
|
#endif |
200 |
extern void js_InitTitle(JSContext *cx, JSTitle *title); |
extern void js_InitTitle(JSContext *cx, JSTitle *title); |
201 |
extern void js_FinishTitle(JSContext *cx, JSTitle *title); |
extern void js_FinishTitle(JSContext *cx, JSTitle *title); |
202 |
extern void js_LockTitle(JSContext *cx, JSTitle *title); |
extern void js_LockTitle(JSContext *cx, JSTitle *title); |
240 |
|
|
241 |
#endif /* DEBUG */ |
#endif /* DEBUG */ |
242 |
|
|
|
#define JS_LOCK_OBJ_VOID(cx, obj, e) \ |
|
|
JS_BEGIN_MACRO \ |
|
|
JS_LOCK_OBJ(cx, obj); \ |
|
|
e; \ |
|
|
JS_UNLOCK_OBJ(cx, obj); \ |
|
|
JS_END_MACRO |
|
|
|
|
|
#define JS_LOCK_VOID(cx, e) \ |
|
|
JS_BEGIN_MACRO \ |
|
|
JSRuntime *_rt = (cx)->runtime; \ |
|
|
JS_LOCK_RUNTIME_VOID(_rt, e); \ |
|
|
JS_END_MACRO |
|
|
|
|
243 |
#else /* !JS_THREADSAFE */ |
#else /* !JS_THREADSAFE */ |
244 |
|
|
245 |
#define JS_ATOMIC_INCREMENT(p) (++*(p)) |
#define JS_ATOMIC_INCREMENT(p) (++*(p)) |
265 |
#define JS_UNLOCK_RUNTIME(rt) ((void)0) |
#define JS_UNLOCK_RUNTIME(rt) ((void)0) |
266 |
#define JS_LOCK_OBJ(cx,obj) ((void)0) |
#define JS_LOCK_OBJ(cx,obj) ((void)0) |
267 |
#define JS_UNLOCK_OBJ(cx,obj) ((void)0) |
#define JS_UNLOCK_OBJ(cx,obj) ((void)0) |
268 |
|
#define JS_LOCK_OBJ_IF_SHAPE(cx,obj,shape) (OBJ_SHAPE(obj) == (shape)) |
269 |
|
|
270 |
#define JS_LOCK_OBJ_VOID(cx,obj,e) (e) |
#define JS_LOCK_OBJ_VOID(cx,obj,e) (e) |
271 |
#define JS_LOCK_SCOPE(cx,scope) ((void)0) |
#define JS_LOCK_SCOPE(cx,scope) ((void)0) |
272 |
#define JS_UNLOCK_SCOPE(cx,scope) ((void)0) |
#define JS_UNLOCK_SCOPE(cx,scope) ((void)0) |
275 |
#define JS_IS_RUNTIME_LOCKED(rt) 1 |
#define JS_IS_RUNTIME_LOCKED(rt) 1 |
276 |
#define JS_IS_OBJ_LOCKED(cx,obj) 1 |
#define JS_IS_OBJ_LOCKED(cx,obj) 1 |
277 |
#define JS_IS_TITLE_LOCKED(cx,title) 1 |
#define JS_IS_TITLE_LOCKED(cx,title) 1 |
|
#define JS_LOCK_VOID(cx, e) JS_LOCK_RUNTIME_VOID((cx)->runtime, e) |
|
278 |
|
|
279 |
#endif /* !JS_THREADSAFE */ |
#endif /* !JS_THREADSAFE */ |
280 |
|
|
287 |
|
|
288 |
#define JS_LOCK_GC(rt) JS_ACQUIRE_LOCK((rt)->gcLock) |
#define JS_LOCK_GC(rt) JS_ACQUIRE_LOCK((rt)->gcLock) |
289 |
#define JS_UNLOCK_GC(rt) JS_RELEASE_LOCK((rt)->gcLock) |
#define JS_UNLOCK_GC(rt) JS_RELEASE_LOCK((rt)->gcLock) |
|
#define JS_LOCK_GC_VOID(rt,e) (JS_LOCK_GC(rt), (e), JS_UNLOCK_GC(rt)) |
|
290 |
#define JS_AWAIT_GC_DONE(rt) JS_WAIT_CONDVAR((rt)->gcDone, JS_NO_TIMEOUT) |
#define JS_AWAIT_GC_DONE(rt) JS_WAIT_CONDVAR((rt)->gcDone, JS_NO_TIMEOUT) |
291 |
#define JS_NOTIFY_GC_DONE(rt) JS_NOTIFY_ALL_CONDVAR((rt)->gcDone) |
#define JS_NOTIFY_GC_DONE(rt) JS_NOTIFY_ALL_CONDVAR((rt)->gcDone) |
292 |
#define JS_AWAIT_REQUEST_DONE(rt) JS_WAIT_CONDVAR((rt)->requestDone, \ |
#define JS_AWAIT_REQUEST_DONE(rt) JS_WAIT_CONDVAR((rt)->requestDone, \ |