Bug 855145 - DeMACROize the JS tracing interfaces; r=billm,mccr8

--HG--
extra : rebase_source : 915c80052b4412f653033eb5fc4d4f96c5d49bd5
This commit is contained in:
Terrence Cole 2013-03-26 15:10:34 -07:00
Родитель c9195167a5
Коммит 1ffd59927b
24 изменённых файлов: 117 добавлений и 129 удалений

Просмотреть файл

@ -420,7 +420,7 @@ TraceActiveWindowGlobal(const uint64_t& aId, nsGlobalWindow*& aWindow, void* aCl
if (aWindow->GetDocShell() && aWindow->IsOuterWindow()) {
TraceClosure* closure = static_cast<TraceClosure*>(aClosure);
if (JSObject* global = aWindow->FastGetGlobalJSObject()) {
JS_CALL_OBJECT_TRACER(closure->mTrc, global, "active window global");
JS_CallObjectTracer(closure->mTrc, global, "active window global");
}
#ifdef MOZ_XUL
nsIDocument* doc = aWindow->GetExtantDoc();

Просмотреть файл

@ -1693,7 +1693,7 @@ nsContentUtils::TraceSafeJSContext(JSTracer* aTrc)
return;
}
if (JSObject* global = JS_GetGlobalObject(cx)) {
JS_CALL_OBJECT_TRACER(aTrc, global, "safe context");
JS_CallObjectTracer(aTrc, global, "safe context");
}
}

Просмотреть файл

@ -2345,7 +2345,7 @@ nsXULPrototypeElement::TraceAllScripts(JSTracer* aTrc)
} else if (child->mType == nsXULPrototypeNode::eType_Script) {
JSScript* script = static_cast<nsXULPrototypeScript*>(child)->GetScriptObject();
if (script) {
JS_CALL_SCRIPT_TRACER(aTrc, script, "active window XUL prototype script");
JS_CallScriptTracer(aTrc, script, "active window XUL prototype script");
}
}
}

Просмотреть файл

@ -643,8 +643,8 @@ static PLDHashOperator
MarkScriptsInGC(nsIURI* aKey, CacheScriptEntry& aScriptEntry, void* aClosure)
{
JSTracer* trc = static_cast<JSTracer*>(aClosure);
JS_CALL_SCRIPT_TRACER(trc, aScriptEntry.mScriptObject,
"nsXULPrototypeCache script");
JS_CallScriptTracer(trc, aScriptEntry.mScriptObject,
"nsXULPrototypeCache script");
return PL_DHASH_NEXT;
}

Просмотреть файл

@ -273,7 +273,7 @@ TraceProtoAndIfaceCache(JSTracer* trc, JSObject* obj)
for (size_t i = 0; i < kProtoAndIfaceCacheCount; ++i) {
JSObject* proto = protoAndIfaceArray[i];
if (proto) {
JS_CALL_OBJECT_TRACER(trc, proto, "protoAndIfaceArray[i]");
JS_CallObjectTracer(trc, proto, "protoAndIfaceArray[i]");
}
}
}

Просмотреть файл

@ -2226,19 +2226,18 @@ NPObjectMember_Trace(JSTracer *trc, JSObject *obj)
// Our NPIdentifier is not always interned, so we must root it explicitly.
jsid id = NPIdentifierToJSId(memberPrivate->methodName);
if (JSID_IS_STRING(id))
JS_CALL_STRING_TRACER(trc, JSID_TO_STRING(id), "NPObjectMemberPrivate.methodName");
JS_CallIdTracer(trc, id, "NPObjectMemberPrivate.methodName");
if (!JSVAL_IS_PRIMITIVE(memberPrivate->fieldValue)) {
JS_CALL_VALUE_TRACER(trc, memberPrivate->fieldValue,
"NPObject Member => fieldValue");
JS_CallValueTracer(trc, memberPrivate->fieldValue,
"NPObject Member => fieldValue");
}
// There's no strong reference from our private data to the
// NPObject, so make sure to mark the NPObject wrapper to keep the
// NPObject alive as long as this NPObjectMember is alive.
if (memberPrivate->npobjWrapper) {
JS_CALL_OBJECT_TRACER(trc, memberPrivate->npobjWrapper,
"NPObject Member => npobjWrapper");
JS_CallObjectTracer(trc, memberPrivate->npobjWrapper,
"NPObject Member => npobjWrapper");
}
}

Просмотреть файл

@ -43,7 +43,7 @@ DOMBindingBase::_trace(JSTracer* aTrc)
{
JSObject* obj = GetJSObject();
if (obj) {
JS_CALL_OBJECT_TRACER(aTrc, obj, "cached wrapper");
JS_CallObjectTracer(aTrc, obj, "cached wrapper");
}
}

Просмотреть файл

@ -184,9 +184,9 @@ EventListenerManager::TraceInternal(JSTracer* aTrc) const
for (const ListenerData* listenerElem = collection->mListeners.getFirst();
listenerElem;
listenerElem = listenerElem->getNext()) {
JS_CALL_OBJECT_TRACER(aTrc,
listenerElem->mListener,
"EventListenerManager listener object");
JS_CallObjectTracer(aTrc,
listenerElem->mListener,
"EventListenerManager listener object");
}
}
}

Просмотреть файл

@ -3297,11 +3297,11 @@ WorkerPrivate::TraceInternal(JSTracer* aTrc)
for (uint32_t index = 0; index < mTimeouts.Length(); index++) {
TimeoutInfo* info = mTimeouts[index];
JS_CALL_VALUE_TRACER(aTrc, info->mTimeoutVal,
"WorkerPrivate timeout value");
JS_CallValueTracer(aTrc, info->mTimeoutVal,
"WorkerPrivate timeout value");
for (uint32_t index2 = 0; index2 < info->mExtraArgVals.Length(); index2++) {
JS_CALL_VALUE_TRACER(aTrc, info->mExtraArgVals[index2],
"WorkerPrivate timeout extra argument value");
JS_CallValueTracer(aTrc, info->mExtraArgVals[index2],
"WorkerPrivate timeout extra argument value");
}
}
}

Просмотреть файл

@ -128,7 +128,7 @@ protected:
_trace(JSTracer* aTrc) MOZ_OVERRIDE
{
for (int32_t i = 0; i < SLOT_COUNT; i++) {
JS_CALL_VALUE_TRACER(aTrc, mSlots[i], "WorkerGlobalScope instance slot");
JS_CallValueTracer(aTrc, mSlots[i], "WorkerGlobalScope instance slot");
}
mWorker->TraceInternal(aTrc);
EventTarget::_trace(aTrc);

Просмотреть файл

@ -1418,9 +1418,9 @@ void
XMLHttpRequest::_trace(JSTracer* aTrc)
{
if (mUpload) {
JS_CALL_OBJECT_TRACER(aTrc, mUpload->GetJSObject(), "mUpload");
JS_CallObjectTracer(aTrc, mUpload->GetJSObject(), "mUpload");
}
JS_CALL_VALUE_TRACER(aTrc, mStateData.mResponse, "mResponse");
JS_CallValueTracer(aTrc, mStateData.mResponse, "mResponse");
XMLHttpRequestEventTarget::_trace(aTrc);
}

Просмотреть файл

@ -23,7 +23,7 @@ void
XMLHttpRequestUpload::_trace(JSTracer* aTrc)
{
if (mXHR) {
JS_CALL_OBJECT_TRACER(aTrc, mXHR->GetJSObject(), "mXHR");
JS_CallObjectTracer(aTrc, mXHR->GetJSObject(), "mXHR");
}
XMLHttpRequestEventTarget::_trace(aTrc);
}

Просмотреть файл

@ -660,8 +660,6 @@ static const struct TraceKindPair {
static JSBool
CountHeap(JSContext *cx, unsigned argc, jsval *vp)
{
void* startThing;
JSGCTraceKind startTraceKind;
jsval v;
int32_t traceKind;
JSString *str;
@ -669,13 +667,11 @@ CountHeap(JSContext *cx, unsigned argc, jsval *vp)
JSCountHeapNode *node;
size_t counter;
startThing = NULL;
startTraceKind = JSTRACE_OBJECT;
Value startValue = UndefinedValue();
if (argc > 0) {
v = JS_ARGV(cx, vp)[0];
if (JSVAL_IS_TRACEABLE(v)) {
startThing = JSVAL_TO_TRACEABLE(v);
startTraceKind = JSVAL_TRACE_KIND(v);
startValue = v;
} else if (!JSVAL_IS_NULL(v)) {
JS_ReportError(cx,
"the first argument is not null or a heap-allocated "
@ -715,11 +711,10 @@ CountHeap(JSContext *cx, unsigned argc, jsval *vp)
countTracer.traceList = NULL;
countTracer.recycleList = NULL;
if (!startThing) {
if (startValue.isUndefined()) {
JS_TraceRuntime(&countTracer.base);
} else {
JS_SET_TRACING_NAME(&countTracer.base, "root");
JS_CallTracer(&countTracer.base, startThing, startTraceKind);
JS_CallValueTracer(&countTracer.base, startValue, "root");
}
counter = 0;

Просмотреть файл

@ -3320,8 +3320,8 @@ CType::Trace(JSTracer* trc, JSObject* obj)
FieldInfoHash* fields =
static_cast<FieldInfoHash*>(JSVAL_TO_PRIVATE(slot));
for (FieldInfoHash::Range r = fields->all(); !r.empty(); r.popFront()) {
JS_CALL_TRACER(trc, r.front().key, JSTRACE_STRING, "fieldName");
JS_CALL_TRACER(trc, r.front().value.mType, JSTRACE_OBJECT, "fieldType");
JS_CallStringTracer(trc, r.front().key, "fieldName");
JS_CallObjectTracer(trc, r.front().value.mType, "fieldType");
}
break;
@ -3336,10 +3336,10 @@ CType::Trace(JSTracer* trc, JSObject* obj)
JS_ASSERT(fninfo);
// Identify our objects to the tracer.
JS_CALL_TRACER(trc, fninfo->mABI, JSTRACE_OBJECT, "abi");
JS_CALL_TRACER(trc, fninfo->mReturnType, JSTRACE_OBJECT, "returnType");
JS_CallObjectTracer(trc, fninfo->mABI, "abi");
JS_CallObjectTracer(trc, fninfo->mReturnType, "returnType");
for (size_t i = 0; i < fninfo->mArgTypes.length(); ++i)
JS_CALL_TRACER(trc, fninfo->mArgTypes[i], JSTRACE_OBJECT, "argType");
JS_CallObjectTracer(trc, fninfo->mArgTypes[i], "argType");
break;
}
@ -6078,10 +6078,10 @@ CClosure::Trace(JSTracer* trc, JSObject* obj)
// Identify our objects to the tracer. (There's no need to identify
// 'closureObj', since that's us.)
JS_CALL_OBJECT_TRACER(trc, cinfo->typeObj, "typeObj");
JS_CALL_OBJECT_TRACER(trc, cinfo->jsfnObj, "jsfnObj");
JS_CallObjectTracer(trc, cinfo->typeObj, "typeObj");
JS_CallObjectTracer(trc, cinfo->jsfnObj, "jsfnObj");
if (cinfo->thisObj)
JS_CALL_OBJECT_TRACER(trc, cinfo->thisObj, "thisObj");
JS_CallObjectTracer(trc, cinfo->thisObj, "thisObj");
}
void

Просмотреть файл

@ -1487,15 +1487,6 @@ js::TraceChildren(JSTracer *trc, void *thing, JSGCTraceKind kind)
}
}
void
js::CallTracer(JSTracer *trc, void *thing, JSGCTraceKind kind)
{
JS_ASSERT(thing);
void *tmp = thing;
MarkKind(trc, &tmp, kind);
JS_ASSERT(tmp == thing);
}
static void
UnmarkGrayGCThing(void *thing)
{

Просмотреть файл

@ -386,9 +386,6 @@ TraceKind(JSScript *script)
void
TraceChildren(JSTracer *trc, void *thing, JSGCTraceKind kind);
void
CallTracer(JSTracer *trc, void *thing, JSGCTraceKind kind);
} /* namespace js */
#endif /* gc_marking_h___ */

Просмотреть файл

@ -2449,6 +2449,56 @@ JS_SetExtraGCRootsTracer(JSRuntime *rt, JSTraceDataOp traceOp, void *data)
rt->gcBlackRootsData = data;
}
JS_PUBLIC_API(void)
JS_CallValueTracer(JSTracer *trc, Value valueArg, const char *name)
{
Value value = valueArg;
MarkValueUnbarriered(trc, &value, name);
JS_ASSERT(value == valueArg);
}
JS_PUBLIC_API(void)
JS_CallIdTracer(JSTracer *trc, jsid idArg, const char *name)
{
jsid id = idArg;
MarkIdUnbarriered(trc, &id, name);
JS_ASSERT(id == idArg);
}
JS_PUBLIC_API(void)
JS_CallObjectTracer(JSTracer *trc, JSObject *objArg, const char *name)
{
JSObject *obj = objArg;
MarkObjectUnbarriered(trc, &obj, name);
JS_ASSERT(obj == objArg);
}
JS_PUBLIC_API(void)
JS_CallStringTracer(JSTracer *trc, JSString *strArg, const char *name)
{
JSString *str = strArg;
MarkStringUnbarriered(trc, &str, name);
JS_ASSERT(str == strArg);
}
JS_PUBLIC_API(void)
JS_CallScriptTracer(JSTracer *trc, JSScript *scriptArg, const char *name)
{
JSScript *script = scriptArg;
MarkScriptUnbarriered(trc, &script, name);
JS_ASSERT(script == scriptArg);
}
JS_PUBLIC_API(void)
JS_CallGenericTracer(JSTracer *trc, void *gcthingArg, const char *name)
{
void *gcthing = gcthingArg;
JSGCTraceKind kind = gc::GetGCThingTraceKind(gcthing);
JS_SET_TRACING_NAME(trc, name);
MarkKind(trc, &gcthing, kind);
JS_ASSERT(gcthing == gcthingArg);
}
JS_PUBLIC_API(void)
JS_TracerInit(JSTracer *trc, JSRuntime *rt, JSTraceCallback callback)
{
@ -2468,12 +2518,6 @@ JS_TraceChildren(JSTracer *trc, void *thing, JSGCTraceKind kind)
js::TraceChildren(trc, thing, kind);
}
JS_PUBLIC_API(void)
JS_CallTracer(JSTracer *trc, void *thing, JSGCTraceKind kind)
{
js::CallTracer(trc, thing, kind);
}
JS_PUBLIC_API(void)
JS_GetTraceThingInfo(char *buf, size_t bufsize, JSTracer *trc, void *thing,
JSGCTraceKind kind, JSBool details)

Просмотреть файл

@ -949,11 +949,8 @@ typedef JSBool
/*
* Function type for trace operation of the class called to enumerate all
* traceable things reachable from obj's private data structure. For each such
* thing, a trace implementation must call
*
* JS_CallTracer(trc, thing, kind);
*
* or one of its convenience macros as described in jsapi.h.
* thing, a trace implementation must call one of the |JS_Call<Type>Tracer|
* variants on the thing.
*
* JSTraceOp implementation can assume that no other threads mutates object
* state. It must not change state of the object or corresponding native
@ -967,8 +964,8 @@ typedef void
(* JSTraceOp)(JSTracer *trc, JSRawObject obj);
/*
* DEBUG only callback that JSTraceOp implementation can provide to return
* a string describing the reference traced with JS_CallTracer.
* Callback that JSTraceOp implementation can provide to return a string
* describing the reference traced with JS_CallTracer.
*/
typedef void
(* JSTraceNamePrinter)(JSTracer *trc, char *buf, size_t bufsize);
@ -2489,15 +2486,6 @@ struct JSTracer {
#endif
};
/*
* The method to call on each reference to a traceable thing stored in a
* particular JSObject or other runtime structure. With DEBUG defined the
* caller before calling JS_CallTracer must initialize JSTracer fields
* describing the reference using the macros below.
*/
extern JS_PUBLIC_API(void)
JS_CallTracer(JSTracer *trc, void *thing, JSGCTraceKind kind);
/*
* Set debugging information about a reference to a traceable thing to prepare
* for the following call to JS_CallTracer.
@ -2562,48 +2550,23 @@ JS_CallTracer(JSTracer *trc, void *thing, JSGCTraceKind kind);
# define JS_SET_TRACING_NAME(trc, name) \
JS_SET_TRACING_DETAILS(trc, NULL, name, (size_t)-1)
/*
* Convenience macro to invoke JS_CallTracer using C string as the name for
* the reference to a traceable thing.
*/
# define JS_CALL_TRACER(trc, thing, kind, name) \
JS_BEGIN_MACRO \
JS_SET_TRACING_NAME(trc, name); \
JS_CallTracer((trc), (thing), (kind)); \
JS_END_MACRO
extern JS_PUBLIC_API(void)
JS_CallValueTracer(JSTracer *trc, JS::Value value, const char *name);
/*
* Convenience macros to invoke JS_CallTracer when jsval represents a
* reference to a traceable thing.
*/
#define JS_CALL_VALUE_TRACER(trc, val, name) \
JS_BEGIN_MACRO \
if (JSVAL_IS_TRACEABLE(val)) { \
JS_CALL_TRACER((trc), JSVAL_TO_GCTHING(val), \
JSVAL_TRACE_KIND(val), name); \
} \
JS_END_MACRO
extern JS_PUBLIC_API(void)
JS_CallIdTracer(JSTracer *trc, jsid id, const char *name);
#define JS_CALL_OBJECT_TRACER(trc, object, name) \
JS_BEGIN_MACRO \
JSObject *obj_ = (object); \
JS_ASSERT(obj_); \
JS_CALL_TRACER((trc), obj_, JSTRACE_OBJECT, name); \
JS_END_MACRO
extern JS_PUBLIC_API(void)
JS_CallObjectTracer(JSTracer *trc, JSObject *obj, const char *name);
#define JS_CALL_STRING_TRACER(trc, string, name) \
JS_BEGIN_MACRO \
JSString *str_ = (string); \
JS_ASSERT(str_); \
JS_CALL_TRACER((trc), str_, JSTRACE_STRING, name); \
JS_END_MACRO
extern JS_PUBLIC_API(void)
JS_CallStringTracer(JSTracer *trc, JSString *str, const char *name);
#define JS_CALL_SCRIPT_TRACER(trc, script, name) \
JS_BEGIN_MACRO \
JSScript *script_ = (script); \
JS_ASSERT(script_); \
JS_CALL_TRACER((trc), script_, JSTRACE_SCRIPT, name); \
JS_END_MACRO
extern JS_PUBLIC_API(void)
JS_CallScriptTracer(JSTracer *trc, JSScript *script, const char *name);
extern JS_PUBLIC_API(void)
JS_CallGenericTracer(JSTracer *trc, void *gcthing, const char *name);
/*
* API for JSTraceCallback implementations.

Просмотреть файл

@ -403,8 +403,7 @@ void XPCJSRuntime::TraceGrayJS(JSTracer* trc, void* data)
static void
TraceJSObject(void *aScriptThing, const char *name, void *aClosure)
{
JS_CALL_TRACER(static_cast<JSTracer*>(aClosure), aScriptThing,
js::GCThingTraceKind(aScriptThing), name);
JS_CallGenericTracer(static_cast<JSTracer*>(aClosure), aScriptThing, name);
}
static PLDHashOperator
@ -421,7 +420,7 @@ void XPCJSRuntime::TraceXPConnectRoots(JSTracer *trc)
while (JSContext *acx = JS_ContextIterator(GetJSRuntime(), &iter)) {
MOZ_ASSERT(js::HasUnrootedGlobal(acx));
if (JSObject *global = JS_GetGlobalObject(acx))
JS_CALL_OBJECT_TRACER(trc, global, "XPC global object");
JS_CallObjectTracer(trc, global, "XPC global object");
}
XPCAutoLock lock(mMapLock);

Просмотреть файл

@ -65,9 +65,9 @@ void XPCTraceableVariant::TraceJS(JSTracer* trc)
{
jsval val = GetJSValPreserveColor();
NS_ASSERTION(JSVAL_IS_TRACEABLE(val), "Must be traceable");
MOZ_ASSERT(JSVAL_IS_TRACEABLE(val));
JS_SET_TRACING_DETAILS(trc, GetTraceName, this, 0);
JS_CallTracer(trc, JSVAL_TO_TRACEABLE(val), JSVAL_TRACE_KIND(val));
JS_CallValueTracer(trc, val, "XPCTraceableVariant::mJSVal");
}
// static

Просмотреть файл

@ -214,7 +214,7 @@ nsXPCWrappedJS::TraceJS(JSTracer* trc)
{
NS_ASSERTION(mRefCnt >= 2 && IsValid(), "must be strongly referenced");
JS_SET_TRACING_DETAILS(trc, GetTraceName, this, 0);
JS_CallTracer(trc, GetJSObjectPreserveColor(), JSTRACE_OBJECT);
JS_CallObjectTracer(trc, GetJSObjectPreserveColor(), "nsXPCWrappedJS::mJSObj");
}
// static

Просмотреть файл

@ -3575,7 +3575,7 @@ void
XPCJSObjectHolder::TraceJS(JSTracer *trc)
{
JS_SET_TRACING_DETAILS(trc, GetTraceName, this, 0);
JS_CallTracer(trc, mJSObj, JSTRACE_OBJECT);
JS_CallObjectTracer(trc, mJSObj, "XPCJSObjectHolder::mJSObj");
}
// static

Просмотреть файл

@ -387,8 +387,8 @@ WrappedNativeJSGCThingTracer(JSDHashTable *table, JSDHashEntryHdr *hdr,
static PLDHashOperator
TraceDOMExpandos(nsPtrHashKey<JSObject> *expando, void *aClosure)
{
JS_CALL_OBJECT_TRACER(static_cast<JSTracer *>(aClosure), expando->GetKey(),
"DOM expando object");
JS_CallObjectTracer(static_cast<JSTracer *>(aClosure), expando->GetKey(),
"DOM expando object");
return PL_DHASH_NEXT;
}

Просмотреть файл

@ -1631,9 +1631,9 @@ public:
void TraceSelf(JSTracer *trc) {
JSObject *obj = GetGlobalJSObjectPreserveColor();
MOZ_ASSERT(obj);
JS_CALL_OBJECT_TRACER(trc, obj, "XPCWrappedNativeScope::mGlobalJSObject");
JS_CallObjectTracer(trc, obj, "XPCWrappedNativeScope::mGlobalJSObject");
if (mXBLScope)
JS_CALL_OBJECT_TRACER(trc, mXBLScope, "XPCWrappedNativeScope::mXBLScope");
JS_CallObjectTracer(trc, mXBLScope, "XPCWrappedNativeScope::mXBLScope");
}
static void
@ -2438,7 +2438,7 @@ public:
void TraceSelf(JSTracer *trc) {
if (mJSProtoObject)
JS_CALL_OBJECT_TRACER(trc, mJSProtoObject, "XPCWrappedNativeProto::mJSProtoObject");
JS_CallObjectTracer(trc, mJSProtoObject, "XPCWrappedNativeProto::mJSProtoObject");
}
void TraceInside(JSTracer *trc) {
@ -2837,7 +2837,7 @@ public:
GetScope()->TraceSelf(trc);
JSObject* wrapper = GetWrapperPreserveColor();
if (wrapper)
JS_CALL_OBJECT_TRACER(trc, wrapper, "XPCWrappedNative::mWrapper");
JS_CallObjectTracer(trc, wrapper, "XPCWrappedNative::mWrapper");
if (mFlatJSObject && mFlatJSObject != INVALID_OBJECT &&
JS_IsGlobalObject(mFlatJSObject))
{
@ -2856,8 +2856,8 @@ public:
// normally somebody else is doing that. Be careful not to trace the
// bogus INVALID_OBJECT value we can have during init, though.
if (mFlatJSObject && mFlatJSObject != INVALID_OBJECT) {
JS_CALL_OBJECT_TRACER(trc, mFlatJSObject,
"XPCWrappedNative::mFlatJSObject");
JS_CallObjectTracer(trc, mFlatJSObject,
"XPCWrappedNative::mFlatJSObject");
}
}
@ -3893,7 +3893,7 @@ public:
void Mark() {}
void TraceJS(JSTracer* trc)
{
JS_CALL_VALUE_TRACER(trc, *mValPtr, "XPCMarkableJSVal");
JS_CallValueTracer(trc, *mValPtr, "XPCMarkableJSVal");
}
void AutoTrace(JSTracer* trc) {}
private: