Bug 1378736 part 1 - Don't null out RegExpObject -> RegExpShared pointer on GC. r=jonco
authorJan de Mooij <jdemooij@mozilla.com>
Fri, 07 Jul 2017 16:56:24 +0200
changeset 367788 6561b74cec5c7a0be7391d56a651baefee943d5a
parent 367787 d2f388860d3d74ed8dfa89cf260089a41941c06b
child 367789 8a1f2f23edb0242e98954d0f1eea98d916e6a7e1
push id32146
push userkwierso@gmail.com
push dateFri, 07 Jul 2017 22:59:03 +0000
treeherdermozilla-central@c45f1aa05c4d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1378736
milestone56.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 1378736 part 1 - Don't null out RegExpObject -> RegExpShared pointer on GC. r=jonco
js/src/vm/RegExpObject.cpp
js/src/vm/RegExpObject.h
--- a/js/src/vm/RegExpObject.cpp
+++ b/js/src/vm/RegExpObject.cpp
@@ -173,21 +173,16 @@ IsMarkingTrace(JSTracer* trc)
     //      CurrentThreadIsHeapBusy() will be false.
 
     return JS::CurrentThreadIsHeapCollecting() && trc->isMarkingTracer();
 }
 
 void
 RegExpObject::trace(JSTracer* trc)
 {
-    // When marking the object normally we have the option of unlinking the
-    // object from its RegExpShared so that the RegExpShared may be collected.
-    if (IsMarkingTrace(trc) && !zone()->isPreservingCode())
-        sharedRef() = nullptr;
-
     TraceNullableEdge(trc, &sharedRef(), "RegExpObject shared");
 }
 
 static JSObject*
 CreateRegExpPrototype(JSContext* cx, JSProtoKey key)
 {
     return GlobalObject::createBlankPrototype(cx, cx->global(), &RegExpObject::protoClass_);
 }
--- a/js/src/vm/RegExpObject.h
+++ b/js/src/vm/RegExpObject.h
@@ -147,17 +147,17 @@ class RegExpObject : public NativeObject
                                        MutableHandleRegExpShared shared);
 
     bool hasShared() {
         return !!sharedRef();
     }
 
     void setShared(RegExpShared& shared) {
         MOZ_ASSERT(!hasShared());
-        sharedRef() = &shared;
+        sharedRef().init(&shared);
     }
 
     static void trace(JSTracer* trc, JSObject* obj);
     void trace(JSTracer* trc);
 
     void initIgnoringLastIndex(HandleAtom source, RegExpFlag flags);
 
     // NOTE: This method is *only* safe to call on RegExps that haven't been
@@ -173,19 +173,19 @@ class RegExpObject : public NativeObject
   private:
     /*
      * Precondition: the syntax for |source| has already been validated.
      * Side effect: sets the private field.
      */
     static MOZ_MUST_USE bool createShared(JSContext* cx, Handle<RegExpObject*> regexp,
                                           MutableHandleRegExpShared shared);
 
-    ReadBarriered<RegExpShared*>& sharedRef() {
+    PreBarriered<RegExpShared*>& sharedRef() {
         auto& ref = NativeObject::privateRef(PRIVATE_SLOT);
-        return reinterpret_cast<ReadBarriered<RegExpShared*>&>(ref);
+        return reinterpret_cast<PreBarriered<RegExpShared*>&>(ref);
     }
 
     /* Call setShared in preference to setPrivate. */
     void setPrivate(void* priv) = delete;
 };
 
 /*
  * Parse regexp flags. Report an error and return false if an invalid