Bug 332648 - Part h: Move AutoEnumStateArray to jsapi.h; r=evilpie
authorMs2ger <ms2ger@gmail.com>
Wed, 11 Jan 2012 09:23:09 +0100
changeset 85401 4fc86339a424b5aff60d4d6603a3ed1ba5c5cf37
parent 85400 2140f9cb5d6a7bbe8218888564f32cda7d58c32b
child 85402 c42d08fdec34547f8302ca6d04f9fe8ea471eaa2
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)
reviewersevilpie
bugs332648
milestone12.0a1
Bug 332648 - Part h: Move AutoEnumStateArray to jsapi.h; r=evilpie
js/src/jsapi.cpp
js/src/jsapi.h
js/src/jscntxt.cpp
js/src/jscntxt.h
js/src/jsgc.cpp
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -82,16 +82,17 @@
 #include "jswrapper.h"
 #include "jstypedarray.h"
 
 #include "ds/LifoAlloc.h"
 #include "builtin/RegExp.h"
 #include "frontend/BytecodeCompiler.h"
 #include "frontend/BytecodeEmitter.h"
 #include "js/MemoryMetrics.h"
+#include "mozilla/Util.h" // DebugOnly
 
 #include "jsatominlines.h"
 #include "jsinferinlines.h"
 #include "jsobjinlines.h"
 #include "jsscopeinlines.h"
 #include "jsscriptinlines.h"
 
 #include "vm/RegExpObject-inl.h"
@@ -6868,9 +6869,18 @@ AutoGCRooter::AutoGCRooter(JSContext *cx
 
 AutoGCRooter::~AutoGCRooter()
 {
     JS_ASSERT(this == context->autoGCRooters);
     CHECK_REQUEST(context);
     context->autoGCRooters = down;
 }
 
+AutoEnumStateRooter::~AutoEnumStateRooter()
+{
+    if (!stateValue.isNull()) {
+        DebugOnly<JSBool> ok =
+            obj->enumerate(context, JSENUMERATE_DESTROY, &stateValue, 0);
+        JS_ASSERT(ok);
+    }
+}
+
 } // namespace JS
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -998,16 +998,45 @@ class AutoArrayRooter : private AutoGCRo
     Value *array;
 
     friend void AutoGCRooter::trace(JSTracer *trc);
 
   private:
     JS_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
+/* The auto-root for enumeration object and its state. */
+class AutoEnumStateRooter : private AutoGCRooter
+{
+  public:
+    AutoEnumStateRooter(JSContext *cx, JSObject *obj
+                        JS_GUARD_OBJECT_NOTIFIER_PARAM)
+      : AutoGCRooter(cx, ENUMERATOR), obj(obj), stateValue()
+    {
+        JS_GUARD_OBJECT_NOTIFIER_INIT;
+        JS_ASSERT(obj);
+    }
+
+    ~AutoEnumStateRooter();
+
+    friend void AutoGCRooter::trace(JSTracer *trc);
+
+    const Value &state() const { return stateValue; }
+    Value *addr() { return &stateValue; }
+
+  protected:
+    void trace(JSTracer *trc);
+
+    JSObject * const obj;
+
+  private:
+    Value stateValue;
+    JS_DECL_USE_GUARD_OBJECT_NOTIFIER
+};
+
 }  /* namespace JS */
 
 /************************************************************************/
 
 /*
  * JS::Value and jsval are the same type; jsval is the old name, kept around
  * for backwards compatibility along with all the JSVAL_* operations below.
  * jsval_layout is an implementation detail and should not be used externally.
--- a/js/src/jscntxt.cpp
+++ b/js/src/jscntxt.cpp
@@ -1695,29 +1695,16 @@ JSContext::sizeOfIncludingThis(JSMallocS
      * There are other JSContext members that could be measured; the following
      * ones have been found by DMD to be worth measuring.  More stuff may be
      * added later.
      */
     return mallocSizeOf(this, sizeof(JSContext)) +
            busyArrays.sizeOfExcludingThis(mallocSizeOf);
 }
 
-namespace js {
-
-AutoEnumStateRooter::~AutoEnumStateRooter()
-{
-    if (!stateValue.isNull()) {
-        DebugOnly<JSBool> ok =
-            obj->enumerate(context, JSENUMERATE_DESTROY, &stateValue, 0);
-        JS_ASSERT(ok);
-    }
-}
-
-} /* namespace js */
-
 namespace JS {
 
 #if defined JS_THREADSAFE && defined DEBUG
 
 AutoCheckRequestDepth::AutoCheckRequestDepth(JSContext *cx)
     : cx(cx)
 {
     JS_ASSERT(cx->thread());
--- a/js/src/jscntxt.h
+++ b/js/src/jscntxt.h
@@ -1592,46 +1592,16 @@ typedef RootedVar<JSFunction*>        Ro
 typedef RootedVar<Shape*>             RootedVarShape;
 typedef RootedVar<BaseShape*>         RootedVarBaseShape;
 typedef RootedVar<types::TypeObject*> RootedVarTypeObject;
 typedef RootedVar<JSString*>          RootedVarString;
 typedef RootedVar<JSAtom*>            RootedVarAtom;
 typedef RootedVar<jsid>               RootedVarId;
 typedef RootedVar<Value>              RootedVarValue;
 
-/* FIXME(bug 332648): Move this into a public header. */
-/* The auto-root for enumeration object and its state. */
-class AutoEnumStateRooter : private AutoGCRooter
-{
-  public:
-    AutoEnumStateRooter(JSContext *cx, JSObject *obj
-                        JS_GUARD_OBJECT_NOTIFIER_PARAM)
-      : AutoGCRooter(cx, ENUMERATOR), obj(obj), stateValue()
-    {
-        JS_GUARD_OBJECT_NOTIFIER_INIT;
-        JS_ASSERT(obj);
-    }
-
-    ~AutoEnumStateRooter();
-
-    friend void AutoGCRooter::trace(JSTracer *trc);
-
-    const Value &state() const { return stateValue; }
-    Value *addr() { return &stateValue; }
-
-  protected:
-    void trace(JSTracer *trc);
-
-    JSObject * const obj;
-
-  private:
-    Value stateValue;
-    JS_DECL_USE_GUARD_OBJECT_NOTIFIER
-};
-
 #ifdef JS_HAS_XML_SUPPORT
 class AutoXMLRooter : private AutoGCRooter {
   public:
     AutoXMLRooter(JSContext *cx, JSXML *xml
                   JS_GUARD_OBJECT_NOTIFIER_PARAM)
       : AutoGCRooter(cx, XML), xml(xml)
     {
         JS_GUARD_OBJECT_NOTIFIER_INIT;
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -1937,17 +1937,17 @@ AutoIdArray::trace(JSTracer *trc)
     JS_ASSERT(tag == IDARRAY);
     gc::MarkIdRange(trc, idArray->vector, idArray->vector + idArray->length,
                     "JSAutoIdArray.idArray");
 }
 
 void
 AutoEnumStateRooter::trace(JSTracer *trc)
 {
-    gc::MarkRoot(trc, obj, "js::AutoEnumStateRooter.obj");
+    gc::MarkRoot(trc, obj, "JS::AutoEnumStateRooter.obj");
 }
 
 inline void
 AutoGCRooter::trace(JSTracer *trc)
 {
     switch (tag) {
       case JSVAL:
         MarkRoot(trc, static_cast<AutoValueRooter *>(this)->val, "JS::AutoValueRooter.val");