Fix non-threadsafe builds, no bug. r=jorendorff
authorBrian Hackett <bhackett1024@gmail.com>
Wed, 11 Jan 2012 07:45:55 -0800
changeset 85513 e41a37df38928a7ddb548466bd9747f7e1fbda89
parent 85512 103460516db6451789c70480e60c1c167e44b046
child 85514 418f713f7092d824aac7798069886318c1a92259
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
milestone12.0a1
Fix non-threadsafe builds, no bug. r=jorendorff
js/public/MemoryMetrics.h
js/src/MemoryMetrics.cpp
js/src/jslock.h
--- a/js/public/MemoryMetrics.h
+++ b/js/public/MemoryMetrics.h
@@ -178,23 +178,27 @@ struct IterateData
     js::Vector<CompartmentStats, 0, js::SystemAllocPolicy> compartmentStatsVector;
     CompartmentStats *currCompartmentStats;
 
     JSMallocSizeOfFun mallocSizeOf;
     GetNameCallback getNameCb;
     DestroyNameCallback destroyNameCb;
 };
 
+#ifdef JS_THREADSAFE
+
 extern JS_PUBLIC_API(bool)
 CollectCompartmentStatsForRuntime(JSRuntime *rt, IterateData *data);
 
 extern JS_PUBLIC_API(bool)
 GetExplicitNonHeapForRuntime(JSRuntime *rt, int64_t *amount,
                              JSMallocSizeOfFun mallocSizeOf);
 
+#endif /* JS_THREADSAFE */
+
 extern JS_PUBLIC_API(void)
 SizeOfCompartmentTypeInferenceData(JSContext *cx, JSCompartment *compartment,
                                    TypeInferenceMemoryStats *stats,
                                    JSMallocSizeOfFun mallocSizeOf);
 
 extern JS_PUBLIC_API(void)
 SizeOfObjectTypeInferenceData(/*TypeObject*/ void *object,
                               TypeInferenceMemoryStats *stats,
--- a/js/src/MemoryMetrics.cpp
+++ b/js/src/MemoryMetrics.cpp
@@ -43,16 +43,18 @@
 #include "jscompartment.h"
 #include "jsgc.h"
 #include "jsobj.h"
 #include "jsscope.h"
 #include "jsscript.h"
 
 #include "jsobjinlines.h"
 
+#ifdef JS_THREADSAFE
+
 namespace JS {
 
 using namespace js;
 
 static void
 CompartmentMemoryCallback(JSContext *cx, void *vdata, JSCompartment *compartment)
 {
     // Append a new CompartmentStats to the vector.
@@ -218,20 +220,16 @@ CollectCompartmentStatsForRuntime(JSRunt
         data->runtimeObject = data->mallocSizeOf(rt, sizeof(JSRuntime));
 
         // Nb: we use sizeOfExcludingThis() because atomState.atoms is within
         // JSRuntime, and so counted when JSRuntime is counted.
         data->runtimeAtomsTable =
             rt->atomState.atoms.sizeOfExcludingThis(data->mallocSizeOf);
 
         {
-#ifndef JS_THREADSAFE
-#error "This code assumes JS_THREADSAFE is defined"
-#endif
-
             // Need the GC lock to call JS_ContextIteratorUnlocked() and to
             // access rt->threads.
             AutoLockGC lock(rt);
 
             JSContext *acx, *iter = NULL;
             while ((acx = JS_ContextIteratorUnlocked(rt, &iter)) != NULL) {
                 data->runtimeContexts +=
                     acx->sizeOfIncludingThis(data->mallocSizeOf);
@@ -344,20 +342,16 @@ GetExplicitNonHeapForRuntime(JSRuntime *
         JSAutoRequest ar(cx);
 
         // explicit/<compartment>/mjit-code
         size_t n = 0;
         IterateCompartments(cx, &n, ExplicitNonHeapCompartmentCallback);
         *amount += n;
 
         {
-#ifndef JS_THREADSAFE
-#error "This code assumes JS_THREADSAFE is defined"
-#endif
-
             // Need the GC lock to call JS_ContextIteratorUnlocked() and to
             // access rt->threads.
             AutoLockGC lock(rt);
 
             // explicit/runtime/threads/regexp-code
             // explicit/runtime/threads/stack-committed
             for (JSThread::Map::Range r = rt->threads.all(); !r.empty(); r.popFront()) {
                 JSThread *thread = r.front().value;
@@ -375,8 +369,10 @@ GetExplicitNonHeapForRuntime(JSRuntime *
     }
 
     JS_DestroyContextNoGC(cx);
 
     return true;
 }
 
 } // namespace JS
+
+#endif // JS_THREADSAFE
--- a/js/src/jslock.h
+++ b/js/src/jslock.h
@@ -139,17 +139,17 @@ extern JSBool js_IsRuntimeLocked(JSRunti
 
 #else  /* !JS_THREADSAFE */
 
 #define JS_ATOMIC_INCREMENT(p)      (++*(p))
 #define JS_ATOMIC_DECREMENT(p)      (--*(p))
 #define JS_ATOMIC_ADD(p,v)          (*(p) += (v))
 #define JS_ATOMIC_SET(p,v)          (*(p) = (v))
 
-#define js_CurrentThreadId()        0
+#define js_CurrentThreadId()        ((void*)NULL)
 #define JS_NEW_LOCK()               NULL
 #define JS_DESTROY_LOCK(l)          ((void)0)
 #define JS_ACQUIRE_LOCK(l)          ((void)0)
 #define JS_RELEASE_LOCK(l)          ((void)0)
 #define JS_LOCK(cx, tl)             ((void)0)
 #define JS_UNLOCK(cx, tl)           ((void)0)
 
 #define JS_NEW_CONDVAR(l)           NULL