From a2eed15990d40e0376bd74255bb8e6d8fc95c02a Mon Sep 17 00:00:00 2001 From: Jon Coppeard Date: Tue, 18 Jun 2013 11:00:38 +0100 Subject: [PATCH] Bug 877762 - GC: Post-barrier cycle collector participants - 6 Convert jsid and JS::String to use Heap r=smaug --- dom/base/nsJSTimeoutHandler.cpp | 7 ++++--- js/xpconnect/src/XPCJSRuntime.cpp | 8 ++++---- xpcom/glue/nsCycleCollectionParticipant.cpp | 4 ++-- xpcom/glue/nsCycleCollectionParticipant.h | 12 ++++-------- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/dom/base/nsJSTimeoutHandler.cpp b/dom/base/nsJSTimeoutHandler.cpp index 4b7a083ed8f..24fbc359ca6 100644 --- a/dom/base/nsJSTimeoutHandler.cpp +++ b/dom/base/nsJSTimeoutHandler.cpp @@ -70,7 +70,8 @@ private: nsTArray > mArgs; // The JS expression to evaluate or function to call, if !mExpr - JSFlatString *mExpr; + // Note this is always a flat string. + JS::Heap mExpr; nsRefPtr mFunction; }; @@ -281,7 +282,7 @@ nsJSScriptTimeoutHandler::Init(nsGlobalWindow *aWindow, bool *aIsInterval, NS_HOLD_JS_OBJECTS(this, nsJSScriptTimeoutHandler); - mExpr = expr; + mExpr = JS_FORGET_STRING_FLATNESS(expr); // Get the calling location. const char *filename; @@ -320,7 +321,7 @@ const PRUnichar * nsJSScriptTimeoutHandler::GetHandlerText() { NS_ASSERTION(mExpr, "No expression, so no handler text!"); - return ::JS_GetFlatStringChars(mExpr); + return ::JS_GetFlatStringChars(JS_ASSERT_STRING_IS_FLAT(mExpr)); } nsresult NS_CreateJSTimeoutHandler(nsGlobalWindow *aWindow, diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index 26a79bdf9d4..c7a942084ad 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -506,14 +506,14 @@ struct JsGcTracer : public TraceCallbacks virtual void Trace(JS::Heap *p, const char *name, void *closure) const MOZ_OVERRIDE { JS_CallHeapValueTracer(static_cast(closure), p, name); } - virtual void Trace(jsid *p, const char *name, void *closure) const MOZ_OVERRIDE { - JS_CallIdTracer(static_cast(closure), p, name); + virtual void Trace(JS::Heap *p, const char *name, void *closure) const MOZ_OVERRIDE { + JS_CallHeapIdTracer(static_cast(closure), p, name); } virtual void Trace(JSObject **p, const char *name, void *closure) const MOZ_OVERRIDE { JS_CallObjectTracer(static_cast(closure), p, name); } - virtual void Trace(JSString **p, const char *name, void *closure) const MOZ_OVERRIDE { - JS_CallStringTracer(static_cast(closure), p, name); + virtual void Trace(JS::Heap*p, const char *name, void *closure) const MOZ_OVERRIDE { + JS_CallHeapStringTracer(static_cast(closure), p, name); } virtual void Trace(JS::Heap *p, const char *name, void *closure) const MOZ_OVERRIDE { JS_CallHeapScriptTracer(static_cast(closure), p, name); diff --git a/xpcom/glue/nsCycleCollectionParticipant.cpp b/xpcom/glue/nsCycleCollectionParticipant.cpp index 1789a79f54d..c03a4117669 100644 --- a/xpcom/glue/nsCycleCollectionParticipant.cpp +++ b/xpcom/glue/nsCycleCollectionParticipant.cpp @@ -75,7 +75,7 @@ TraceCallbackFunc::Trace(JS::Heap* p, const char* name, void* closure } void -TraceCallbackFunc::Trace(jsid* p, const char* name, void* closure) const +TraceCallbackFunc::Trace(JS::Heap* p, const char* name, void* closure) const { void *thing = JSID_TO_GCTHING(*p); if (thing) { @@ -90,7 +90,7 @@ TraceCallbackFunc::Trace(JSObject** p, const char* name, void* closure) const } void -TraceCallbackFunc::Trace(JSString** p, const char* name, void* closure) const +TraceCallbackFunc::Trace(JS::Heap* p, const char* name, void* closure) const { mCallback(*p, name, closure); } diff --git a/xpcom/glue/nsCycleCollectionParticipant.h b/xpcom/glue/nsCycleCollectionParticipant.h index 1923abf5ec6..e8f3e607a70 100644 --- a/xpcom/glue/nsCycleCollectionParticipant.h +++ b/xpcom/glue/nsCycleCollectionParticipant.h @@ -63,14 +63,10 @@ template class Heap; struct TraceCallbacks { virtual void Trace(JS::Heap* p, const char* name, void* closure) const = 0; - virtual void Trace(jsid* p, const char* name, void* closure) const = 0; + virtual void Trace(JS::Heap* p, const char* name, void* closure) const = 0; virtual void Trace(JSObject** p, const char* name, void* closure) const = 0; - virtual void Trace(JSString** p, const char* name, void* closure) const = 0; + virtual void Trace(JS::Heap* p, const char* name, void* closure) const = 0; virtual void Trace(JS::Heap* p, const char* name, void* closure) const = 0; - - void Trace(JSFlatString** p, const char* name, void* closure) const { - Trace(reinterpret_cast(p), name, closure); - } }; /* @@ -84,9 +80,9 @@ struct TraceCallbackFunc : public TraceCallbacks explicit TraceCallbackFunc(Func cb) : mCallback(cb) {} virtual void Trace(JS::Heap* p, const char* name, void* closure) const MOZ_OVERRIDE; - virtual void Trace(jsid* p, const char* name, void* closure) const MOZ_OVERRIDE; + virtual void Trace(JS::Heap* p, const char* name, void* closure) const MOZ_OVERRIDE; virtual void Trace(JSObject** p, const char* name, void* closure) const MOZ_OVERRIDE; - virtual void Trace(JSString** p, const char* name, void* closure) const MOZ_OVERRIDE; + virtual void Trace(JS::Heap* p, const char* name, void* closure) const MOZ_OVERRIDE; virtual void Trace(JS::Heap* p, const char* name, void* closure) const MOZ_OVERRIDE; private: