Bug 877762 - GC: Post-barrier cycle collector participants - 6 Convert jsid and JS::String to use Heap<T> r=smaug
authorJon Coppeard <jcoppeard@mozilla.com>
Tue, 18 Jun 2013 11:00:38 +0100
changeset 135409 9fba4a49aa71ba00f5b557be53a4d30e634fc236
parent 135408 e71598bf972312dab776437686e41fcd4256f28d
child 135410 f6d53e1cde69f62305640e59440aabc4a643bc17
push id29656
push userjcoppeard@mozilla.com
push dateTue, 18 Jun 2013 10:04:29 +0000
treeherdermozilla-inbound@047741328e5a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs877762
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 877762 - GC: Post-barrier cycle collector participants - 6 Convert jsid and JS::String to use Heap<T> r=smaug
dom/base/nsJSTimeoutHandler.cpp
js/xpconnect/src/XPCJSRuntime.cpp
xpcom/glue/nsCycleCollectionParticipant.cpp
xpcom/glue/nsCycleCollectionParticipant.h
--- a/dom/base/nsJSTimeoutHandler.cpp
+++ b/dom/base/nsJSTimeoutHandler.cpp
@@ -65,17 +65,18 @@ public:
 private:
   // filename, line number and JS language version string of the
   // caller of setTimeout()
   nsCString mFileName;
   uint32_t mLineNo;
   nsTArray<JS::Heap<JS::Value> > mArgs;
 
   // The JS expression to evaluate or function to call, if !mExpr
-  JSFlatString *mExpr;
+  // Note this is always a flat string.
+  JS::Heap<JSString*> mExpr;
   nsRefPtr<Function> mFunction;
 };
 
 
 // nsJSScriptTimeoutHandler
 // QueryInterface implementation for nsJSScriptTimeoutHandler
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsJSScriptTimeoutHandler)
   tmp->ReleaseJSObjects();
@@ -276,17 +277,17 @@ nsJSScriptTimeoutHandler::Init(nsGlobalW
           // Note: Our only caller knows to turn NS_ERROR_DOM_TYPE_ERR into NS_OK.
           return NS_ERROR_DOM_TYPE_ERR;
         }
       }
     } // if there's no document, we don't have to do anything.
 
     NS_HOLD_JS_OBJECTS(this, nsJSScriptTimeoutHandler);
 
-    mExpr = expr;
+    mExpr = JS_FORGET_STRING_FLATNESS(expr);
 
     // Get the calling location.
     const char *filename;
     if (nsJSUtils::GetCallingLocation(cx, &filename, &mLineNo)) {
       mFileName.Assign(filename);
     }
   } else if (funobj) {
     NS_HOLD_JS_OBJECTS(this, nsJSScriptTimeoutHandler);
@@ -315,17 +316,17 @@ nsJSScriptTimeoutHandler::Init(nsGlobalW
   *aInterval = interval;
   return NS_OK;
 }
 
 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,
                                    bool *aIsInterval,
                                    int32_t *aInterval,
                                    nsIScriptTimeoutHandler **aRet)
 {
   *aRet = nullptr;
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -501,24 +501,24 @@ void XPCJSRuntime::TraceGrayJS(JSTracer*
     self->TraceXPConnectRoots(trc);
 }
 
 struct JsGcTracer : public TraceCallbacks
 {
     virtual void Trace(JS::Heap<JS::Value> *p, const char *name, void *closure) const MOZ_OVERRIDE {
         JS_CallHeapValueTracer(static_cast<JSTracer*>(closure), p, name);
     }
-    virtual void Trace(jsid *p, const char *name, void *closure) const MOZ_OVERRIDE {
-        JS_CallIdTracer(static_cast<JSTracer*>(closure), p, name);
+    virtual void Trace(JS::Heap<jsid> *p, const char *name, void *closure) const MOZ_OVERRIDE {
+        JS_CallHeapIdTracer(static_cast<JSTracer*>(closure), p, name);
     }
     virtual void Trace(JSObject **p, const char *name, void *closure) const MOZ_OVERRIDE {
         JS_CallObjectTracer(static_cast<JSTracer*>(closure), p, name);
     }
-    virtual void Trace(JSString **p, const char *name, void *closure) const MOZ_OVERRIDE {
-        JS_CallStringTracer(static_cast<JSTracer*>(closure), p, name);
+    virtual void Trace(JS::Heap<JSString *>*p, const char *name, void *closure) const MOZ_OVERRIDE {
+        JS_CallHeapStringTracer(static_cast<JSTracer*>(closure), p, name);
     }
     virtual void Trace(JS::Heap<JSScript *> *p, const char *name, void *closure) const MOZ_OVERRIDE {
         JS_CallHeapScriptTracer(static_cast<JSTracer*>(closure), p, name);
     }
 };
 
 static PLDHashOperator
 TraceJSHolder(void *holder, nsScriptObjectTracer *&tracer, void *arg)
--- a/xpcom/glue/nsCycleCollectionParticipant.cpp
+++ b/xpcom/glue/nsCycleCollectionParticipant.cpp
@@ -70,32 +70,32 @@ CycleCollectionNoteEdgeNameImpl(nsCycleC
 
 void
 TraceCallbackFunc::Trace(JS::Heap<JS::Value>* p, const char* name, void* closure) const
 {
   mCallback(JSVAL_TO_TRACEABLE(p->get()), name, closure);
 }
 
 void
-TraceCallbackFunc::Trace(jsid* p, const char* name, void* closure) const
+TraceCallbackFunc::Trace(JS::Heap<jsid>* p, const char* name, void* closure) const
 {
   void *thing = JSID_TO_GCTHING(*p);
   if (thing) {
     mCallback(thing, name, closure);
   }
 }
 
 void
 TraceCallbackFunc::Trace(JSObject** p, const char* name, void* closure) const
 {
   mCallback(*p, name, closure);
 }
 
 void
-TraceCallbackFunc::Trace(JSString** p, const char* name, void* closure) const
+TraceCallbackFunc::Trace(JS::Heap<JSString*>* p, const char* name, void* closure) const
 {
   mCallback(*p, name, closure);
 }
 
 void
 TraceCallbackFunc::Trace(JS::Heap<JSScript*>* p, const char* name, void* closure) const
 {
   mCallback(p->get(), name, closure);
--- a/xpcom/glue/nsCycleCollectionParticipant.h
+++ b/xpcom/glue/nsCycleCollectionParticipant.h
@@ -58,40 +58,36 @@ template <class T> class Heap;
 /*
  * A struct defining pure virtual methods which are called when tracing cycle
  * collection paticipants.  The appropriate method is called depending on the
  * type of JS GC thing.
  */
 struct TraceCallbacks
 {
     virtual void Trace(JS::Heap<JS::Value>* 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<jsid>* 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<JSString*>* p, const char* name, void* closure) const = 0;
     virtual void Trace(JS::Heap<JSScript*>* p, const char* name, void* closure) const = 0;
-
-    void Trace(JSFlatString** p, const char* name, void* closure) const {
-        Trace(reinterpret_cast<JSString**>(p), name, closure);
-    }
 };
 
 /*
  * An implementation of TraceCallbacks that calls a single function for all JS
  * GC thing types encountered.
  */
 struct TraceCallbackFunc : public TraceCallbacks
 {
     typedef void (* Func)(void* p, const char* name, void* closure);
 
     explicit TraceCallbackFunc(Func cb) : mCallback(cb) {}
 
     virtual void Trace(JS::Heap<JS::Value>* 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<jsid>* 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<JSString*>* p, const char* name, void* closure) const MOZ_OVERRIDE;
     virtual void Trace(JS::Heap<JSScript*>* p, const char* name, void* closure) const MOZ_OVERRIDE;
 
   private:
     Func mCallback;
 };
 
 /**
  * VTables