Bug 1319468 - P3: Use Rooted for RootedCount. r=jonco
authorYoshi Cheng-Hao Huang <allstars.chh@gmail.com>
Fri, 08 Feb 2019 12:23:07 +0100
changeset 519620 9685cdc4b7cb67decb4acc603bfed0b371b77e43
parent 519619 ba49b929457a6df36413a33ce0270af65ad472e1
child 519621 5c4daba349dc2484188abd2c301b35ccd2d4aa08
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1319468
milestone67.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 1319468 - P3: Use Rooted for RootedCount. r=jonco
js/public/UbiNodeCensus.h
--- a/js/public/UbiNodeCensus.h
+++ b/js/public/UbiNodeCensus.h
@@ -175,49 +175,38 @@ class CountBase {
 
   size_t total_;
 
   // The smallest JS::ubi::Node::identifier() passed to this instance's
   // count() method. This provides a stable way to sort sets.
   Node::Id smallestNodeIdCounted_;
 };
 
-class RootedCount : JS::CustomAutoRooter {
-  CountBasePtr count;
-
-  void trace(JSTracer* trc) override { count->trace(trc); }
-
- public:
-  RootedCount(JSContext* cx, CountBasePtr&& count)
-      : CustomAutoRooter(cx), count(std::move(count)) {}
-  CountBase* operator->() const { return count.get(); }
-  explicit operator bool() const { return count.get(); }
-  operator CountBasePtr&() { return count; }
-};
+using RootedCount = JS::Rooted<CountBasePtr>;
 
 // Common data for a census traversal, shared across all CountType nodes.
 struct Census {
   JSContext* const cx;
   // If the targetZones set is non-empty, then only consider nodes whose zone
   // is an element of the set. If the targetZones set is empty, then nodes in
   // all zones are considered.
   JS::ZoneSet targetZones;
 
   explicit Census(JSContext* cx) : cx(cx) {}
 };
 
 // A BreadthFirst handler type that conducts a census, using a CountBase to
 // categorize and count each node.
 class CensusHandler {
   Census& census;
-  CountBasePtr& rootCount;
+  JS::Handle<CountBasePtr> rootCount;
   mozilla::MallocSizeOf mallocSizeOf;
 
  public:
-  CensusHandler(Census& census, CountBasePtr& rootCount,
+  CensusHandler(Census& census, JS::Handle<CountBasePtr> rootCount,
                 mozilla::MallocSizeOf mallocSizeOf)
       : census(census), rootCount(rootCount), mallocSizeOf(mallocSizeOf) {}
 
   MOZ_MUST_USE bool report(JSContext* cx, MutableHandleValue report) {
     return rootCount->report(cx, report);
   }
 
   // This class needs to retain no per-node data.