Bug 731898: Remove typedef jsrefcount, r=luke
authorDavid Mandelin <dmandelin@mozilla.com>
Thu, 01 Mar 2012 11:43:17 -0800
changeset 88321 9613e21afa3425f13a8ff343f3ea581f9d1c17dc
parent 88320 fed586e905ec0a8712ca6b9f8127e5133e690b30
child 88322 0f085bd21bc75eb6453c6101086e1fe80c21d61d
push id157
push userMs2ger@gmail.com
push dateWed, 07 Mar 2012 19:27:10 +0000
reviewersluke
bugs731898
milestone13.0a1
Bug 731898: Remove typedef jsrefcount, r=luke
js/src/jsapi.cpp
js/src/jsapi.h
js/src/jscntxt.h
js/src/jscompartment.h
js/src/jspubtd.h
js/src/shell/js.cpp
js/xpconnect/src/xpcprivate.h
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -1068,38 +1068,38 @@ JS_PUBLIC_API(void)
 JS_YieldRequest(JSContext *cx)
 {
 #ifdef JS_THREADSAFE
     CHECK_REQUEST(cx);
     JS_ResumeRequest(cx, JS_SuspendRequest(cx));
 #endif
 }
 
-JS_PUBLIC_API(jsrefcount)
+JS_PUBLIC_API(unsigned)
 JS_SuspendRequest(JSContext *cx)
 {
 #ifdef JS_THREADSAFE
     JSRuntime *rt = cx->runtime;
     JS_ASSERT(rt->onOwnerThread());
 
-    jsrefcount saveDepth = rt->requestDepth;
+    unsigned saveDepth = rt->requestDepth;
     if (!saveDepth)
         return 0;
 
     rt->suspendCount++;
     rt->requestDepth = 1;
     StopRequest(cx);
     return saveDepth;
 #else
     return 0;
 #endif
 }
 
 JS_PUBLIC_API(void)
-JS_ResumeRequest(JSContext *cx, jsrefcount saveDepth)
+JS_ResumeRequest(JSContext *cx, unsigned saveDepth)
 {
 #ifdef JS_THREADSAFE
     JSRuntime *rt = cx->runtime;
     JS_ASSERT(rt->onOwnerThread());
     if (saveDepth == 0)
         return;
     JS_ASSERT(saveDepth >= 1);
     JS_ASSERT(!rt->requestDepth);
@@ -4442,26 +4442,26 @@ JS_CheckAccess(JSContext *cx, JSObject *
 {
     AssertNoGC(cx);
     CHECK_REQUEST(cx);
     assertSameCompartment(cx, obj, id);
     return CheckAccess(cx, obj, id, mode, vp, attrsp);
 }
 
 #ifdef JS_THREADSAFE
-JS_PUBLIC_API(jsrefcount)
+JS_PUBLIC_API(int)
 JS_HoldPrincipals(JSContext *cx, JSPrincipals *principals)
 {
     return JS_ATOMIC_INCREMENT(&principals->refcount);
 }
 
-JS_PUBLIC_API(jsrefcount)
+JS_PUBLIC_API(int)
 JS_DropPrincipals(JSContext *cx, JSPrincipals *principals)
 {
-    jsrefcount rc = JS_ATOMIC_DECREMENT(&principals->refcount);
+    int rc = JS_ATOMIC_DECREMENT(&principals->refcount);
     if (rc == 0)
         principals->destroy(cx, principals);
     return rc;
 }
 #endif
 
 JS_PUBLIC_API(JSSecurityCallbacks *)
 JS_SetRuntimeSecurityCallbacks(JSRuntime *rt, JSSecurityCallbacks *callbacks)
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -2346,21 +2346,21 @@ JS_BeginRequest(JSContext *cx);
 
 extern JS_PUBLIC_API(void)
 JS_EndRequest(JSContext *cx);
 
 /* Yield to pending GC operations, regardless of request depth */
 extern JS_PUBLIC_API(void)
 JS_YieldRequest(JSContext *cx);
 
-extern JS_PUBLIC_API(jsrefcount)
+extern JS_PUBLIC_API(unsigned)
 JS_SuspendRequest(JSContext *cx);
 
 extern JS_PUBLIC_API(void)
-JS_ResumeRequest(JSContext *cx, jsrefcount saveDepth);
+JS_ResumeRequest(JSContext *cx, unsigned saveDepth);
 
 extern JS_PUBLIC_API(JSBool)
 JS_IsInRequest(JSRuntime *rt);
 
 extern JS_PUBLIC_API(JSBool)
 JS_IsInSuspendedRequest(JSRuntime *rt);
 
 #ifdef __cplusplus
@@ -2391,17 +2391,17 @@ class JSAutoRequest {
         mSaveDepth = JS_SuspendRequest(mContext);
     }
     void resume() {
         JS_ResumeRequest(mContext, mSaveDepth);
     }
 
   protected:
     JSContext *mContext;
-    jsrefcount mSaveDepth;
+    unsigned  mSaveDepth;
     JS_DECL_USE_GUARD_OBJECT_NOTIFIER
 
 #if 0
   private:
     static void *operator new(size_t) CPP_THROW_NEW { return 0; };
     static void operator delete(void *, size_t) { };
 #endif
 };
@@ -2423,17 +2423,17 @@ class JSAutoSuspendRequest {
         if (mContext) {
             JS_ResumeRequest(mContext, mSaveDepth);
             mContext = 0;
         }
     }
 
   protected:
     JSContext *mContext;
-    jsrefcount mSaveDepth;
+    unsigned mSaveDepth;
     JS_DECL_USE_GUARD_OBJECT_NOTIFIER
 
 #if 0
   private:
     static void *operator new(size_t) CPP_THROW_NEW { return 0; };
     static void operator delete(void *, size_t) { };
 #endif
 };
@@ -4080,30 +4080,30 @@ JS_SetReservedSlot(JSObject *obj, uint32
 
 /*
  * Security protocol.
  */
 struct JSPrincipals {
     char *codebase;
 
     /* Don't call "destroy"; use reference counting macros below. */
-    jsrefcount refcount;
+    int refcount;
 
     void   (* destroy)(JSContext *cx, JSPrincipals *);
     JSBool (* subsume)(JSPrincipals *, JSPrincipals *);
 };
 
 #ifdef JS_THREADSAFE
 #define JSPRINCIPALS_HOLD(cx, principals)   JS_HoldPrincipals(cx,principals)
 #define JSPRINCIPALS_DROP(cx, principals)   JS_DropPrincipals(cx,principals)
 
-extern JS_PUBLIC_API(jsrefcount)
+extern JS_PUBLIC_API(int)
 JS_HoldPrincipals(JSContext *cx, JSPrincipals *principals);
 
-extern JS_PUBLIC_API(jsrefcount)
+extern JS_PUBLIC_API(int)
 JS_DropPrincipals(JSContext *cx, JSPrincipals *principals);
 
 #else
 #define JSPRINCIPALS_HOLD(cx, principals)   (++(principals)->refcount)
 #define JSPRINCIPALS_DROP(cx, principals)                                     \
     ((--(principals)->refcount == 0)                                          \
      ? ((*(principals)->destroy)((cx), (principals)), 0)                      \
      : (principals)->refcount)
--- a/js/src/jscntxt.h
+++ b/js/src/jscntxt.h
@@ -81,17 +81,17 @@ struct JSSharpInfo {
     bool isSharp;
 
     JSSharpInfo() : hasGen(false), isSharp(false) {}
 };
 
 typedef js::HashMap<JSObject *, JSSharpInfo> JSSharpTable;
 
 struct JSSharpObjectMap {
-    jsrefcount   depth;
+    unsigned     depth;
     uint32_t     sharpgen;
     JSSharpTable table;
 
     JSSharpObjectMap(JSContext *cx) : depth(0), sharpgen(0), table(js::TempAllocPolicy(cx)) {
         table.init();
     }
 };
 
@@ -288,17 +288,17 @@ struct JSRuntime : js::RuntimeFriendFiel
      * removed from the list and scheduled for release.
      */
     js::gc::Chunk       *gcSystemAvailableChunkListHead;
     js::gc::Chunk       *gcUserAvailableChunkListHead;
     js::gc::ChunkPool   gcChunkPool;
 
     js::RootedValueMap  gcRootsHash;
     js::GCLocks         gcLocksHash;
-    jsrefcount          gcKeepAtoms;
+    unsigned            gcKeepAtoms;
     size_t              gcBytes;
     size_t              gcMaxBytes;
     size_t              gcMaxMallocBytes;
 
     /*
      * Number of the committed arenas in all GC chunks including empty chunks.
      * The counter is volatile as it is read without the GC lock, see comments
      * in MaybeGC.
--- a/js/src/jscompartment.h
+++ b/js/src/jscompartment.h
@@ -265,20 +265,20 @@ struct JSCompartment
 
     /*
      * Shared scope property tree, and arena-pool for allocating its nodes.
      */
     js::PropertyTree             propertyTree;
 
 #ifdef DEBUG
     /* Property metering. */
-    jsrefcount                   livePropTreeNodes;
-    jsrefcount                   totalPropTreeNodes;
-    jsrefcount                   propTreeKidsChunks;
-    jsrefcount                   liveDictModeNodes;
+    unsigned                     livePropTreeNodes;
+    unsigned                     totalPropTreeNodes;
+    unsigned                     propTreeKidsChunks;
+    unsigned                     liveDictModeNodes;
 #endif
 
     /* Set of all unowned base shapes in the compartment. */
     js::BaseShapeSet             baseShapes;
     void sweepBaseShapeTable(JSContext *cx);
 
     /* Set of initial shapes in the compartment. */
     js::InitialShapeSet          initialShapes;
--- a/js/src/jspubtd.h
+++ b/js/src/jspubtd.h
@@ -91,17 +91,16 @@ typedef ptrdiff_t jsid;
 # define JSID_BITS(id) (id)
 #endif
 
 JS_BEGIN_EXTERN_C
 
 /* Scalar typedefs. */
 typedef int32_t   jsint;
 typedef uint32_t  jsuint;
-typedef int32_t   jsrefcount;   /* PRInt32 if JS_THREADSAFE, see jslock.h */
 
 #ifdef WIN32
 typedef wchar_t   jschar;
 #else
 typedef uint16_t  jschar;
 #endif
 
 /*
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -1614,17 +1614,17 @@ CountHeap(JSContext *cx, unsigned argc, 
     if (!countTracer.ok) {
         JS_ReportOutOfMemory(cx);
         return false;
     }
 
     return JS_NewNumberValue(cx, (double) counter, vp);
 }
 
-static jsrefcount finalizeCount = 0;
+static unsigned finalizeCount = 0;
 
 static void
 finalize_counter_finalize(JSContext *cx, JSObject *obj)
 {
     JS_ATOMIC_INCREMENT(&finalizeCount);
 }
 
 static JSClass FinalizeCounterClass = {
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -3581,17 +3581,17 @@ struct XPCJSContextInfo {
         suspendDepth(0)
     {}
     JSContext* cx;
 
     // Whether the frame chain was saved
     bool savedFrameChain;
 
     // Greater than 0 if a request was suspended.
-    jsrefcount suspendDepth;
+    unsigned suspendDepth;
 };
 
 class XPCJSContextStack
 {
 public:
     XPCJSContextStack()
       : mSafeJSContext(NULL)
       , mOwnSafeJSContext(NULL)