--- sbbs/include/mozilla/js/jslock.h 2018/04/24 16:41:23 1.1 +++ sbbs/include/mozilla/js/jslock.h 2018/04/24 16:42:11 1.1.1.2 @@ -45,6 +45,7 @@ #include "pratom.h" #include "prlock.h" #include "prcvar.h" +#include "prthread.h" #include "jsprvtd.h" /* for JSScope, etc. */ #include "jspubtd.h" /* for JSRuntime, etc. */ @@ -68,6 +69,9 @@ typedef struct JSThinLock { JSFatLock *fat; } JSThinLock; +#define CX_THINLOCK_ID(cx) ((jsword)(cx)->thread) +#define CURRENT_THREAD_IS_ME(me) (((JSThread *)me)->id == js_CurrentThreadId()) + typedef PRLock JSLock; typedef struct JSFatLockTable { @@ -83,8 +87,7 @@ typedef struct JSFatLockTable { #define JS_ATOMIC_DECREMENT(p) PR_AtomicDecrement((PRInt32 *)(p)) #define JS_ATOMIC_ADD(p,v) PR_AtomicAdd((PRInt32 *)(p), (PRInt32)(v)) -#define CurrentThreadId() (jsword)PR_GetCurrentThread() -#define JS_CurrentThreadId() js_CurrentThreadId() +#define js_CurrentThreadId() (jsword)PR_GetCurrentThread() #define JS_NEW_LOCK() PR_NewLock() #define JS_DESTROY_LOCK(l) PR_DestroyLock(l) #define JS_ACQUIRE_LOCK(l) PR_Lock(l) @@ -106,28 +109,9 @@ typedef struct JSFatLockTable { * an #include cycle between jslock.h and jsscope.h: moderate-sized XXX here, * to be fixed by moving JS_LOCK_SCOPE to jsscope.h, JS_LOCK_OBJ to jsobj.h, * and so on. - * - * We also need jsscope.h #ifdef DEBUG for SET_OBJ_INFO and SET_SCOPE_INFO, - * but we do not want any nested includes that depend on DEBUG. Those lead - * to build bustage when someone makes a change that depends in a subtle way - * on jsscope.h being included directly or indirectly, but does not test by - * building optimized as well as DEBUG. */ #include "jsscope.h" -#ifdef DEBUG - -#define SET_OBJ_INFO(obj_,file_,line_) \ - SET_SCOPE_INFO(OBJ_SCOPE(obj_),file_,line_) - -#define SET_SCOPE_INFO(scope_,file_,line_) \ - ((scope_)->ownercx ? (void)0 : \ - (JS_ASSERT((0 < (scope_)->u.count && (scope_)->u.count <= 4) || \ - SCOPE_IS_SEALED(scope_)), \ - (void)((scope_)->file[(scope_)->u.count-1] = (file_), \ - (scope_)->line[(scope_)->u.count-1] = (line_)))) -#endif /* DEBUG */ - #define JS_LOCK_RUNTIME(rt) js_LockRuntime(rt) #define JS_UNLOCK_RUNTIME(rt) js_UnlockRuntime(rt) @@ -140,20 +124,17 @@ typedef struct JSFatLockTable { */ #define JS_LOCK_OBJ(cx,obj) ((OBJ_SCOPE(obj)->ownercx == (cx)) \ ? (void)0 \ - : (js_LockObj(cx, obj), \ - SET_OBJ_INFO(obj,__FILE__,__LINE__))) + : (js_LockObj(cx, obj))) #define JS_UNLOCK_OBJ(cx,obj) ((OBJ_SCOPE(obj)->ownercx == (cx)) \ ? (void)0 : js_UnlockObj(cx, obj)) -#define JS_LOCK_SCOPE(cx,scope) ((scope)->ownercx == (cx) ? (void)0 : \ - (js_LockScope(cx, scope), \ - SET_SCOPE_INFO(scope,__FILE__,__LINE__))) -#define JS_UNLOCK_SCOPE(cx,scope) ((scope)->ownercx == (cx) ? (void)0 : \ - js_UnlockScope(cx, scope)) +#define JS_LOCK_SCOPE(cx,scope) ((scope)->ownercx == (cx) ? (void)0 \ + : js_LockScope(cx, scope)) +#define JS_UNLOCK_SCOPE(cx,scope) ((scope)->ownercx == (cx) ? (void)0 \ + : js_UnlockScope(cx, scope)) #define JS_TRANSFER_SCOPE_LOCK(cx, scope, newscope) \ js_TransferScopeLock(cx, scope, newscope) -extern jsword js_CurrentThreadId(); extern void js_LockRuntime(JSRuntime *rt); extern void js_UnlockRuntime(JSRuntime *rt); extern void js_LockObj(JSContext *cx, JSObject *obj); @@ -162,7 +143,6 @@ extern void js_LockScope(JSContext *cx, extern void js_UnlockScope(JSContext *cx, JSScope *scope); extern int js_SetupLocks(int,int); extern void js_CleanupLocks(); -extern void js_InitContextForLocking(JSContext *); extern void js_TransferScopeLock(JSContext *, JSScope *, JSScope *); extern JS_FRIEND_API(jsval) js_GetSlotThreadSafe(JSContext *, JSObject *, uint32); @@ -202,9 +182,13 @@ extern JSBool js_IsScopeLocked(JSContext JS_LOCK_RUNTIME_VOID(_rt, e); \ JS_END_MACRO +/* FIXME: bug 353962 hackaround */ +#define JS_USE_ONLY_NSPR_LOCKS 1 + #if defined(JS_USE_ONLY_NSPR_LOCKS) || \ !( (defined(_WIN32) && defined(_M_IX86)) || \ (defined(__GNUC__) && defined(__i386__)) || \ + ((defined(__USLC__) || defined(_SCO_DS)) && defined(i386)) || \ (defined(SOLARIS) && defined(sparc) && defined(ULTRA_SPARC)) || \ defined(AIX) ) @@ -276,14 +260,7 @@ extern JS_INLINE void js_Unlock(JSThinLo JS_NO_TIMEOUT) #define JS_NOTIFY_REQUEST_DONE(rt) JS_NOTIFY_CONDVAR((rt)->requestDone) -#define JS_LOCK(P,CX) JS_LOCK0(P,(CX)->thread) -#define JS_UNLOCK(P,CX) JS_UNLOCK0(P,(CX)->thread) - -#ifndef SET_OBJ_INFO -#define SET_OBJ_INFO(obj,f,l) ((void)0) -#endif -#ifndef SET_SCOPE_INFO -#define SET_SCOPE_INFO(scope,f,l) ((void)0) -#endif +#define JS_LOCK(P,CX) JS_LOCK0(P, CX_THINLOCK_ID(CX)) +#define JS_UNLOCK(P,CX) JS_UNLOCK0(P, CX_THINLOCK_ID(CX)) #endif /* jslock_h___ */