Bug 815454 - Clean up Traverse/Unlink of web audio. r=smaug
authorAndrew McCreight <amccreight@mozilla.com>
Tue, 27 Nov 2012 15:08:22 -0800
changeset 114304 795294e974850ca4abe9574072ea3677dc71776a
parent 114303 b412fee450e2857387bc2d596aa8976d12c5673a
child 114305 03e4b50b8d236be52081b0ea5f89203356ba37b7
push id23913
push useremorley@mozilla.com
push dateWed, 28 Nov 2012 17:11:31 +0000
treeherdermozilla-central@17c267a881cf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs815454
milestone20.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 815454 - Clean up Traverse/Unlink of web audio. r=smaug
content/media/webaudio/AudioNode.cpp
content/media/webaudio/AudioNode.h
content/media/webaudio/BiquadFilterNode.cpp
content/media/webaudio/DelayNode.cpp
content/media/webaudio/DynamicsCompressorNode.cpp
content/media/webaudio/GainNode.cpp
content/media/webaudio/PannerNode.cpp
content/media/webaudio/PannerNode.h
--- a/content/media/webaudio/AudioNode.cpp
+++ b/content/media/webaudio/AudioNode.cpp
@@ -7,46 +7,36 @@
 #include "AudioNode.h"
 #include "AudioContext.h"
 #include "nsContentUtils.h"
 #include "mozilla/ErrorResult.h"
 
 namespace mozilla {
 namespace dom {
 
-template <typename T>
-static void
-TraverseElements(nsCycleCollectionTraversalCallback& cb,
-                 const nsTArray<T>& array,
-                 const char* name)
+inline void
+ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
+                            mozilla::dom::AudioNode::Output& aField,
+                            const char* aName,
+                            unsigned aFlags)
 {
-  for (uint32_t i = 0, length = array.Length(); i < length; ++i) {
-    NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, name);
-    AudioNode* node = array[i].get();
-    cb.NoteXPCOMChild(node);
-  }
+  CycleCollectionNoteChild(aCallback, aField.mDestination.get(), aName, aFlags);
 }
 
-NS_IMPL_CYCLE_COLLECTION_CLASS(AudioNode)
-
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(AudioNode)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mContext)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mInputs)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mOutputs)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
-NS_IMPL_CYCLE_COLLECTION_UNLINK_END
+inline void
+ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
+                            mozilla::dom::AudioNode::Input& aField,
+                            const char* aName,
+                            unsigned aFlags)
+{
+  CycleCollectionNoteChild(aCallback, aField.mSource.get(), aName, aFlags);
+}
 
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(AudioNode)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mContext)
-  TraverseElements(cb, tmp->mInputs, "mInputs[i]");
-  TraverseElements(cb, tmp->mOutputs, "mOutputs[i]");
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
-
-NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(AudioNode)
+NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_3(AudioNode,
+                                        mContext, mInputs, mOutputs)
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(AudioNode)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(AudioNode)
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(AudioNode)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
--- a/content/media/webaudio/AudioNode.h
+++ b/content/media/webaudio/AudioNode.h
@@ -76,21 +76,16 @@ public:
     }
 
     // Check whether the slot is valid
     typedef void**** ConvertibleToBool;
     operator ConvertibleToBool() const {
       return ConvertibleToBool(mDestination && mInput != InvalidIndex);
     }
 
-    // Needed for the CC traversal
-    AudioNode* get() const {
-      return mDestination;
-    }
-
     nsRefPtr<AudioNode> mDestination;
     // This is an index into mDestination->mInputs which specifies the Input
     // object corresponding to this Output node.
     const uint32_t mInput;
   };
   struct Input {
     enum { InvalidIndex = 0xffffffff };
     Input()
@@ -104,30 +99,24 @@ public:
     }
 
     // Check whether the slot is valid
     typedef void**** ConvertibleToBool;
     operator ConvertibleToBool() const {
       return ConvertibleToBool(mSource && mOutput != InvalidIndex);
     }
 
-    // Needed for the CC traversal
-    AudioNode* get() const {
-      return mSource;
-    }
-
     nsRefPtr<AudioNode> mSource;
     // This is an index into mSource->mOutputs which specifies the Output
     // object corresponding to this Input node.
     const uint32_t mOutput;
   };
 
 private:
   nsRefPtr<AudioContext> mContext;
   nsTArray<Input> mInputs;
   nsTArray<Output> mOutputs;
 };
 
 }
 }
 
 #endif
-
--- a/content/media/webaudio/BiquadFilterNode.cpp
+++ b/content/media/webaudio/BiquadFilterNode.cpp
@@ -5,27 +5,18 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "BiquadFilterNode.h"
 #include "mozilla/dom/BiquadFilterNodeBinding.h"
 
 namespace mozilla {
 namespace dom {
 
-NS_IMPL_CYCLE_COLLECTION_CLASS(BiquadFilterNode)
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(BiquadFilterNode, AudioNode)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mFrequency)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mQ)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mGain)
-NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(BiquadFilterNode, AudioNode)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFrequency)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mQ)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGain)
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
+NS_IMPL_CYCLE_COLLECTION_INHERITED_3(BiquadFilterNode, AudioNode,
+                                     mFrequency, mQ, mGain)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(BiquadFilterNode)
 NS_INTERFACE_MAP_END_INHERITING(AudioNode)
 
 NS_IMPL_ADDREF_INHERITED(BiquadFilterNode, AudioNode)
 NS_IMPL_RELEASE_INHERITED(BiquadFilterNode, AudioNode)
 
 static float
--- a/content/media/webaudio/DelayNode.cpp
+++ b/content/media/webaudio/DelayNode.cpp
@@ -5,23 +5,18 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "DelayNode.h"
 #include "mozilla/dom/DelayNodeBinding.h"
 
 namespace mozilla {
 namespace dom {
 
-NS_IMPL_CYCLE_COLLECTION_CLASS(DelayNode)
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(DelayNode, AudioNode)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mDelay)
-NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(DelayNode, AudioNode)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDelay)
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
+NS_IMPL_CYCLE_COLLECTION_INHERITED_1(DelayNode, AudioNode,
+                                     mDelay)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(DelayNode)
 NS_INTERFACE_MAP_END_INHERITING(AudioNode)
 
 NS_IMPL_ADDREF_INHERITED(DelayNode, AudioNode)
 NS_IMPL_RELEASE_INHERITED(DelayNode, AudioNode)
 
 DelayNode::DelayNode(AudioContext* aContext, double aMaxDelay)
--- a/content/media/webaudio/DynamicsCompressorNode.cpp
+++ b/content/media/webaudio/DynamicsCompressorNode.cpp
@@ -5,33 +5,23 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "DynamicsCompressorNode.h"
 #include "mozilla/dom/DynamicsCompressorNodeBinding.h"
 
 namespace mozilla {
 namespace dom {
 
-NS_IMPL_CYCLE_COLLECTION_CLASS(DynamicsCompressorNode)
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(DynamicsCompressorNode, AudioNode)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mThreshold)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mKnee)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mRatio)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mReduction)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mAttack)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mRelease)
-NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(DynamicsCompressorNode, AudioNode)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mThreshold)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mKnee)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRatio)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mReduction)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAttack)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRelease)
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
+NS_IMPL_CYCLE_COLLECTION_INHERITED_6(DynamicsCompressorNode, AudioNode,
+                                     mThreshold,
+                                     mKnee,
+                                     mRatio,
+                                     mReduction,
+                                     mAttack,
+                                     mRelease)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(DynamicsCompressorNode)
 NS_INTERFACE_MAP_END_INHERITING(AudioNode)
 
 NS_IMPL_ADDREF_INHERITED(DynamicsCompressorNode, AudioNode)
 NS_IMPL_RELEASE_INHERITED(DynamicsCompressorNode, AudioNode)
 
 DynamicsCompressorNode::DynamicsCompressorNode(AudioContext* aContext)
--- a/content/media/webaudio/GainNode.cpp
+++ b/content/media/webaudio/GainNode.cpp
@@ -5,23 +5,18 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "GainNode.h"
 #include "mozilla/dom/GainNodeBinding.h"
 
 namespace mozilla {
 namespace dom {
 
-NS_IMPL_CYCLE_COLLECTION_CLASS(GainNode)
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(GainNode, AudioNode)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mGain)
-NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(GainNode, AudioNode)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGain)
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
+NS_IMPL_CYCLE_COLLECTION_INHERITED_1(GainNode, AudioNode,
+                                     mGain)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(GainNode)
 NS_INTERFACE_MAP_END_INHERITING(AudioNode)
 
 NS_IMPL_ADDREF_INHERITED(GainNode, AudioNode)
 NS_IMPL_RELEASE_INHERITED(GainNode, AudioNode)
 
 GainNode::GainNode(AudioContext* aContext)
--- a/content/media/webaudio/PannerNode.cpp
+++ b/content/media/webaudio/PannerNode.cpp
@@ -5,28 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "PannerNode.h"
 #include "mozilla/dom/PannerNodeBinding.h"
 
 namespace mozilla {
 namespace dom {
 
-NS_IMPL_CYCLE_COLLECTION_CLASS(PannerNode)
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(PannerNode, AudioNode)
-NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(PannerNode, AudioNode)
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(PannerNode)
-NS_INTERFACE_MAP_END_INHERITING(AudioNode)
-
-NS_IMPL_ADDREF_INHERITED(PannerNode, AudioNode)
-NS_IMPL_RELEASE_INHERITED(PannerNode, AudioNode)
-
 PannerNode::PannerNode(AudioContext* aContext)
   : AudioNode(aContext)
   , mPanningModel(PanningModelEnum::HRTF)
   , mDistanceModel(DistanceModelEnum::INVERSE_DISTANCE)
   , mPosition()
   , mOrientation(1.f, 0.f, 0.f)
   , mVelocity()
   , mRefDistance(1.f)
--- a/content/media/webaudio/PannerNode.h
+++ b/content/media/webaudio/PannerNode.h
@@ -31,19 +31,16 @@ MOZ_BEGIN_ENUM_CLASS(DistanceModelEnum, 
   Max = 2
 MOZ_END_ENUM_CLASS(DistanceModelEnum)
 
 class PannerNode : public AudioNode
 {
 public:
   explicit PannerNode(AudioContext* aContext);
 
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PannerNode, AudioNode)
-
   virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope,
                                bool* aTriedToWrap);
 
   virtual uint32_t MaxNumberOfInputs() const MOZ_FINAL MOZ_OVERRIDE
   {
     return 1;
   }
   virtual uint32_t MaxNumberOfOutputs() const MOZ_FINAL MOZ_OVERRIDE