Bug 332648 - Part h: Move AutoEnumStateArray to jsapi.h; r=evilpie

This commit is contained in:
Ms2ger 2012-01-11 09:23:09 +01:00
parent 27ed38a4d4
commit 42d0f74e76
5 changed files with 40 additions and 44 deletions

View File

@ -87,6 +87,7 @@
#include "frontend/BytecodeCompiler.h" #include "frontend/BytecodeCompiler.h"
#include "frontend/BytecodeEmitter.h" #include "frontend/BytecodeEmitter.h"
#include "js/MemoryMetrics.h" #include "js/MemoryMetrics.h"
#include "mozilla/Util.h" // DebugOnly
#include "jsatominlines.h" #include "jsatominlines.h"
#include "jsinferinlines.h" #include "jsinferinlines.h"
@ -6873,4 +6874,13 @@ AutoGCRooter::~AutoGCRooter()
context->autoGCRooters = down; context->autoGCRooters = down;
} }
AutoEnumStateRooter::~AutoEnumStateRooter()
{
if (!stateValue.isNull()) {
DebugOnly<JSBool> ok =
obj->enumerate(context, JSENUMERATE_DESTROY, &stateValue, 0);
JS_ASSERT(ok);
}
}
} // namespace JS } // namespace JS

View File

@ -1003,6 +1003,35 @@ class AutoArrayRooter : private AutoGCRooter {
JS_DECL_USE_GUARD_OBJECT_NOTIFIER 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 */ } /* namespace JS */
/************************************************************************/ /************************************************************************/

View File

@ -1700,19 +1700,6 @@ JSContext::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const
busyArrays.sizeOfExcludingThis(mallocSizeOf); 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 { namespace JS {
#if defined JS_THREADSAFE && defined DEBUG #if defined JS_THREADSAFE && defined DEBUG

View File

@ -1597,36 +1597,6 @@ typedef RootedVar<JSAtom*> RootedVarAtom;
typedef RootedVar<jsid> RootedVarId; typedef RootedVar<jsid> RootedVarId;
typedef RootedVar<Value> RootedVarValue; 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 #ifdef JS_HAS_XML_SUPPORT
class AutoXMLRooter : private AutoGCRooter { class AutoXMLRooter : private AutoGCRooter {
public: public:

View File

@ -1942,7 +1942,7 @@ AutoIdArray::trace(JSTracer *trc)
void void
AutoEnumStateRooter::trace(JSTracer *trc) AutoEnumStateRooter::trace(JSTracer *trc)
{ {
gc::MarkRoot(trc, obj, "js::AutoEnumStateRooter.obj"); gc::MarkRoot(trc, obj, "JS::AutoEnumStateRooter.obj");
} }
inline void inline void