зеркало из https://github.com/mozilla/gecko-dev.git
Remove all remnants of JSTempValueRooter. WIN!
This commit is contained in:
Родитель
ff2fe48d4b
Коммит
6090792c57
232
js/src/jscntxt.h
232
js/src/jscntxt.h
|
@ -1165,96 +1165,6 @@ typedef struct JSResolvingEntry {
|
|||
#define JSRESFLAG_WATCH 0x2 /* resolving id from watch */
|
||||
#define JSRESOLVE_INFER 0xffff /* infer bits from current bytecode */
|
||||
|
||||
/*
|
||||
* Macros to push/pop JSTempValueRooter instances to context-linked stack of
|
||||
* temporary GC roots. If you need to protect a result value that flows out of
|
||||
* a C function across several layers of other functions, use the
|
||||
* js_LeaveLocalRootScopeWithResult internal API (see further below) instead.
|
||||
*
|
||||
* The macros also provide a simple way to get a single rooted pointer via
|
||||
* JS_PUSH_TEMP_ROOT_<KIND>(cx, NULL, &tvr). Then &tvr.u.<kind> gives the
|
||||
* necessary pointer.
|
||||
*
|
||||
* JSTempValueRooter.count defines the type of the rooted value referenced by
|
||||
* JSTempValueRooter.u union of type JSTempValueUnion. When count is positive
|
||||
* or zero, u.array points to a vector of jsvals. Otherwise it must be one of
|
||||
* the following constants:
|
||||
*/
|
||||
#define JSTVU_SINGLE (-1) /* u.value or u.<gcthing> is single jsval
|
||||
or non-JSString GC-thing pointer */
|
||||
#define JSTVU_TRACE (-2) /* u.trace is a hook to trace a custom
|
||||
* structure */
|
||||
#define JSTVU_SPROP (-3) /* u.sprop roots property tree node */
|
||||
#define JSTVU_WEAK_ROOTS (-4) /* u.weakRoots points to saved weak roots */
|
||||
#define JSTVU_COMPILER (-5) /* u.compiler roots JSCompiler* */
|
||||
#define JSTVU_SCRIPT (-6) /* u.script roots JSScript* */
|
||||
#define JSTVU_ENUMERATOR (-7) /* a pointer to JSTempValueRooter points
|
||||
to an instance of JSAutoEnumStateRooter
|
||||
with u.object storing the enumeration
|
||||
object */
|
||||
|
||||
/*
|
||||
* Here single JSTVU_SINGLE covers both jsval and pointers to almost (see note
|
||||
* below) any GC-thing via reinterpreting the thing as JSVAL_OBJECT. This works
|
||||
* because the GC-thing is aligned on a 0 mod 8 boundary, and object has the 0
|
||||
* jsval tag. So any GC-heap-allocated thing pointer may be tagged as if it
|
||||
* were an object and untagged, if it's then used only as an opaque pointer
|
||||
* until discriminated by other means than tag bits. This is how, for example,
|
||||
* js_GetGCThingTraceKind uses its |thing| parameter -- it consults GC-thing
|
||||
* flags stored separately from the thing to decide the kind of thing.
|
||||
*
|
||||
* Note well that JSStrings may be statically allocated (see the intStringTable
|
||||
* and unitStringTable static arrays), so this hack does not work for arbitrary
|
||||
* GC-thing pointers.
|
||||
*/
|
||||
#define JS_PUSH_TEMP_ROOT_COMMON(cx,x,tvr,cnt,kind) \
|
||||
JS_BEGIN_MACRO \
|
||||
JS_ASSERT((cx)->tempValueRooters != (tvr)); \
|
||||
(tvr)->count = (cnt); \
|
||||
(tvr)->u.kind = (x); \
|
||||
(tvr)->down = (cx)->tempValueRooters; \
|
||||
(cx)->tempValueRooters = (tvr); \
|
||||
JS_END_MACRO
|
||||
|
||||
#define JS_POP_TEMP_ROOT(cx,tvr) \
|
||||
JS_BEGIN_MACRO \
|
||||
JS_ASSERT((cx)->tempValueRooters == (tvr)); \
|
||||
(cx)->tempValueRooters = (tvr)->down; \
|
||||
JS_END_MACRO
|
||||
|
||||
#define JS_PUSH_TEMP_ROOT(cx,cnt,arr,tvr) \
|
||||
JS_BEGIN_MACRO \
|
||||
JS_ASSERT((int)(cnt) >= 0); \
|
||||
JS_PUSH_TEMP_ROOT_COMMON(cx, arr, tvr, (ptrdiff_t) (cnt), array); \
|
||||
JS_END_MACRO
|
||||
|
||||
#define JS_PUSH_SINGLE_TEMP_ROOT(cx,val,tvr) \
|
||||
JS_PUSH_TEMP_ROOT_COMMON(cx, val, tvr, JSTVU_SINGLE, value)
|
||||
|
||||
#define JS_PUSH_TEMP_ROOT_OBJECT(cx,obj,tvr) \
|
||||
JS_PUSH_TEMP_ROOT_COMMON(cx, obj, tvr, JSTVU_SINGLE, object)
|
||||
|
||||
#define JS_PUSH_TEMP_ROOT_STRING(cx,str,tvr) \
|
||||
JS_PUSH_SINGLE_TEMP_ROOT(cx, str ? STRING_TO_JSVAL(str) : JSVAL_NULL, tvr)
|
||||
|
||||
#define JS_PUSH_TEMP_ROOT_XML(cx,xml_,tvr) \
|
||||
JS_PUSH_TEMP_ROOT_COMMON(cx, xml_, tvr, JSTVU_SINGLE, xml)
|
||||
|
||||
#define JS_PUSH_TEMP_ROOT_TRACE(cx,trace_,tvr) \
|
||||
JS_PUSH_TEMP_ROOT_COMMON(cx, trace_, tvr, JSTVU_TRACE, trace)
|
||||
|
||||
#define JS_PUSH_TEMP_ROOT_SPROP(cx,sprop_,tvr) \
|
||||
JS_PUSH_TEMP_ROOT_COMMON(cx, sprop_, tvr, JSTVU_SPROP, sprop)
|
||||
|
||||
#define JS_PUSH_TEMP_ROOT_WEAK_COPY(cx,weakRoots_,tvr) \
|
||||
JS_PUSH_TEMP_ROOT_COMMON(cx, weakRoots_, tvr, JSTVU_WEAK_ROOTS, weakRoots)
|
||||
|
||||
#define JS_PUSH_TEMP_ROOT_COMPILER(cx,pc,tvr) \
|
||||
JS_PUSH_TEMP_ROOT_COMMON(cx, pc, tvr, JSTVU_COMPILER, compiler)
|
||||
|
||||
#define JS_PUSH_TEMP_ROOT_SCRIPT(cx,script_,tvr) \
|
||||
JS_PUSH_TEMP_ROOT_COMMON(cx, script_, tvr, JSTVU_SCRIPT, script)
|
||||
|
||||
extern const JSDebugHooks js_NullDebugHooks; /* defined in jsdbgapi.cpp */
|
||||
|
||||
/*
|
||||
|
@ -1477,9 +1387,6 @@ struct JSContext
|
|||
/* PDL of stack headers describing stack slots not rooted by argv, etc. */
|
||||
JSStackHeader *stackHeaders;
|
||||
|
||||
/* Stack of thread-stack-allocated temporary GC roots. */
|
||||
JSTempValueRooter *tempValueRooters;
|
||||
|
||||
/* Stack of thread-stack-allocated GC roots. */
|
||||
js::AutoGCRooter *autoGCRooters;
|
||||
|
||||
|
@ -2058,145 +1965,6 @@ class AutoXMLRooter : private AutoGCRooter {
|
|||
|
||||
} /* namespace js */
|
||||
|
||||
/* FIXME(bug 332648): Move this into a public header. */
|
||||
class JSAutoTempValueRooter
|
||||
{
|
||||
public:
|
||||
JSAutoTempValueRooter(JSContext *cx, size_t len, jsval *vec
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mContext(cx) {
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
JS_PUSH_TEMP_ROOT(mContext, len, vec, &mTvr);
|
||||
}
|
||||
explicit JSAutoTempValueRooter(JSContext *cx, jsval v = JSVAL_NULL
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mContext(cx) {
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
JS_PUSH_SINGLE_TEMP_ROOT(mContext, v, &mTvr);
|
||||
}
|
||||
JSAutoTempValueRooter(JSContext *cx, JSString *str
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mContext(cx) {
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
JS_PUSH_TEMP_ROOT_STRING(mContext, str, &mTvr);
|
||||
}
|
||||
JSAutoTempValueRooter(JSContext *cx, JSObject *obj
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mContext(cx) {
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
JS_PUSH_TEMP_ROOT_OBJECT(mContext, obj, &mTvr);
|
||||
}
|
||||
JSAutoTempValueRooter(JSContext *cx, JSScopeProperty *sprop
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mContext(cx) {
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
JS_PUSH_TEMP_ROOT_SPROP(mContext, sprop, &mTvr);
|
||||
}
|
||||
|
||||
~JSAutoTempValueRooter() {
|
||||
JS_POP_TEMP_ROOT(mContext, &mTvr);
|
||||
}
|
||||
|
||||
jsval value() { return mTvr.u.value; }
|
||||
jsval *addr() { return &mTvr.u.value; }
|
||||
|
||||
protected:
|
||||
JSContext *mContext;
|
||||
|
||||
private:
|
||||
JSTempValueRooter mTvr;
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class JSAutoTempIdRooter
|
||||
{
|
||||
public:
|
||||
explicit JSAutoTempIdRooter(JSContext *cx, jsid id = INT_TO_JSID(0)
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mContext(cx) {
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
JS_PUSH_SINGLE_TEMP_ROOT(mContext, ID_TO_VALUE(id), &mTvr);
|
||||
}
|
||||
|
||||
~JSAutoTempIdRooter() {
|
||||
JS_POP_TEMP_ROOT(mContext, &mTvr);
|
||||
}
|
||||
|
||||
jsid id() { return (jsid) mTvr.u.value; }
|
||||
jsid * addr() { return (jsid *) &mTvr.u.value; }
|
||||
|
||||
private:
|
||||
JSContext *mContext;
|
||||
JSTempValueRooter mTvr;
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class JSAutoIdArray {
|
||||
public:
|
||||
JSAutoIdArray(JSContext *cx, JSIdArray *ida
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: cx(cx), idArray(ida) {
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
if (ida)
|
||||
JS_PUSH_TEMP_ROOT(cx, ida->length, ida->vector, &tvr);
|
||||
}
|
||||
~JSAutoIdArray() {
|
||||
if (idArray) {
|
||||
JS_POP_TEMP_ROOT(cx, &tvr);
|
||||
JS_DestroyIdArray(cx, idArray);
|
||||
}
|
||||
}
|
||||
bool operator!() {
|
||||
return idArray == NULL;
|
||||
}
|
||||
jsid operator[](size_t i) const {
|
||||
JS_ASSERT(idArray);
|
||||
JS_ASSERT(i < size_t(idArray->length));
|
||||
return idArray->vector[i];
|
||||
}
|
||||
size_t length() const {
|
||||
return idArray->length;
|
||||
}
|
||||
private:
|
||||
JSContext * const cx;
|
||||
JSIdArray * const idArray;
|
||||
JSTempValueRooter tvr;
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
|
||||
/* No copy or assignment semantics. */
|
||||
JSAutoIdArray(JSAutoIdArray &);
|
||||
void operator=(JSAutoIdArray &);
|
||||
};
|
||||
|
||||
/* The auto-root for enumeration object and its state. */
|
||||
class JSAutoEnumStateRooter : public JSTempValueRooter
|
||||
{
|
||||
public:
|
||||
JSAutoEnumStateRooter(JSContext *cx, JSObject *obj, jsval *statep
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mContext(cx), mStatep(statep)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
JS_ASSERT(obj);
|
||||
JS_ASSERT(statep);
|
||||
JS_PUSH_TEMP_ROOT_COMMON(cx, obj, this, JSTVU_ENUMERATOR, object);
|
||||
}
|
||||
|
||||
~JSAutoEnumStateRooter() {
|
||||
JS_POP_TEMP_ROOT(mContext, this);
|
||||
}
|
||||
|
||||
void mark(JSTracer *trc) {
|
||||
JS_CALL_OBJECT_TRACER(trc, u.object, "enumerator_obj");
|
||||
js_MarkEnumeratorState(trc, u.object, *mStatep);
|
||||
}
|
||||
|
||||
private:
|
||||
JSContext *mContext;
|
||||
jsval *mStatep;
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class JSAutoResolveFlags
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -110,14 +110,6 @@
|
|||
|
||||
using namespace js;
|
||||
|
||||
/*
|
||||
* Check JSTempValueUnion has the size of jsval and void * so we can
|
||||
* reinterpret jsval as void* GC-thing pointer and use JSTVU_SINGLE for
|
||||
* different GC-things.
|
||||
*/
|
||||
JS_STATIC_ASSERT(sizeof(JSTempValueUnion) == sizeof(jsval));
|
||||
JS_STATIC_ASSERT(sizeof(JSTempValueUnion) == sizeof(void *));
|
||||
|
||||
/*
|
||||
* Check that JSTRACE_XML follows JSTRACE_OBJECT, JSTRACE_DOUBLE and
|
||||
* JSTRACE_STRING.
|
||||
|
@ -2441,36 +2433,6 @@ js_TraceContext(JSTracer *trc, JSContext *acx)
|
|||
TraceValues(trc, sh->nslots, JS_STACK_SEGMENT(sh), "stack");
|
||||
}
|
||||
|
||||
for (JSTempValueRooter *tvr = acx->tempValueRooters; tvr; tvr = tvr->down) {
|
||||
switch (tvr->count) {
|
||||
case JSTVU_SINGLE:
|
||||
JS_SET_TRACING_NAME(trc, "tvr->u.value");
|
||||
js_CallValueTracerIfGCThing(trc, tvr->u.value);
|
||||
break;
|
||||
case JSTVU_TRACE:
|
||||
tvr->u.trace(trc, tvr);
|
||||
break;
|
||||
case JSTVU_SPROP:
|
||||
tvr->u.sprop->trace(trc);
|
||||
break;
|
||||
case JSTVU_WEAK_ROOTS:
|
||||
tvr->u.weakRoots->mark(trc);
|
||||
break;
|
||||
case JSTVU_COMPILER:
|
||||
tvr->u.compiler->trace(trc);
|
||||
break;
|
||||
case JSTVU_SCRIPT:
|
||||
js_TraceScript(trc, tvr->u.script);
|
||||
break;
|
||||
case JSTVU_ENUMERATOR:
|
||||
static_cast<JSAutoEnumStateRooter *>(tvr)->mark(trc);
|
||||
break;
|
||||
default:
|
||||
JS_ASSERT(tvr->count >= 0);
|
||||
TraceValues(trc, tvr->count, tvr->u.array, "tvr->u.array");
|
||||
}
|
||||
}
|
||||
|
||||
for (js::AutoGCRooter *gcr = acx->autoGCRooters; gcr; gcr = gcr->down)
|
||||
gcr->trace(trc);
|
||||
|
||||
|
|
|
@ -101,7 +101,6 @@ typedef struct JSParseNode JSParseNode;
|
|||
typedef struct JSProperty JSProperty;
|
||||
typedef struct JSSharpObjectMap JSSharpObjectMap;
|
||||
typedef struct JSEmptyScope JSEmptyScope;
|
||||
typedef struct JSTempValueRooter JSTempValueRooter;
|
||||
typedef struct JSThread JSThread;
|
||||
typedef struct JSThreadData JSThreadData;
|
||||
typedef struct JSTreeContext JSTreeContext;
|
||||
|
@ -285,31 +284,6 @@ typedef struct JSDebugHooks {
|
|||
void *debugErrorHookData;
|
||||
} JSDebugHooks;
|
||||
|
||||
/*
|
||||
* Type definitions for temporary GC roots that register with GC local C
|
||||
* variables. See jscntxt.h for details.
|
||||
*/
|
||||
typedef void
|
||||
(* JSTempValueTrace)(JSTracer *trc, JSTempValueRooter *tvr);
|
||||
|
||||
typedef union JSTempValueUnion {
|
||||
jsval value;
|
||||
JSObject *object;
|
||||
JSXML *xml;
|
||||
JSTempValueTrace trace;
|
||||
JSScopeProperty *sprop;
|
||||
JSWeakRoots *weakRoots;
|
||||
JSCompiler *compiler;
|
||||
JSScript *script;
|
||||
jsval *array;
|
||||
} JSTempValueUnion;
|
||||
|
||||
struct JSTempValueRooter {
|
||||
JSTempValueRooter *down;
|
||||
ptrdiff_t count;
|
||||
JSTempValueUnion u;
|
||||
};
|
||||
|
||||
/* JSObjectOps function pointer typedefs. */
|
||||
|
||||
/*
|
||||
|
|
Загрузка…
Ссылка в новой задаче