Bug 994413 - Make Gecko use the same value marking semantics as SpiderMonkey; r=jonco,mccr8
authorTerrence Cole <terrence@mozilla.com>
Wed, 09 Apr 2014 12:42:48 -0700
changeset 179053 0312954d8974c1bd8075ce11d9203f69a7a3337e
parent 179052 fcb4575e90d9bf72c7fd12a17e2423760ac61570
child 179054 64119cdee9522ccb5a0692aede1c5f1bebd69e77
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersjonco, mccr8
bugs994413
milestone31.0a1
Bug 994413 - Make Gecko use the same value marking semantics as SpiderMonkey; r=jonco,mccr8
dom/base/Console.cpp
xpcom/base/nsCycleCollector.cpp
xpcom/glue/nsCycleCollectionParticipant.cpp
xpcom/glue/nsCycleCollectionParticipant.h
--- a/dom/base/Console.cpp
+++ b/dom/base/Console.cpp
@@ -502,19 +502,17 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(Con
 
   for (ConsoleCallData* data = tmp->mQueuedCalls.getFirst(); data != nullptr;
        data = data->getNext()) {
     if (data->mGlobal) {
       aCallbacks.Trace(&data->mGlobal, "data->mGlobal", aClosure);
     }
 
     for (uint32_t i = 0; i < data->mArguments.Length(); ++i) {
-      if (JSVAL_IS_TRACEABLE(data->mArguments[i])) {
-        aCallbacks.Trace(&data->mArguments[i], "data->mArguments[i]", aClosure);
-      }
+      aCallbacks.Trace(&data->mArguments[i], "data->mArguments[i]", aClosure);
     }
   }
 
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(Console)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(Console)
 
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -2406,19 +2406,21 @@ public:
     bool HasSnowWhiteObjects() const
     {
       return mObjects.Length() > 0;
     }
 
     virtual void Trace(JS::Heap<JS::Value>* aValue, const char* aName,
                        void* aClosure) const
     {
-        void* thing = JSVAL_TO_TRACEABLE(aValue->get());
-        if (thing && xpc_GCThingIsGrayCCThing(thing)) {
-            mCollector->GetJSPurpleBuffer()->mValues.AppendElement(*aValue);
+        if (aValue->isMarkable()) {
+            void* thing = aValue->toGCThing();
+            if (thing && xpc_GCThingIsGrayCCThing(thing)) {
+                mCollector->GetJSPurpleBuffer()->mValues.AppendElement(*aValue);
+            }
         }
     }
 
     virtual void Trace(JS::Heap<jsid>* aId, const char* aName,
                        void* aClosure) const
     {
     }
 
--- a/xpcom/glue/nsCycleCollectionParticipant.cpp
+++ b/xpcom/glue/nsCycleCollectionParticipant.cpp
@@ -64,17 +64,19 @@ CycleCollectionNoteEdgeNameImpl(nsCycleC
     arrayEdgeName.AppendLiteral("[i]");
   }
   aCallback.NoteNextEdgeName(arrayEdgeName.get());
 }
 
 void
 TraceCallbackFunc::Trace(JS::Heap<JS::Value>* p, const char* name, void* closure) const
 {
-  mCallback(JSVAL_TO_TRACEABLE(p->get()), name, closure);
+  if (p->isMarkable()) {
+    mCallback(p->toGCThing(), name, closure);
+  }
 }
 
 void
 TraceCallbackFunc::Trace(JS::Heap<jsid>* p, const char* name, void* closure) const
 {
   void *thing = JSID_TO_GCTHING(*p);
   if (thing) {
     mCallback(thing, name, closure);
--- a/xpcom/glue/nsCycleCollectionParticipant.h
+++ b/xpcom/glue/nsCycleCollectionParticipant.h
@@ -424,19 +424,17 @@ T* DowncastCCParticipant(void *p)
     nsISupports *s = static_cast<nsISupports*>(p);                             \
     NS_CYCLE_COLLECTION_CLASSNAME(_base_class)::Trace(s, aCallbacks, aClosure);
 
 #define NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(_field)              \
   if (tmp->_field)                                                             \
     aCallbacks.Trace(&tmp->_field, #_field, aClosure);
 
 #define NS_IMPL_CYCLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK(_field)           \
-  if (JSVAL_IS_TRACEABLE(tmp->_field)) {                                       \
-    aCallbacks.Trace(&tmp->_field, #_field, aClosure);                         \
-  }
+  aCallbacks.Trace(&tmp->_field, #_field, aClosure);
 
 // NB: The (void)tmp; hack in the TRACE_END macro exists to support
 // implementations that don't need to do anything in their Trace method.
 // Without this hack, some compilers warn about the unused tmp local.
 #define NS_IMPL_CYCLE_COLLECTION_TRACE_END                                     \
       (void)tmp;                                                               \
   }