Bug 1340482 - Trace shape for shaped but non-native objects. r=sfink
authorJon Coppeard <jcoppeard@mozilla.com>
Mon, 20 Mar 2017 18:13:19 -0400
changeset 501799 846948a41b6c25bf5488b761e716d521c99cbf7f
parent 501798 112d7a5b1a0d3e673e3a434a99d9a99842f0850c
child 501800 c2f5bc87d8cd577a13a96a8a4c50cd482600a6cf
push id50127
push userna-g@nostrum.com
push dateTue, 21 Mar 2017 00:09:45 +0000
reviewerssfink
bugs1340482
milestone55.0a1
Bug 1340482 - Trace shape for shaped but non-native objects. r=sfink
js/src/jsobj.cpp
js/src/vm/ShapedObject.h
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -3874,22 +3874,23 @@ JS::ubi::Concrete<JSObject>::size(mozill
 
 const char16_t JS::ubi::Concrete<JSObject>::concreteTypeName[] = u"JSObject";
 
 void
 JSObject::traceChildren(JSTracer* trc)
 {
     TraceEdge(trc, &group_, "group");
 
+    if (is<ShapedObject>())
+        as<ShapedObject>().traceShape(trc);
+
     const Class* clasp = group_->clasp();
     if (clasp->isNative()) {
         NativeObject* nobj = &as<NativeObject>();
 
-        TraceEdge(trc, &nobj->shape_, "shape");
-
         {
             GetObjectSlotNameFunctor func(nobj);
             JS::AutoTracingDetails ctx(trc, func);
             JS::AutoTracingIndex index(trc);
             // Tracing can mutate the target but cannot change the slot count,
             // but the compiler has no way of knowing this.
             const uint32_t nslots = nobj->slotSpan();
             for (uint32_t i = 0; i < nslots; ++i) {
--- a/js/src/vm/ShapedObject.h
+++ b/js/src/vm/ShapedObject.h
@@ -34,16 +34,20 @@ class ShapedObject : public JSObject
     }
 
     void setShape(Shape* shape) {
         this->shape_ = shape;
     }
 
     Shape* shape() const { return this->shape_; }
 
+    void traceShape(JSTracer* trc) {
+        TraceEdge(trc, &shape_, "shape");
+    }
+
     static size_t offsetOfShape() { return offsetof(ShapedObject, shape_); }
 
   private:
     static void staticAsserts() {
         static_assert(offsetof(ShapedObject, shape_) == offsetof(shadow::Object, shape),
                       "shadow shape must match actual shape");
     }
 };