Bug 1485615 - Move internal ZoneAllocPolicy to gc/Zone.h r=sfink
authorJon Coppeard <jcoppeard@mozilla.com>
Thu, 23 Aug 2018 16:59:01 +0100
changeset 488178 40001671f508bd5673f365c47cbbdbe6c9cdbdf2
parent 488177 c70943a6b070698c59db4802c912a6c682b49ba4
child 488179 71791e10b6e9c29fc3ff36ddee232d07961ba81d
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1485615
milestone63.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 1485615 - Move internal ZoneAllocPolicy to gc/Zone.h r=sfink
js/public/AllocPolicy.h
js/src/builtin/ModuleObject.h
js/src/gc/WeakMap.h
js/src/gc/Zone.h
js/src/vm/RegExpShared.h
--- a/js/public/AllocPolicy.h
+++ b/js/public/AllocPolicy.h
@@ -123,45 +123,11 @@ class TempAllocPolicy : public AllocPoli
             ReportOutOfMemory(cx_);
             return false;
         }
 
         return true;
     }
 };
 
-/*
- * Allocation policy that uses Zone::pod_malloc and friends, so that memory
- * pressure is accounted for on the zone. This is suitable for memory associated
- * with GC things allocated in the zone.
- *
- * Since it doesn't hold a JSContext (those may not live long enough), it can't
- * report out-of-memory conditions itself; the caller must check for OOM and
- * take the appropriate action.
- *
- * FIXME bug 647103 - replace these *AllocPolicy names.
- */
-class ZoneAllocPolicy
-{
-    JS::Zone* const zone;
-
-  public:
-    MOZ_IMPLICIT ZoneAllocPolicy(JS::Zone* z) : zone(z) {}
-
-    // These methods are defined in gc/Zone.h.
-    template <typename T> inline T* maybe_pod_malloc(size_t numElems);
-    template <typename T> inline T* maybe_pod_calloc(size_t numElems);
-    template <typename T> inline T* maybe_pod_realloc(T* p, size_t oldSize, size_t newSize);
-    template <typename T> inline T* pod_malloc(size_t numElems);
-    template <typename T> inline T* pod_calloc(size_t numElems);
-    template <typename T> inline T* pod_realloc(T* p, size_t oldSize, size_t newSize);
-
-    template <typename T> void free_(T* p, size_t numElems = 0) { js_free(p); }
-    void reportAllocOverflow() const {}
-
-    MOZ_MUST_USE bool checkSimulatedOOM() const {
-        return !js::oom::ShouldFailWithOOM();
-    }
-};
-
 } /* namespace js */
 
 #endif /* js_AllocPolicy_h */
--- a/js/src/builtin/ModuleObject.h
+++ b/js/src/builtin/ModuleObject.h
@@ -7,16 +7,17 @@
 #ifndef builtin_ModuleObject_h
 #define builtin_ModuleObject_h
 
 #include "mozilla/Maybe.h"
 
 #include "jsapi.h"
 
 #include "builtin/SelfHostingDefines.h"
+#include "gc/Zone.h"
 #include "js/GCVector.h"
 #include "js/Id.h"
 #include "js/UniquePtr.h"
 #include "vm/JSAtom.h"
 #include "vm/NativeObject.h"
 #include "vm/ProxyObject.h"
 
 namespace js {
--- a/js/src/gc/WeakMap.h
+++ b/js/src/gc/WeakMap.h
@@ -6,16 +6,17 @@
 
 #ifndef gc_WeakMap_h
 #define gc_WeakMap_h
 
 #include "mozilla/LinkedList.h"
 
 #include "gc/Barrier.h"
 #include "gc/DeletePolicy.h"
+#include "gc/Zone.h"
 #include "js/HashTable.h"
 
 namespace JS {
 class Zone;
 } // namespace JS
 
 namespace js {
 
--- a/js/src/gc/Zone.h
+++ b/js/src/gc/Zone.h
@@ -752,53 +752,56 @@ class Zone : public JS::shadow::Zone,
     friend bool js::CurrentThreadCanAccessZone(Zone* zone);
     friend class js::gc::GCRuntime;
 };
 
 } // namespace JS
 
 namespace js {
 
-template <typename T>
-inline T*
-ZoneAllocPolicy::maybe_pod_malloc(size_t numElems)
+/*
+ * Allocation policy that uses Zone::pod_malloc and friends, so that memory
+ * pressure is accounted for on the zone. This is suitable for memory associated
+ * with GC things allocated in the zone.
+ *
+ * Since it doesn't hold a JSContext (those may not live long enough), it can't
+ * report out-of-memory conditions itself; the caller must check for OOM and
+ * take the appropriate action.
+ *
+ * FIXME bug 647103 - replace these *AllocPolicy names.
+ */
+class ZoneAllocPolicy
 {
-    return zone->maybe_pod_malloc<T>(numElems);
-}
+    JS::Zone* const zone;
 
-template <typename T>
-inline T*
-ZoneAllocPolicy::maybe_pod_calloc(size_t numElems)
-{
-    return zone->maybe_pod_calloc<T>(numElems);
-}
-
-template <typename T>
-inline T*
-ZoneAllocPolicy::maybe_pod_realloc(T* p, size_t oldSize, size_t newSize)
-{
-    return zone->maybe_pod_realloc<T>(p, oldSize, newSize);
-}
+  public:
+    MOZ_IMPLICIT ZoneAllocPolicy(JS::Zone* z) : zone(z) {}
 
-template <typename T>
-inline T*
-ZoneAllocPolicy::pod_malloc(size_t numElems)
-{
-    return zone->pod_malloc<T>(numElems);
-}
+    template <typename T> T* maybe_pod_malloc(size_t numElems) {
+        return zone->maybe_pod_malloc<T>(numElems);
+    }
+    template <typename T> T* maybe_pod_calloc(size_t numElems) {
+        return zone->maybe_pod_calloc<T>(numElems);
+    }
+    template <typename T> T* maybe_pod_realloc(T* p, size_t oldSize, size_t newSize) {
+        return zone->maybe_pod_realloc<T>(p, oldSize, newSize);
+    }
+    template <typename T> T* pod_malloc(size_t numElems) {
+        return zone->pod_malloc<T>(numElems);
+    }
+    template <typename T> T* pod_calloc(size_t numElems) {
+        return zone->pod_calloc<T>(numElems);
+    }
+    template <typename T> T* pod_realloc(T* p, size_t oldSize, size_t newSize) {
+        return zone->pod_realloc<T>(p, oldSize, newSize);
+    }
 
-template <typename T>
-inline T*
-ZoneAllocPolicy::pod_calloc(size_t numElems)
-{
-    return zone->pod_calloc<T>(numElems);
-}
+    template <typename T> void free_(T* p, size_t numElems = 0) { js_free(p); }
+    void reportAllocOverflow() const {}
 
-template <typename T>
-inline T*
-ZoneAllocPolicy::pod_realloc(T* p, size_t oldSize, size_t newSize)
-{
-    return zone->pod_realloc<T>(p, oldSize, newSize);
-}
+    MOZ_MUST_USE bool checkSimulatedOOM() const {
+        return !js::oom::ShouldFailWithOOM();
+    }
+};
 
 } // namespace js
 
 #endif // gc_Zone_h
--- a/js/src/vm/RegExpShared.h
+++ b/js/src/vm/RegExpShared.h
@@ -14,16 +14,17 @@
 
 #include "mozilla/Assertions.h"
 #include "mozilla/MemoryReporting.h"
 
 #include "builtin/SelfHostingDefines.h"
 #include "gc/Barrier.h"
 #include "gc/Heap.h"
 #include "gc/Marking.h"
+#include "gc/Zone.h"
 #include "js/AllocPolicy.h"
 #include "js/UbiNode.h"
 #include "js/Vector.h"
 #include "vm/ArrayObject.h"
 #include "vm/JSAtom.h"
 
 namespace js {