Bug 1402473 - Relax RegExpShared assert to ignore shutdown leaks r=jandem
authorJon Coppeard <jcoppeard@mozilla.com>
Mon, 09 Oct 2017 10:22:44 +0100
changeset 427687 f5dd83abdb399422f09f75576c970c74daeb3798
parent 427685 6ad5b916c9659aeb4b901d8f9ec7f121dc2c4418
child 427688 a61ebf848a5ccd7c259480947b6e3697a82ab4f9
push id97
push userfmarier@mozilla.com
push dateSat, 14 Oct 2017 01:12:59 +0000
reviewersjandem
bugs1402473
milestone58.0a1
Bug 1402473 - Relax RegExpShared assert to ignore shutdown leaks r=jandem
js/src/gc/Zone.cpp
js/src/vm/RegExpShared.h
--- a/js/src/gc/Zone.cpp
+++ b/js/src/gc/Zone.cpp
@@ -77,19 +77,22 @@ Zone::~Zone()
     JSRuntime* rt = runtimeFromAnyThread();
     if (this == rt->gc.systemZone)
         rt->gc.systemZone = nullptr;
 
     js_delete(debuggers.ref());
     js_delete(jitZone_.ref());
 
 #ifdef DEBUG
-    // Avoid assertion destroying the weak map list if the embedding leaked GC things.
-    if (!rt->gc.shutdownCollectedEverything())
+    // Avoid assertions failures warning that not everything has been destroyed
+    // if the embedding leaked GC things.
+    if (!rt->gc.shutdownCollectedEverything()) {
         gcWeakMapList().clear();
+        regExps.clear();
+    }
 #endif
 }
 
 bool
 Zone::init(bool isSystemArg)
 {
     isSystem = isSystemArg;
     return uniqueIds().init() &&
--- a/js/src/vm/RegExpShared.h
+++ b/js/src/vm/RegExpShared.h
@@ -274,16 +274,20 @@ class RegExpZone
 
     bool empty() const { return set_.empty(); }
 
     RegExpShared* get(JSContext* cx, HandleAtom source, RegExpFlag flags);
 
     /* Like 'get', but compile 'maybeOpt' (if non-null). */
     RegExpShared* get(JSContext* cx, HandleAtom source, JSString* maybeOpt);
 
+#ifdef DEBUG
+    void clear() { set_.clear(); }
+#endif
+
     size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf);
 };
 
 class RegExpCompartment
 {
     /*
      * This is the template object where the result of re.exec() is based on,
      * if there is a result. This is used in CreateRegExpMatchResult to set