Bug 1200732 - Use stable hashing for AutoCycleDetectorSet; r=jonco
☠☠ backed out by 96691a3775ed ☠ ☠
authorTerrence Cole <terrence@mozilla.com>
Wed, 26 Aug 2015 14:51:43 -0700
changeset 260610 d92d88957742e5aa095bb4563e8108ffc5744b78
parent 260609 ff66ba4688c0169e4b67ddd06057f29ae57feafc
child 260611 b45b4b3f1ed5e7df24e62551e6a5e9fdd5c1acc9
push id29318
push usercbook@mozilla.com
push dateThu, 03 Sep 2015 11:15:07 +0000
treeherdermozilla-central@74fbd245369c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1200732
milestone43.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 1200732 - Use stable hashing for AutoCycleDetectorSet; r=jonco
js/src/jscntxt.cpp
js/src/jscntxt.h
--- a/js/src/jscntxt.cpp
+++ b/js/src/jscntxt.cpp
@@ -55,17 +55,17 @@ using namespace js::gc;
 using mozilla::DebugOnly;
 using mozilla::PodArrayZero;
 using mozilla::PointerRangeSize;
 using mozilla::UniquePtr;
 
 bool
 js::AutoCycleDetector::init()
 {
-    ObjectSet& set = cx->cycleDetectorSet;
+    AutoCycleDetector::Set& set = cx->cycleDetectorSet;
     hashsetAddPointer = set.lookupForAdd(obj);
     if (!hashsetAddPointer) {
         if (!set.add(hashsetAddPointer, obj))
             return false;
         cyclic = false;
         hashsetGenerationAtInit = set.generation();
     }
     return true;
@@ -77,24 +77,20 @@ js::AutoCycleDetector::~AutoCycleDetecto
         if (hashsetGenerationAtInit == cx->cycleDetectorSet.generation())
             cx->cycleDetectorSet.remove(hashsetAddPointer);
         else
             cx->cycleDetectorSet.remove(obj);
     }
 }
 
 void
-js::TraceCycleDetectionSet(JSTracer* trc, js::ObjectSet& set)
+js::TraceCycleDetectionSet(JSTracer* trc, AutoCycleDetector::Set& set)
 {
-    for (js::ObjectSet::Enum e(set); !e.empty(); e.popFront()) {
-        JSObject* key = e.front();
-        TraceRoot(trc, &key, "cycle detector table entry");
-        if (key != e.front())
-            e.rekeyFront(key);
-    }
+    for (AutoCycleDetector::Set::Enum e(set); !e.empty(); e.popFront())
+        TraceRoot(trc, &e.mutableFront(), "cycle detector table entry");
 }
 
 JSContext*
 js::NewContext(JSRuntime* rt, size_t stackChunkSize)
 {
     JS_AbortIfWrongThread(rt);
 
     JSContext* cx = js_new<JSContext>(rt);
--- a/js/src/jscntxt.h
+++ b/js/src/jscntxt.h
@@ -24,47 +24,49 @@ struct DtoaState;
 
 namespace js {
 
 namespace jit {
 class JitContext;
 class DebugModeOSRVolatileJitFrameIterator;
 } // namespace jit
 
-typedef HashSet<JSObject*> ObjectSet;
 typedef HashSet<Shape*> ShapeSet;
 
 /* Detects cycles when traversing an object graph. */
 class AutoCycleDetector
 {
-    JSContext* cx;
-    RootedObject obj;
-    bool cyclic;
-    uint32_t hashsetGenerationAtInit;
-    ObjectSet::AddPtr hashsetAddPointer;
-    MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
+  public:
+    using Set = HashSet<JSObject*, MovableCellHasher<JSObject*>>;
 
-  public:
     AutoCycleDetector(JSContext* cx, HandleObject objArg
                       MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : cx(cx), obj(cx, objArg), cyclic(true)
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     }
 
     ~AutoCycleDetector();
 
     bool init();
 
     bool foundCycle() { return cyclic; }
+
+  private:
+    JSContext* cx;
+    RootedObject obj;
+    bool cyclic;
+    uint32_t hashsetGenerationAtInit;
+    Set::AddPtr hashsetAddPointer;
+    MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
 /* Updates references in the cycle detection set if the GC moves them. */
 extern void
-TraceCycleDetectionSet(JSTracer* trc, ObjectSet& set);
+TraceCycleDetectionSet(JSTracer* trc, AutoCycleDetector::Set& set);
 
 struct AutoResolving;
 
 namespace frontend { struct CompileError; }
 
 /*
  * Execution Context Overview:
  *
@@ -341,17 +343,17 @@ struct JSContext : public js::ExclusiveC
     typedef js::Vector<SavedFrameChain, 1, js::SystemAllocPolicy> SaveStack;
     SaveStack           savedFrameChains_;
   public:
     bool saveFrameChain();
     void restoreFrameChain();
 
   public:
     /* State for object and array toSource conversion. */
-    js::ObjectSet       cycleDetectorSet;
+    js::AutoCycleDetector::Set cycleDetectorSet;
 
     /* Client opaque pointers. */
     void*               data;
     void*               data2;
 
   public:
 
     /*