Bug 716176 - Trigger write barriers when copying BaseShapes; r=billm
authorTerrence Cole <terrence@mozilla.com>
Mon, 09 Jan 2012 16:08:24 -0800
changeset 85296 6a0de913a0429d0aae8518e5de030a72859afa9c
parent 85295 b4778618b053c04fb8a99bdfde3c7626146b2c50
child 85297 2676737a824ce68d5a802a3240c10c6087b0f631
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs716176
milestone12.0a1
Bug 716176 - Trigger write barriers when copying BaseShapes; r=billm Since getterObj and setterObj are hidden beneath unions, we need to manually trigger their barriers.
js/src/jsscope.h
js/src/jsscopeinlines.h
--- a/js/src/jsscope.h
+++ b/js/src/jsscope.h
@@ -336,16 +336,18 @@ class BaseShape : public js::gc::Cell
     inline BaseShape(Class *clasp, JSObject *parent, uint32_t objectFlags);
     inline BaseShape(Class *clasp, JSObject *parent, uint32_t objectFlags,
                      uint8_t attrs, PropertyOp rawGetter, StrictPropertyOp rawSetter);
     inline BaseShape(const StackBaseShape &base);
 
     /* Not defined: BaseShapes must not be stack allocated. */
     ~BaseShape();
 
+    inline BaseShape &operator=(const BaseShape &other);
+
     bool isOwned() const { return !!(flags & OWNED_SHAPE); }
 
     inline bool matchesGetterSetter(PropertyOp rawGetter,
                                     StrictPropertyOp rawSetter) const;
 
     inline void adoptUnowned(UnownedBaseShape *other);
     inline void setOwned(UnownedBaseShape *unowned);
 
--- a/js/src/jsscopeinlines.h
+++ b/js/src/jsscopeinlines.h
@@ -107,16 +107,38 @@ BaseShape::BaseShape(const StackBaseShap
     if ((base.flags & HAS_GETTER_OBJECT) && base.rawGetter) {
         JSObject::writeBarrierPost(this->getterObj, &this->getterObj);
     }
     if ((base.flags & HAS_SETTER_OBJECT) && base.rawSetter) {
         JSObject::writeBarrierPost(this->setterObj, &this->setterObj);
     }
 }
 
+inline BaseShape &
+BaseShape::operator=(const BaseShape &other)
+{
+    clasp = other.clasp;
+    parent = other.parent;
+    flags = other.flags;
+    slotSpan_ = other.slotSpan_;
+    if (flags & HAS_GETTER_OBJECT) {
+        getterObj = other.getterObj;
+        JSObject::writeBarrierPost(getterObj, &getterObj);
+    } else {
+        rawGetter = other.rawGetter;
+    }
+    if (flags & HAS_SETTER_OBJECT) {
+        setterObj = other.setterObj;
+        JSObject::writeBarrierPost(setterObj, &setterObj);
+    } else {
+        rawSetter = other.rawSetter;
+    }
+    return *this;
+}
+
 inline bool
 BaseShape::matchesGetterSetter(PropertyOp rawGetter, StrictPropertyOp rawSetter) const
 {
     return rawGetter == this->rawGetter && rawSetter == this->rawSetter;
 }
 
 inline
 StackBaseShape::StackBaseShape(Shape *shape)