From 4411f6fc39a3ff042e28c6c7d7887dd6f45c720a Mon Sep 17 00:00:00 2001 From: "igor@mir2.org" Date: Tue, 1 May 2007 14:54:29 -0700 Subject: [PATCH] Bug 377751: removal of the commit. --- dom/src/base/nsDOMClassInfo.cpp | 6 +- js/src/xpconnect/idl/nsIXPCScriptable.idl | 8 +- js/src/xpconnect/idl/nsIXPConnect.idl | 1 - js/src/xpconnect/public/xpc_map_end.h | 12 +-- js/src/xpconnect/src/XPCDispInlines.h | 2 +- .../xpconnect/src/XPCDispParamPropJSClass.cpp | 19 ++-- js/src/xpconnect/src/XPCDispPrivate.h | 20 ++-- js/src/xpconnect/src/XPCDispTypeInfo.cpp | 28 +++--- js/src/xpconnect/src/XPCNativeWrapper.cpp | 20 ++-- js/src/xpconnect/src/xpcjsruntime.cpp | 50 +++++----- js/src/xpconnect/src/xpcprivate.h | 95 ++++++++----------- js/src/xpconnect/src/xpcthreadcontext.cpp | 4 +- js/src/xpconnect/src/xpcwrappednative.cpp | 7 +- .../xpconnect/src/xpcwrappednativejsops.cpp | 81 ++++++++-------- .../xpconnect/src/xpcwrappednativescope.cpp | 31 +++--- storage/src/mozStorageStatementWrapper.cpp | 18 ++-- 16 files changed, 191 insertions(+), 211 deletions(-) diff --git a/dom/src/base/nsDOMClassInfo.cpp b/dom/src/base/nsDOMClassInfo.cpp index b4e6a05aee5b..889345d6b6c6 100644 --- a/dom/src/base/nsDOMClassInfo.cpp +++ b/dom/src/base/nsDOMClassInfo.cpp @@ -3682,10 +3682,10 @@ nsDOMClassInfo::HasInstance(nsIXPConnectWrappedNative *wrapper, JSContext *cx, } NS_IMETHODIMP -nsDOMClassInfo::Trace(nsIXPConnectWrappedNative *wrapper, JSTracer *trc, - JSObject *obj) +nsDOMClassInfo::Mark(nsIXPConnectWrappedNative *wrapper, JSContext *cx, + JSObject *obj, void *arg, PRUint32 *_retval) { - NS_WARNING("nsDOMClassInfo::Trace Don't call me!"); + NS_WARNING("nsDOMClassInfo::Mark Don't call me!"); return NS_ERROR_UNEXPECTED; } diff --git a/js/src/xpconnect/idl/nsIXPCScriptable.idl b/js/src/xpconnect/idl/nsIXPCScriptable.idl index 7c37283480ee..0533073edb6e 100644 --- a/js/src/xpconnect/idl/nsIXPCScriptable.idl +++ b/js/src/xpconnect/idl/nsIXPCScriptable.idl @@ -53,7 +53,7 @@ * to *_retval unless they want to return PR_FALSE. */ -[uuid(1455f6fe-6de9-4b62-a2b3-d1aee82dd829)] +[uuid(9cc0c2e0-f769-4f14-8cd6-2d2d40466f6c)] interface nsIXPCScriptable : nsISupports { /* bitflags used for 'flags' (only 32 bits available!) */ @@ -74,7 +74,7 @@ interface nsIXPCScriptable : nsISupports const PRUint32 WANT_CALL = 1 << 13; const PRUint32 WANT_CONSTRUCT = 1 << 14; const PRUint32 WANT_HASINSTANCE = 1 << 15; - const PRUint32 WANT_TRACE = 1 << 16; + const PRUint32 WANT_MARK = 1 << 16; const PRUint32 USE_JSSTUB_FOR_ADDPROPERTY = 1 << 17; const PRUint32 USE_JSSTUB_FOR_DELPROPERTY = 1 << 18; const PRUint32 USE_JSSTUB_FOR_SETPROPERTY = 1 << 19; @@ -161,8 +161,8 @@ interface nsIXPCScriptable : nsISupports in JSContextPtr cx, in JSObjectPtr obj, in JSVal val, out PRBool bp); - void trace(in nsIXPConnectWrappedNative wrapper, - in JSTracerPtr trc, in JSObjectPtr obj); + PRUint32 mark(in nsIXPConnectWrappedNative wrapper, + in JSContextPtr cx, in JSObjectPtr obj, in voidPtr arg); PRBool equality(in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in JSVal val); diff --git a/js/src/xpconnect/idl/nsIXPConnect.idl b/js/src/xpconnect/idl/nsIXPConnect.idl index ed4e7a0d30a9..0f66c6617791 100644 --- a/js/src/xpconnect/idl/nsIXPConnect.idl +++ b/js/src/xpconnect/idl/nsIXPConnect.idl @@ -64,7 +64,6 @@ native JSVal(jsval); native JSID(jsid); [ptr] native voidPtrPtr(void*); -[ptr] native JSTracerPtr(JSTracer); /***************************************************************************/ diff --git a/js/src/xpconnect/public/xpc_map_end.h b/js/src/xpconnect/public/xpc_map_end.h index cf5fd64f3244..4bb85d2f3091 100644 --- a/js/src/xpconnect/public/xpc_map_end.h +++ b/js/src/xpconnect/public/xpc_map_end.h @@ -109,8 +109,8 @@ NS_IMETHODIMP XPC_MAP_CLASSNAME::GetScriptableFlags(PRUint32 *aFlags) #ifdef XPC_MAP_WANT_HASINSTANCE nsIXPCScriptable::WANT_HASINSTANCE | #endif -#ifdef XPC_MAP_WANT_TRACE - nsIXPCScriptable::WANT_TRACE | +#ifdef XPC_MAP_WANT_MARK + nsIXPCScriptable::WANT_MARK | #endif #ifdef XPC_MAP_WANT_EQUALITY nsIXPCScriptable::WANT_EQUALITY | @@ -212,8 +212,8 @@ NS_IMETHODIMP XPC_MAP_CLASSNAME::HasInstance(nsIXPConnectWrappedNative *wrapper, {NS_ERROR("never called"); return NS_ERROR_NOT_IMPLEMENTED;} #endif -#ifndef XPC_MAP_WANT_TRACE -NS_IMETHODIMP XPC_MAP_CLASSNAME::Trace(nsIXPConnectWrappedNative *wrapper, JSTracer *trc, JSObject * obj) +#ifndef XPC_MAP_WANT_MARK +NS_IMETHODIMP XPC_MAP_CLASSNAME::Mark(nsIXPConnectWrappedNative *wrapper, JSContext * cx, JSObject * obj, void * arg, PRUint32 *_retval) {NS_ERROR("never called"); return NS_ERROR_NOT_IMPLEMENTED;} #endif @@ -301,8 +301,8 @@ NS_IMETHODIMP XPC_MAP_CLASSNAME::InnerObject(nsIXPConnectWrappedNative *wrapper, #undef XPC_MAP_WANT_HASINSTANCE #endif -#ifdef XPC_MAP_WANT_TRACE -#undef XPC_MAP_WANT_TRACE +#ifdef XPC_MAP_WANT_MARK +#undef XPC_MAP_WANT_MARK #endif #ifdef XPC_MAP_WANT_EQUALITY diff --git a/js/src/xpconnect/src/XPCDispInlines.h b/js/src/xpconnect/src/XPCDispInlines.h index 694520ea0a1d..53bb641fb820 100644 --- a/js/src/xpconnect/src/XPCDispInlines.h +++ b/js/src/xpconnect/src/XPCDispInlines.h @@ -463,7 +463,7 @@ JSBool XPCDispIDArray::IsMarked() const // NOP. This is just here to make the AutoMarkingPtr code compile. inline -void XPCDispIDArray::Mark() +void XPCDispIDArray::MarkBeforeJSFinalize(JSContext*) { } diff --git a/js/src/xpconnect/src/XPCDispParamPropJSClass.cpp b/js/src/xpconnect/src/XPCDispParamPropJSClass.cpp index 9b3c38aca514..70d2988a458a 100644 --- a/js/src/xpconnect/src/XPCDispParamPropJSClass.cpp +++ b/js/src/xpconnect/src/XPCDispParamPropJSClass.cpp @@ -134,20 +134,23 @@ XPC_PP_Finalize(JSContext *cx, JSObject *obj) } /** - * Is called to trace things that the object holds. - * @param trc the tracing structure + * Is called to mark during GC + * @param cx the JS context * @param obj the object being marked + * @param arg we just pass this on + * @return 0 */ -JS_STATIC_DLL_CALLBACK(void) -XPC_PP_Trace(JSTracer *trc, JSObject *obj) +JS_STATIC_DLL_CALLBACK(uint32) +XPC_PP_Mark(JSContext *cx, JSObject *obj, void *arg) { - XPCDispParamPropJSClass* paramProp = GetParamProp(trc->context, obj); + XPCDispParamPropJSClass* paramProp = GetParamProp(cx, obj); if(paramProp) { XPCWrappedNative* wrapper = paramProp->GetWrapper(); if(wrapper && wrapper->IsValid()) - xpc_TraceForValidWrapper(trc, wrapper); + xpc_MarkForValidWrapper(cx, wrapper, arg); } + return 0; } /** @@ -156,7 +159,7 @@ XPC_PP_Trace(JSTracer *trc, JSObject *obj) */ static JSClass ParamPropClass = { "XPCDispParamPropJSCass", // Name - JSCLASS_HAS_PRIVATE | JSCLASS_MARK_IS_TRACE, // flags + JSCLASS_HAS_PRIVATE, // flags /* Mandatory non-null function pointer members. */ JS_PropertyStub, // addProperty @@ -175,7 +178,7 @@ static JSClass ParamPropClass = { nsnull, // construct; nsnull, // xdrObject; nsnull, // hasInstance; - JS_CLASS_TRACE(XPC_PP_Trace), // mark/trace; + XPC_PP_Mark, // mark; nsnull // spare; }; diff --git a/js/src/xpconnect/src/XPCDispPrivate.h b/js/src/xpconnect/src/XPCDispPrivate.h index 2b85853a02c6..22fb58ff9d36 100644 --- a/js/src/xpconnect/src/XPCDispPrivate.h +++ b/js/src/xpconnect/src/XPCDispPrivate.h @@ -292,13 +292,11 @@ public: * @param array a JS array of ID's */ XPCDispIDArray(XPCCallContext& ccx, JSIdArray* array); - /** * Returns the length of the array * @return length of the array */ PRUint32 Length() const; - /** * Returns an ID within the array * @param cx a JS context @@ -308,24 +306,22 @@ public: jsval Item(JSContext* cx, PRUint32 index) const; /** - * Called to trace jsval associated with the ID's + * Called to mark the ID's during GC */ - void TraceJS(JSTracer* trc); - + void Mark(); /** - * Called to unmark the ID's marked during GC marking trace + * Called to unmark the ID's after GC has been done */ void Unmark(); - - /** - * NOP. This is just here to make the AutoMarkingPtr code compile. - */ - inline void Mark(); - /** * Tests whether the ID is marked */ JSBool IsMarked() const; + + /** + * NOP. This is just here to make the AutoMarkingPtr code compile. + */ + inline void MarkBeforeJSFinalize(JSContext*); private: JSBool mMarked; nsVoidArray mIDArray; diff --git a/js/src/xpconnect/src/XPCDispTypeInfo.cpp b/js/src/xpconnect/src/XPCDispTypeInfo.cpp index e7762c5dbbba..7c56d4ab2299 100644 --- a/js/src/xpconnect/src/XPCDispTypeInfo.cpp +++ b/js/src/xpconnect/src/XPCDispTypeInfo.cpp @@ -444,27 +444,31 @@ XPCDispIDArray::XPCDispIDArray(XPCCallContext& ccx, JSIdArray* array) : } } -void XPCDispIDArray::TraceJS(JSTracer* trc) +void XPCDispIDArray::Mark() { // If already marked nothing to do - if(JS_IsGCMarkingTracer(trc)) - { - if (IsMarked()) - return; - mMarked = JS_TRUE; - } + if(IsMarked()) + return; + mMarked = JS_TRUE; + XPCCallContext ccx(NATIVE_CALLER); + // Bail if our call context is bad + if(!ccx.IsValid()) + return; PRInt32 count = Length(); jsval val; - + JSContext* cx = ccx; // Iterate each of the ID's and mark them for(PRInt32 index = 0; index < count; ++index) { - if(JS_IdToValue(trc->context, - NS_REINTERPRET_CAST(jsid, mIDArray.ElementAt(index)), - &val)) + if(JS_IdToValue(cx, + NS_REINTERPRET_CAST(jsid, + mIDArray.ElementAt(index)), + &val) && + JSVAL_IS_GCTHING(val)) { - JS_CALL_VALUE_TRACER(trc, val, "disp_id_array_element"); + JS_MarkGCThing(cx, NS_REINTERPRET_CAST(void*,val), + nsnull, nsnull); } } } diff --git a/js/src/xpconnect/src/XPCNativeWrapper.cpp b/js/src/xpconnect/src/XPCNativeWrapper.cpp index 127eccd700b2..8fa5ce229e1d 100644 --- a/js/src/xpconnect/src/XPCNativeWrapper.cpp +++ b/js/src/xpconnect/src/XPCNativeWrapper.cpp @@ -82,8 +82,8 @@ XPC_NW_Construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, JS_STATIC_DLL_CALLBACK(JSBool) XPC_NW_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp); -JS_STATIC_DLL_CALLBACK(void) -XPC_NW_Trace(JSTracer *trc, JSObject *obj); +JS_STATIC_DLL_CALLBACK(uint32) +XPC_NW_Mark(JSContext *cx, JSObject *obj, void *arg); JS_STATIC_DLL_CALLBACK(JSBool) XPC_NW_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp); @@ -104,7 +104,7 @@ JSExtendedClass XPCNativeWrapper::sXPC_NW_JSClass = { JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS | // Our one reserved slot holds a jsint of flag bits JSCLASS_NEW_RESOLVE | JSCLASS_HAS_RESERVED_SLOTS(1) | - JSCLASS_MARK_IS_TRACE | JSCLASS_IS_EXTENDED, + JSCLASS_IS_EXTENDED, XPC_NW_AddProperty, XPC_NW_DelProperty, XPC_NW_GetProperty, XPC_NW_SetProperty, XPC_NW_Enumerate, (JSResolveOp)XPC_NW_NewResolve, @@ -112,7 +112,7 @@ JSExtendedClass XPCNativeWrapper::sXPC_NW_JSClass = { nsnull, XPC_NW_CheckAccess, XPC_NW_Call, XPC_NW_Construct, nsnull, XPC_NW_HasInstance, - JS_CLASS_TRACE(XPC_NW_Trace), nsnull + XPC_NW_Mark, nsnull }, // JSExtendedClass initialization XPC_NW_Equality @@ -1185,16 +1185,18 @@ XPCNativeWrapperCtor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, return JS_TRUE; } -JS_STATIC_DLL_CALLBACK(void) -XPC_NW_Trace(JSTracer *trc, JSObject *obj) +JS_STATIC_DLL_CALLBACK(uint32) +XPC_NW_Mark(JSContext *cx, JSObject *obj, void *arg) { XPCWrappedNative *wrappedNative = - XPCNativeWrapper::GetWrappedNative(trc->context, obj); + XPCNativeWrapper::GetWrappedNative(cx, obj); if (wrappedNative && wrappedNative->IsValid()) { - JS_CALL_OBJECT_TRACER(trc, wrappedNative->GetFlatJSObject(), - "wrappedNative.flatJSObject"); + ::JS_MarkGCThing(cx, wrappedNative->GetFlatJSObject(), + "XPCNativeWrapper wrapped native", arg); } + + return 0; } JS_STATIC_DLL_CALLBACK(JSBool) diff --git a/js/src/xpconnect/src/xpcjsruntime.cpp b/js/src/xpconnect/src/xpcjsruntime.cpp index eb6e21847964..98409d1f027d 100644 --- a/js/src/xpconnect/src/xpcjsruntime.cpp +++ b/js/src/xpconnect/src/xpcjsruntime.cpp @@ -249,31 +249,6 @@ ContextCallback(JSContext *cx, uintN operation) : JS_TRUE; } -// static -void XPCJSRuntime::TraceJS(JSTracer *trc, XPCJSRuntime* self) -{ - // Skip this part if XPConnect is shutting down. We get into - // bad locking problems with the thread iteration otherwise. - if(!self->GetXPConnect()->IsShuttingDown()) - { - PRLock* threadLock = XPCPerThreadData::GetLock(); - if(threadLock) - { // scoped lock - nsAutoLock lock(threadLock); - - XPCPerThreadData* iterp = nsnull; - XPCPerThreadData* thread; - - while(nsnull != (thread = - XPCPerThreadData::IterateThreads(&iterp))) - { - // Trace those AutoMarkingPtr lists! - thread->TraceJS(trc); - } - } - } -} - // static JSBool XPCJSRuntime::GCCallback(JSContext *cx, JSGCStatus status) { @@ -303,7 +278,30 @@ JSBool XPCJSRuntime::GCCallback(JSContext *cx, JSGCStatus status) self->mThreadRunningGC = PR_GetCurrentThread(); } - TraceJS(JS_GetGCMarkingTracer(cx), self); + // Skip this part if XPConnect is shutting down. We get into + // bad locking problems with the thread iteration otherwise. + if(!self->GetXPConnect()->IsShuttingDown()) + { + PRLock* threadLock = XPCPerThreadData::GetLock(); + if(threadLock) + { // scoped lock + nsAutoLock lock(threadLock); + + XPCPerThreadData* iterp = nsnull; + XPCPerThreadData* thread; + + while(nsnull != (thread = + XPCPerThreadData::IterateThreads(&iterp))) + { + // Mark those AutoMarkingPtr lists! + // XXX This should be in a JSGC_MARK_BEGIN + // callback, in case other callbacks use + // JSGC_MARK_END (or a close phase before it) + // to determine what is about to be finalized. + thread->MarkAutoRootsBeforeJSFinalize(cx); + } + } + } dyingWrappedJSArray = &self->mWrappedJSToReleaseArray; { diff --git a/js/src/xpconnect/src/xpcprivate.h b/js/src/xpconnect/src/xpcprivate.h index f27cd9bcc4b8..61c8c2b84e51 100644 --- a/js/src/xpconnect/src/xpcprivate.h +++ b/js/src/xpconnect/src/xpcprivate.h @@ -628,8 +628,6 @@ public: return mStrings[index]; } - static void TraceJS(JSTracer *trc, XPCJSRuntime* self); - static JSBool JS_DLL_CALLBACK GCCallback(JSContext *cx, JSGCStatus status); void DebugDump(PRInt16 depth); @@ -1040,7 +1038,7 @@ xpc_InitWrappedNativeJSOps(); // Comes from xpcwrappednativeops.cpp extern void -xpc_TraceForValidWrapper(JSTracer *trc, XPCWrappedNative* wrapper); +xpc_MarkForValidWrapper(JSContext *cx, XPCWrappedNative* wrapper, void *arg); /***************************************************************************/ @@ -1091,9 +1089,6 @@ public: static void SystemIsBeingShutDown(XPCCallContext& ccx); - static void - TraceJS(JSTracer* trc, XPCJSRuntime* rt); - static void FinishedMarkPhaseOfGC(JSContext* cx, XPCJSRuntime* rt); @@ -1299,8 +1294,8 @@ public: {return 0 != (mMemberCount & XPC_NATIVE_IFACE_MARK_FLAG);} // NOP. This is just here to make the AutoMarkingPtr code compile. - inline void TraceJS(JSTracer* trc) {} - inline void AutoTrace(JSTracer* trc) {} + inline void MarkBeforeJSFinalize(JSContext*) {} + inline void AutoMark(JSContext*) {} static void DestroyInstance(JSContext* cx, XPCJSRuntime* rt, XPCNativeInterface* inst); @@ -1428,8 +1423,8 @@ public: inline void Mark(); // NOP. This is just here to make the AutoMarkingPtr code compile. - inline void TraceJS(JSTracer* trc) {} - inline void AutoTrace(JSTracer* trc) {} + inline void MarkBeforeJSFinalize(JSContext*) {} + inline void AutoMark(JSContext*) {} private: void MarkSelfOnly() {mInterfaceCount |= XPC_NATIVE_SET_MARK_FLAG;} @@ -1517,7 +1512,7 @@ public: JSBool WantCall() GET_IT(WANT_CALL) JSBool WantConstruct() GET_IT(WANT_CONSTRUCT) JSBool WantHasInstance() GET_IT(WANT_HASINSTANCE) - JSBool WantTrace() GET_IT(WANT_TRACE) + JSBool WantMark() GET_IT(WANT_MARK) JSBool WantEquality() GET_IT(WANT_EQUALITY) JSBool WantOuterObject() GET_IT(WANT_OUTER_OBJECT) JSBool WantInnerObject() GET_IT(WANT_INNER_OBJECT) @@ -1728,23 +1723,16 @@ public: void DebugDump(PRInt16 depth); - // During the mark traversal of JS GC this is called in the 'early' phase - // by AutoMarkingWrappedNativeProtoPtr. + // This is called in the 'early' phase by AutoMarkingWrappedNativeProtoPtr. // 'early' meaning after JSGC_MARK_END and before JSGC_FINALIZE_END. // At this point in time we can still mark JSObjects in the JS gc heap. - void TraceJS(JSTracer* trc) - { - if(mJSProtoObject) - { - JS_CALL_OBJECT_TRACER(trc, mJSProtoObject, - "XPCWrappedNativeProto::mJSProtoObject"); - } - if(mScriptableInfo && JS_IsGCMarkingTracer(trc)) - mScriptableInfo->Mark(); - } - + void MarkBeforeJSFinalize(JSContext* cx) + {if(mJSProtoObject) + JS_MarkGCThing(cx, mJSProtoObject, + "XPCWrappedNativeProto::mJSProtoObject", nsnull); + if(mScriptableInfo) mScriptableInfo->Mark();} // NOP. This is just here to make the AutoMarkingPtr code compile. - inline void AutoTrace(JSTracer* trc) {} + inline void AutoMark(JSContext*) {} // Yes, we *do* need to mark the mScriptableInfo in both cases. void Mark() const @@ -1813,8 +1801,8 @@ public: ~XPCWrappedNativeTearOff(); // NOP. This is just here to make the AutoMarkingPtr code compile. - inline void TraceJS(JSTracer* trc) {} - inline void AutoTrace(JSTracer* trc) {} + inline void MarkBeforeJSFinalize(JSContext*) {} + inline void AutoMark(JSContext*) {} void Mark() {mJSObject = (JSObject*)(((jsword)mJSObject) | 1);} void Unmark() {mJSObject = (JSObject*)(((jsword)mJSObject) & ~1);} @@ -2038,29 +2026,28 @@ public: } // Yes, we *do* need to mark the mScriptableInfo in both cases. - inline void TraceJS(JSTracer* trc) + inline void MarkBeforeJSFinalize(JSContext* cx) { - if(mScriptableInfo && JS_IsGCMarkingTracer(trc)) - mScriptableInfo->Mark(); - if(HasProto()) mMaybeProto->TraceJS(trc); + if(mScriptableInfo) mScriptableInfo->Mark(); + if(HasProto()) mMaybeProto->MarkBeforeJSFinalize(cx); if(mNativeWrapper) { - JS_CALL_OBJECT_TRACER(trc, mNativeWrapper, - "XPCWrappedNative::mNativeWrapper"); + JS_MarkGCThing(cx, mNativeWrapper, + "XPCWrappedNative::mNativeWrapper", nsnull); } } - inline void AutoTrace(JSTracer* trc) + inline void AutoMark(JSContext* cx) { // If this got called, we're being kept alive by someone who really // needs us alive and whole. Do not let our mFlatJSObject go away. - // This is the only time we should be tracing our mFlatJSObject, - // normally somebody else is doing that. Be careful not to trace the - // bogus JSVAL_ONE value we can have during init, though. + // This is the only time we should be marking our mFlatJSObject; + // normally we just go away quietly when it does. Be careful not to + // mark the bogus JSVAL_ONE value we can have during init, though. if(mFlatJSObject && mFlatJSObject != (JSObject*)JSVAL_ONE) { - JS_CALL_OBJECT_TRACER(trc, mFlatJSObject, - "XPCWrappedNative::mFlatJSObject"); + ::JS_MarkGCThing(cx, mFlatJSObject, + "XPCWrappedNative::mFlatJSObject", nsnull); } } @@ -2913,7 +2900,7 @@ public: AutoMarkingPtr** GetAutoRootsAdr() {return &mAutoRoots;} - void TraceJS(JSTracer* trc); + void MarkAutoRootsBeforeJSFinalize(JSContext* cx); void MarkAutoRootsAfterJSFinalize(); jsuword GetStackLimit() const { return mStackLimit; } @@ -3388,11 +3375,11 @@ public: XPCMarkableJSVal(jsval *pval) : mVal(0), mValPtr(pval) {} ~XPCMarkableJSVal() {} void Mark() {} - void TraceJS(JSTracer* trc) - { - JS_CALL_VALUE_TRACER(trc, *mValPtr, "XPCMarkableJSVal"); - } - void AutoTrace(JSTracer* trc) {} + void MarkBeforeJSFinalize(JSContext* cx) + {if(JSVAL_IS_GCTHING(*mValPtr)) + JS_MarkGCThing(cx, JSVAL_TO_GCTHING(*mValPtr), + "XPCMarkableJSVal", nsnull);} + void AutoMark(JSContext*) {} private: XPCMarkableJSVal(); // not implemented jsval mVal; @@ -3432,7 +3419,7 @@ public: AutoMarkingPtr* GetNext() {return mNext;} - virtual void TraceJS(JSTracer* trc) = 0; + virtual void MarkBeforeJSFinalize(JSContext* cx) = 0; virtual void MarkAfterJSFinalize() = 0; protected: @@ -3450,12 +3437,12 @@ public: \ : AutoMarkingPtr(ccx), mPtr(ptr) {} \ virtual ~ class_ () {} \ \ - virtual void TraceJS(JSTracer* trc) \ + virtual void MarkBeforeJSFinalize(JSContext* cx) \ {if(mPtr) { \ - mPtr->TraceJS(trc); \ - mPtr->AutoTrace(trc); \ + mPtr->MarkBeforeJSFinalize(cx); \ + mPtr->AutoMark(cx); \ } \ - if(mNext) mNext->TraceJS(trc);} \ + if(mNext) mNext->MarkBeforeJSFinalize(cx);} \ \ virtual void MarkAfterJSFinalize() \ {if(mPtr) mPtr->Mark(); \ @@ -3496,18 +3483,18 @@ public: \ } \ virtual ~ class_ () {} \ \ - virtual void TraceJS(JSTracer* trc) \ + virtual void MarkBeforeJSFinalize(JSContext* cx) \ { \ for(PRUint32 i = 0; i < mCount; ++i) \ { \ type_* cur = mPtr[i]; \ if(cur) \ { \ - cur->TraceJS(trc); \ - cur->AutoTrace(trc); \ + cur->MarkBeforeJSFinalize(cx); \ + cur->AutoMark(cx); \ } \ } \ - if(mNext) mNext->TraceJS(trc); \ + if(mNext) mNext->MarkBeforeJSFinalize(cx); \ } \ \ virtual void MarkAfterJSFinalize() \ diff --git a/js/src/xpconnect/src/xpcthreadcontext.cpp b/js/src/xpconnect/src/xpcthreadcontext.cpp index 2b36bdd8421b..3d7422a6699a 100644 --- a/js/src/xpconnect/src/xpcthreadcontext.cpp +++ b/js/src/xpconnect/src/xpcthreadcontext.cpp @@ -504,7 +504,7 @@ xpc_ThreadDataDtorCB(void* ptr) delete data; } -void XPCPerThreadData::TraceJS(JSTracer *trc) +void XPCPerThreadData::MarkAutoRootsBeforeJSFinalize(JSContext* cx) { #ifdef XPC_TRACK_AUTOMARKINGPTR_STATS { @@ -520,7 +520,7 @@ void XPCPerThreadData::TraceJS(JSTracer *trc) #endif if(mAutoRoots) - mAutoRoots->TraceJS(trc); + mAutoRoots->MarkBeforeJSFinalize(cx); } void XPCPerThreadData::MarkAutoRootsAfterJSFinalize() diff --git a/js/src/xpconnect/src/xpcwrappednative.cpp b/js/src/xpconnect/src/xpcwrappednative.cpp index 118585f0e08d..786e1eec0296 100644 --- a/js/src/xpconnect/src/xpcwrappednative.cpp +++ b/js/src/xpconnect/src/xpcwrappednative.cpp @@ -93,14 +93,15 @@ NS_CYCLE_COLLECTION_CLASSNAME(XPCWrappedNative)::Traverse(nsISupports *s, // it marked. - // xpc_TraceForValidWrapper calls TraceJS and TraceScopeJSObjects. + // xpc_MarkForValidWrapper calls MarkBeforeJSFinalize and + // MarkScopeJSObjects. - // XPCWrappedNative marks its proto (see TraceJS). + // XPCWrappedNative marks its proto (see MarkBeforeJSFinalize). if(tmp->HasProto()) cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT, tmp->GetProto()->GetJSProtoObject()); - // XPCWrappedNative marks its mNativeWrapper (see TraceJS). + // XPCWrappedNative marks its mNativeWrapper (see MarkBeforeJSFinalize). cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT, tmp->mNativeWrapper); // XPCWrappedNative marks its scope. diff --git a/js/src/xpconnect/src/xpcwrappednativejsops.cpp b/js/src/xpconnect/src/xpcwrappednativejsops.cpp index be5cf678a60e..f3682c2cbaac 100644 --- a/js/src/xpconnect/src/xpcwrappednativejsops.cpp +++ b/js/src/xpconnect/src/xpcwrappednativejsops.cpp @@ -651,7 +651,7 @@ XPC_WN_NoHelper_Finalize(JSContext *cx, JSObject *obj) } static void -TraceScopeJSObjects(JSTracer *trc, XPCWrappedNativeScope* scope) +MarkScopeJSObjects(JSContext *cx, XPCWrappedNativeScope* scope, void *arg) { NS_ASSERTION(scope, "bad scope"); @@ -659,39 +659,35 @@ TraceScopeJSObjects(JSTracer *trc, XPCWrappedNativeScope* scope) obj = scope->GetGlobalJSObject(); NS_ASSERTION(scope, "bad scope JSObject"); - JS_CALL_OBJECT_TRACER(trc, obj, "XPCWrappedNativeScope::mGlobalJSObject"); + JS_MarkGCThing(cx, obj, "XPCWrappedNativeScope::mGlobalJSObject", arg); obj = scope->GetPrototypeJSObject(); if(obj) { - JS_CALL_OBJECT_TRACER(trc, obj, - "XPCWrappedNativeScope::mPrototypeJSObject"); + JS_MarkGCThing(cx, obj, "XPCWrappedNativeScope::mPrototypeJSObject", arg); } obj = scope->GetPrototypeJSFunction(); if(obj) { - JS_CALL_OBJECT_TRACER(trc, obj, - "XPCWrappedNativeScope::mPrototypeJSFunction"); + JS_MarkGCThing(cx, obj, "XPCWrappedNativeScope::mPrototypeJSFunction", arg); } } void -xpc_TraceForValidWrapper(JSTracer *trc, XPCWrappedNative* wrapper) +xpc_MarkForValidWrapper(JSContext *cx, XPCWrappedNative* wrapper, void *arg) { - // NOTE: It might be nice to also do the wrapper->Mark() call here too - // when we are called during the marking phase of JS GC to mark the - // wrapper's and wrapper's proto's interface sets. - // + // NOTE: It might be nice to also do the wrapper->Mark() call here too. + // That call marks the wrapper's and wrapper's proto's interface sets. // We currently do that in the GC callback code. The reason we don't do that // here is because the bits used in that marking do unpleasant things to the // member counts in the interface and interface set objects. Those counts // are used in the DealWithDyingGCThings calls that are part of this JS GC // marking phase. By doing these calls later during our GC callback we // avoid that problem. Arguably this could be changed. But it ain't broke. - // - // However, we do need to call the wrapper's TraceJS so that - // it can be sure that its (potentially shared) JSClass is traced. The + + // However, we do need to call the wrapper's MarkBeforeJSFinalize so that + // it can be sure that its (potentially shared) JSClass gets marked. The // danger is that a live wrapper might not be in a wrapper map and thus // won't be fully marked in the GC callback. This can happen if there is // a security exception during wrapper creation or if during wrapper @@ -700,19 +696,20 @@ xpc_TraceForValidWrapper(JSTracer *trc, XPCWrappedNative* wrapper) // the interface set will never be accessed. But the JS engine will still // need to use the JSClass. So, some marking is required for protection. - wrapper->TraceJS(trc); + wrapper->MarkBeforeJSFinalize(cx); - TraceScopeJSObjects(trc, wrapper->GetScope()); + MarkScopeJSObjects(cx, wrapper->GetScope(), arg); } -JS_STATIC_DLL_CALLBACK(void) -XPC_WN_Shared_Trace(JSTracer *trc, JSObject *obj) +JS_STATIC_DLL_CALLBACK(uint32) +XPC_WN_Shared_Mark(JSContext *cx, JSObject *obj, void *arg) { XPCWrappedNative* wrapper = - XPCWrappedNative::GetWrappedNativeOfJSObject(trc->context, obj); + XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj); if(wrapper && wrapper->IsValid()) - xpc_TraceForValidWrapper(trc, wrapper); + xpc_MarkForValidWrapper(cx, wrapper, arg); + return 1; } JS_STATIC_DLL_CALLBACK(JSBool) @@ -883,7 +880,6 @@ JSExtendedClass XPC_WN_NoHelper_JSClass = { "XPCWrappedNative_NoHelper", // name; JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS | - JSCLASS_MARK_IS_TRACE | JSCLASS_IS_EXTENDED, // flags; /* Mandatory non-null function pointer members. */ @@ -904,7 +900,7 @@ JSExtendedClass XPC_WN_NoHelper_JSClass = { nsnull, // construct; nsnull, // xdrObject; nsnull, // hasInstance; - JS_CLASS_TRACE(XPC_WN_Shared_Trace), // mark/trace; + XPC_WN_Shared_Mark, // mark; nsnull // spare; }, XPC_WN_Equality, @@ -1038,16 +1034,18 @@ XPC_WN_Helper_Finalize(JSContext *cx, JSObject *obj) wrapper->FlatJSObjectFinalized(cx, obj); } -JS_STATIC_DLL_CALLBACK(void) -XPC_WN_Helper_Trace(JSTracer *trc, JSObject *obj) +JS_STATIC_DLL_CALLBACK(uint32) +XPC_WN_Helper_Mark(JSContext *cx, JSObject *obj, void *arg) { + PRUint32 ignored = 0; XPCWrappedNative* wrapper = - XPCWrappedNative::GetWrappedNativeOfJSObject(trc->context, obj); + XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj); if(wrapper && wrapper->IsValid()) { - wrapper->GetScriptableCallback()->Trace(wrapper, trc, obj); - xpc_TraceForValidWrapper(trc, wrapper); + wrapper->GetScriptableCallback()->Mark(wrapper, cx, obj, arg, &ignored); + xpc_MarkForValidWrapper(cx, wrapper, arg); } + return (uint32) ignored; } JS_STATIC_DLL_CALLBACK(JSBool) @@ -1346,7 +1344,6 @@ XPCNativeScriptableShared::PopulateJSClass(JSBool isGlobal) mJSClass.base.flags = JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS | JSCLASS_NEW_RESOLVE | - JSCLASS_MARK_IS_TRACE | JSCLASS_IS_EXTENDED; if(isGlobal) @@ -1435,10 +1432,10 @@ XPCNativeScriptableShared::PopulateJSClass(JSBool isGlobal) if(mFlags.WantHasInstance()) mJSClass.base.hasInstance = XPC_WN_Helper_HasInstance; - if(mFlags.WantTrace()) - mJSClass.base.mark = JS_CLASS_TRACE(XPC_WN_Helper_Trace); + if(mFlags.WantMark()) + mJSClass.base.mark = XPC_WN_Helper_Mark; else - mJSClass.base.mark = JS_CLASS_TRACE(XPC_WN_Shared_Trace); + mJSClass.base.mark = XPC_WN_Shared_Mark; mJSClass.equality = XPC_WN_Equality; mJSClass.outerObject = XPC_WN_OuterObject; @@ -1557,14 +1554,14 @@ XPC_WN_Shared_Proto_Finalize(JSContext *cx, JSObject *obj) p->JSProtoObjectFinalized(cx, obj); } -JS_STATIC_DLL_CALLBACK(void) -XPC_WN_Shared_Proto_Trace(JSTracer *trc, JSObject *obj) +JS_STATIC_DLL_CALLBACK(uint32) +XPC_WN_Shared_Proto_Mark(JSContext *cx, JSObject *obj, void *arg) { // This can be null if xpc shutdown has already happened - XPCWrappedNativeProto* p = - (XPCWrappedNativeProto*) JS_GetPrivate(trc->context, obj); + XPCWrappedNativeProto* p = (XPCWrappedNativeProto*) JS_GetPrivate(cx, obj); if(p) - TraceScopeJSObjects(trc, p->GetScope()); + MarkScopeJSObjects(cx, p->GetScope(), arg); + return 1; } /*****************************************************/ @@ -1600,7 +1597,7 @@ XPC_WN_ModsAllowed_Proto_Resolve(JSContext *cx, JSObject *obj, jsval idval) JSClass XPC_WN_ModsAllowed_Proto_JSClass = { "XPC_WN_ModsAllowed_Proto_JSClass", // name; - JSCLASS_HAS_PRIVATE | JSCLASS_MARK_IS_TRACE, // flags; + JSCLASS_HAS_PRIVATE, // flags; /* Mandatory non-null function pointer members. */ JS_PropertyStub, // addProperty; @@ -1619,7 +1616,7 @@ JSClass XPC_WN_ModsAllowed_Proto_JSClass = { nsnull, // construct; nsnull, // xdrObject; nsnull, // hasInstance; - JS_CLASS_TRACE(XPC_WN_Shared_Proto_Trace), // mark/trace; + XPC_WN_Shared_Proto_Mark, // mark; nsnull // spare; }; @@ -1681,7 +1678,7 @@ XPC_WN_NoMods_Proto_Resolve(JSContext *cx, JSObject *obj, jsval idval) JSClass XPC_WN_NoMods_Proto_JSClass = { "XPC_WN_NoMods_Proto_JSClass", // name; - JSCLASS_HAS_PRIVATE | JSCLASS_MARK_IS_TRACE, // flags; + JSCLASS_HAS_PRIVATE, // flags; /* Mandatory non-null function pointer members. */ XPC_WN_OnlyIWrite_Proto_PropertyStub, // addProperty; @@ -1700,7 +1697,7 @@ JSClass XPC_WN_NoMods_Proto_JSClass = { nsnull, // construct; nsnull, // xdrObject; nsnull, // hasInstance; - JS_CLASS_TRACE(XPC_WN_Shared_Proto_Trace), // mark/trace; + XPC_WN_Shared_Proto_Mark, // mark; nsnull // spare; }; @@ -1764,7 +1761,7 @@ XPC_WN_TearOff_Finalize(JSContext *cx, JSObject *obj) JSClass XPC_WN_Tearoff_JSClass = { "WrappedNative_TearOff", // name; - JSCLASS_HAS_PRIVATE | JSCLASS_MARK_IS_TRACE, // flags; + JSCLASS_HAS_PRIVATE, // flags; /* Mandatory non-null function pointer members. */ XPC_WN_OnlyIWrite_PropertyStub, // addProperty; @@ -1783,7 +1780,7 @@ JSClass XPC_WN_Tearoff_JSClass = { nsnull, // construct; nsnull, // xdrObject; nsnull, // hasInstance; - nsnull, // mark/trace; + nsnull, // mark; nsnull // spare; }; diff --git a/js/src/xpconnect/src/xpcwrappednativescope.cpp b/js/src/xpconnect/src/xpcwrappednativescope.cpp index c76bf031c25e..6565d593da91 100644 --- a/js/src/xpconnect/src/xpcwrappednativescope.cpp +++ b/js/src/xpconnect/src/xpcwrappednativescope.cpp @@ -268,32 +268,19 @@ WrappedNativeJSGCThingMarker(JSDHashTable *table, JSDHashEntryHdr *hdr, XPCWrappedNative* wrapper = ((Native2WrappedNativeMap::Entry*)hdr)->value; if(wrapper->HasExternalReference()) { - JSTracer* trc = (JSTracer *)arg; - JS_CALL_OBJECT_TRACER(trc, wrapper->GetFlatJSObject(), - "XPCWrappedNative::mFlatJSObject"); + JS_MarkGCThing((JSContext*)arg, wrapper->GetFlatJSObject(), + "XPCWrappedNative::mFlatJSObject", nsnull); // FIXME: this call appears to do more harm than good, but // there is reason to imagine it might clean up some cycles // formed by a poor order between C++ and JS garbage cycle // formations. See Bug 368869. // - // if (JS_IsGCMarkTraversal(trc)) - // nsCycleCollector_suspectCurrent(wrapper); + // nsCycleCollector_suspectCurrent(wrapper); } return JS_DHASH_NEXT; } -// static -void -XPCWrappedNativeScope::TraceJS(JSTracer* trc, XPCJSRuntime* rt) -{ - // Do JS_CallTracer for all wrapperednatives with external references. - for(XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext) - { - cur->mWrappedNativeMap->Enumerate(WrappedNativeJSGCThingMarker, trc); - } -} - // static void XPCWrappedNativeScope::FinishedMarkPhaseOfGC(JSContext* cx, XPCJSRuntime* rt) @@ -301,14 +288,20 @@ XPCWrappedNativeScope::FinishedMarkPhaseOfGC(JSContext* cx, XPCJSRuntime* rt) // Hold the lock until return... XPCAutoLock lock(rt->GetMapLock()); - TraceJS(JS_GetGCMarkingTracer(cx), rt); + XPCWrappedNativeScope* cur; + + // Do JS_MarkGCThing for all wrapperednatives with external references. + for(cur = gScopes; cur; cur = cur->mNext) + { + cur->mWrappedNativeMap->Enumerate(WrappedNativeJSGCThingMarker, cx); + } // Since the JSGC_END call happens outside of a lock, // it is possible for us to get called here twice before the FinshedGC // call happens. So, we allow for gDyingScopes not being null. XPCWrappedNativeScope* prev = nsnull; - XPCWrappedNativeScope* cur = gScopes; + cur = gScopes; while(cur) { @@ -810,7 +803,7 @@ XPCWrappedNativeScope::DebugDump(PRInt16 depth) void XPCWrappedNativeScope::Traverse(nsCycleCollectionTraversalCallback &cb) { - // See TraceScopeJSObjects. + // See MarkScopeJSObjects. cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT, mGlobalJSObject); cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT, mPrototypeJSObject); cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT, diff --git a/storage/src/mozStorageStatementWrapper.cpp b/storage/src/mozStorageStatementWrapper.cpp index 69b7cdeca65a..fb5a47b998c5 100644 --- a/storage/src/mozStorageStatementWrapper.cpp +++ b/storage/src/mozStorageStatementWrapper.cpp @@ -450,10 +450,10 @@ mozStorageStatementWrapper::HasInstance(nsIXPConnectWrappedNative *wrapper, JSCo return NS_ERROR_NOT_IMPLEMENTED; } -/* void trace (in nsIXPConnectWrappedNative wrapper, in JSTracerPtr trc, in JSObjectPtr obj); */ +/* PRUint32 mark (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in voidPtr arg); */ NS_IMETHODIMP -mozStorageStatementWrapper::Trace(nsIXPConnectWrappedNative *wrapper, - JSTracer *trc, JSObject *obj) +mozStorageStatementWrapper::Mark(nsIXPConnectWrappedNative *wrapper, JSContext * cx, + JSObject * obj, void * arg, PRUint32 *_retval) { return NS_ERROR_NOT_IMPLEMENTED; } @@ -718,10 +718,10 @@ mozStorageStatementRow::HasInstance(nsIXPConnectWrappedNative *wrapper, JSContex return NS_ERROR_NOT_IMPLEMENTED; } -/* void trace (in nsIXPConnectWrappedNative wrapper, in JSTracerPtr trc, in JSObjectPtr obj); */ +/* PRUint32 mark (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in voidPtr arg); */ NS_IMETHODIMP -mozStorageStatementRow::Trace(nsIXPConnectWrappedNative *wrapper, - JSTracer * trc, JSObject * obj) +mozStorageStatementRow::Mark(nsIXPConnectWrappedNative *wrapper, JSContext * cx, + JSObject * obj, void * arg, PRUint32 *_retval) { return NS_ERROR_NOT_IMPLEMENTED; } @@ -1001,10 +1001,10 @@ mozStorageStatementParams::HasInstance(nsIXPConnectWrappedNative *wrapper, JSCon return NS_ERROR_NOT_IMPLEMENTED; } -/* void trace (in nsIXPConnectWrappedNative wrapper, in JSTracerPtr trc, in JSObjectPtr obj); */ +/* PRUint32 mark (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in voidPtr arg); */ NS_IMETHODIMP -mozStorageStatementParams::Trace(nsIXPConnectWrappedNative *wrapper, - JSTracer *trc, JSObject * obj) +mozStorageStatementParams::Mark(nsIXPConnectWrappedNative *wrapper, JSContext * cx, + JSObject * obj, void * arg, PRUint32 *_retval) { return NS_ERROR_NOT_IMPLEMENTED; }