Bug 1268085 - Remove unused post barrier callbacks r=terrence
authorJon Coppeard <jcoppeard@mozilla.com>
Fri, 29 Apr 2016 10:44:22 +0100
changeset 295464 33f5b0151b8b1a3d2cc1e8779c28616a5dba2971
parent 295463 b10abfa0ce4861480b80c58f9232753f586fd23f
child 295465 d2af90b2dba27b070be1d31935df7e924507c981
push id19006
push userkwierso@gmail.com
push dateFri, 29 Apr 2016 23:06:04 +0000
treeherderfx-team@8471d2d75bf4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs1268085
milestone49.0a1
Bug 1268085 - Remove unused post barrier callbacks r=terrence
js/ipc/JavaScriptShared.cpp
js/ipc/JavaScriptShared.h
js/src/gc/GCRuntime.h
js/src/gc/StoreBuffer.h
js/src/jsfriendapi.cpp
js/src/jsfriendapi.h
js/src/jsgc.cpp
--- a/js/ipc/JavaScriptShared.cpp
+++ b/js/ipc/JavaScriptShared.cpp
@@ -78,26 +78,16 @@ IdToObjectMap::clear()
 }
 
 bool
 IdToObjectMap::empty() const
 {
     return table_.empty();
 }
 
-ObjectToIdMap::ObjectToIdMap(JSRuntime* rt)
-  : rt_(rt)
-{
-}
-
-ObjectToIdMap::~ObjectToIdMap()
-{
-    JS_ClearAllPostBarrierCallbacks(rt_);
-}
-
 bool
 ObjectToIdMap::init()
 {
     return table_.initialized() || table_.init(32);
 }
 
 void
 ObjectToIdMap::trace(JSTracer* trc)
@@ -140,19 +130,17 @@ ObjectToIdMap::clear()
 
 bool JavaScriptShared::sLoggingInitialized;
 bool JavaScriptShared::sLoggingEnabled;
 bool JavaScriptShared::sStackLoggingEnabled;
 
 JavaScriptShared::JavaScriptShared(JSRuntime* rt)
   : rt_(rt),
     refcount_(1),
-    nextSerialNumber_(1),
-    unwaivedObjectIds_(rt),
-    waivedObjectIds_(rt)
+    nextSerialNumber_(1)
 {
     if (!sLoggingInitialized) {
         sLoggingInitialized = true;
 
         if (PR_GetEnv("MOZ_CPOW_LOG")) {
             sLoggingEnabled = true;
             sStackLoggingEnabled = strstr(PR_GetEnv("MOZ_CPOW_LOG"), "stacks");
         } else {
--- a/js/ipc/JavaScriptShared.h
+++ b/js/ipc/JavaScriptShared.h
@@ -107,30 +107,26 @@ class IdToObjectMap
 
 // Map JSObjects -> ids
 class ObjectToIdMap
 {
     using Hasher = js::MovableCellHasher<JS::Heap<JSObject*>>;
     using Table = js::GCHashMap<JS::Heap<JSObject*>, ObjectId, Hasher, js::SystemAllocPolicy>;
 
   public:
-    explicit ObjectToIdMap(JSRuntime* rt);
-    ~ObjectToIdMap();
-
     bool init();
     void trace(JSTracer* trc);
     void sweep();
 
     bool add(JSContext* cx, JSObject* obj, ObjectId id);
     ObjectId find(JSObject* obj);
     void remove(JSObject* obj);
     void clear();
 
   private:
-    JSRuntime* rt_;
     Table table_;
 };
 
 class Logging;
 
 class JavaScriptShared : public CPOWManager
 {
   public:
--- a/js/src/gc/GCRuntime.h
+++ b/js/src/gc/GCRuntime.h
@@ -609,17 +609,16 @@ class GCRuntime
         gcstats::AutoPhase ap(stats, gcstats::PHASE_MINOR_GC);
         minorGCImpl(reason, nullptr);
     }
     void minorGC(JSContext* cx, JS::gcreason::Reason reason);
     void evictNursery(JS::gcreason::Reason reason = JS::gcreason::EVICT_NURSERY) {
         gcstats::AutoPhase ap(stats, gcstats::PHASE_EVICT_NURSERY);
         minorGCImpl(reason, nullptr);
     }
-    void clearPostBarrierCallbacks();
     bool gcIfRequested(JSContext* cx = nullptr);
     void gc(JSGCInvocationKind gckind, JS::gcreason::Reason reason);
     void startGC(JSGCInvocationKind gckind, JS::gcreason::Reason reason, int64_t millis = 0);
     void gcSlice(JS::gcreason::Reason reason, int64_t millis = 0);
     void finishGC(JS::gcreason::Reason reason);
     void abortGC();
     void startDebugGC(JSGCInvocationKind gckind, SliceBudget& budget);
     void debugGCSlice(SliceBudget& budget);
--- a/js/src/gc/StoreBuffer.h
+++ b/js/src/gc/StoreBuffer.h
@@ -352,33 +352,16 @@ class StoreBuffer
 
         void trace(TenuringTracer& mover) const;
 
         explicit operator bool() const { return edge != nullptr; }
 
         typedef PointerEdgeHasher<WholeCellEdges> Hasher;
     };
 
-    template <typename Key>
-    struct CallbackRef : public BufferableRef
-    {
-        typedef void (*TraceCallback)(JSTracer* trc, Key* key, void* data);
-
-        CallbackRef(TraceCallback cb, Key* k, void* d) : callback(cb), key(k), data(d) {}
-
-        virtual void trace(JSTracer* trc) {
-            callback(trc, key, data);
-        }
-
-      private:
-        TraceCallback callback;
-        Key* key;
-        void* data;
-    };
-
     template <typename Buffer, typename Edge>
     void unput(Buffer& buffer, const Edge& edge) {
         MOZ_ASSERT(!JS::shadow::Runtime::asShadowRuntime(runtime_)->isHeapBusy());
         MOZ_ASSERT(CurrentThreadCanAccessRuntime(runtime_));
         if (!isEnabled())
             return;
         mozilla::ReentrancyGuard g(*this);
         buffer.unput(this, edge);
@@ -446,39 +429,29 @@ class StoreBuffer
             put(bufferSlot, edge);
     }
     inline void putWholeCell(Cell* cell);
 
     /* Insert an entry into the generic buffer. */
     template <typename T>
     void putGeneric(const T& t) { put(bufferGeneric, t);}
 
-    /* Insert or update a callback entry. */
-    template <typename Key>
-    void putCallback(void (*callback)(JSTracer* trc, Key* key, void* data), Key* key, void* data) {
-        put(bufferGeneric, CallbackRef<Key>(callback, key, data));
-    }
-
     void setShouldCancelIonCompilations() {
         cancelIonCompilations_ = true;
     }
 
     /* Methods to trace the source of all edges in the store buffer. */
     void traceValues(TenuringTracer& mover)            { bufferVal.trace(this, mover); }
     void traceCells(TenuringTracer& mover)             { bufferCell.trace(this, mover); }
     void traceSlots(TenuringTracer& mover)             { bufferSlot.trace(this, mover); }
     void traceWholeCells(TenuringTracer& mover)        { bufferWholeCell.trace(this, mover); }
     void traceGenericEntries(JSTracer *trc)            { bufferGeneric.trace(this, trc); }
 
     /* For use by our owned buffers and for testing. */
     void setAboutToOverflow();
 
-    bool hasPostBarrierCallbacks() {
-        return !bufferGeneric.isEmpty();
-    }
-
     void addSizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf, JS::GCSizes* sizes);
 };
 
 } /* namespace gc */
 } /* namespace js */
 
 #endif /* gc_StoreBuffer_h */
--- a/js/src/jsfriendapi.cpp
+++ b/js/src/jsfriendapi.cpp
@@ -1271,42 +1271,16 @@ js::ReportErrorWithId(JSContext* cx, con
 
 #ifdef DEBUG
 bool
 js::HasObjectMovedOp(JSObject* obj) {
     return !!GetObjectClass(obj)->extObjectMovedOp();
 }
 #endif
 
-JS_FRIEND_API(void)
-JS_StoreObjectPostBarrierCallback(JSContext* cx,
-                                  void (*callback)(JSTracer* trc, JSObject* key, void* data),
-                                  JSObject* key, void* data)
-{
-    JSRuntime* rt = cx->runtime();
-    if (IsInsideNursery(key))
-        rt->gc.storeBuffer.putCallback(callback, key, data);
-}
-
-extern JS_FRIEND_API(void)
-JS_StoreStringPostBarrierCallback(JSContext* cx,
-                                  void (*callback)(JSTracer* trc, JSString* key, void* data),
-                                  JSString* key, void* data)
-{
-    JSRuntime* rt = cx->runtime();
-    if (IsInsideNursery(key))
-        rt->gc.storeBuffer.putCallback(callback, key, data);
-}
-
-extern JS_FRIEND_API(void)
-JS_ClearAllPostBarrierCallbacks(JSRuntime* rt)
-{
-    rt->gc.clearPostBarrierCallbacks();
-}
-
 JS_FRIEND_API(bool)
 js::ForwardToNative(JSContext* cx, JSNative native, const CallArgs& args)
 {
     return native(cx, args.length(), args.base());
 }
 
 JS_FRIEND_API(JSObject*)
 js::ConvertArgsToArray(JSContext* cx, const CallArgs& args)
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -2888,36 +2888,16 @@ ToWindowProxyIfWindow(JSObject* obj);
  * global), else return `obj`. This function is infallible and never returns
  * nullptr.
  */
 extern JS_FRIEND_API(JSObject*)
 ToWindowIfWindowProxy(JSObject* obj);
 
 } /* namespace js */
 
-extern JS_FRIEND_API(void)
-JS_StoreObjectPostBarrierCallback(JSContext* cx,
-                                  void (*callback)(JSTracer* trc, JSObject* key, void* data),
-                                  JSObject* key, void* data);
-
-extern JS_FRIEND_API(void)
-JS_StoreStringPostBarrierCallback(JSContext* cx,
-                                  void (*callback)(JSTracer* trc, JSString* key, void* data),
-                                  JSString* key, void* data);
-
-/**
- * Forcibly clear postbarrier callbacks queued by the previous two methods.
- * This should be used when the object owning the postbarriered pointers is
- * being destroyed outside of a garbage collection.
- *
- * This currently works by performing a minor GC.
- */
-extern JS_FRIEND_API(void)
-JS_ClearAllPostBarrierCallbacks(JSRuntime *rt);
-
 class NativeProfiler
 {
   public:
     virtual ~NativeProfiler() {};
     virtual void sampleNative(void* addr, uint32_t size) = 0;
     virtual void removeNative(void* addr) = 0;
     virtual void reset() = 0;
 };
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -6778,23 +6778,16 @@ GCRuntime::minorGC(JSContext* cx, JS::gc
     minorGCImpl(reason, &pretenureGroups);
     for (size_t i = 0; i < pretenureGroups.length(); i++) {
         if (pretenureGroups[i]->canPreTenure())
             pretenureGroups[i]->setShouldPreTenure(cx);
     }
 }
 
 void
-GCRuntime::clearPostBarrierCallbacks()
-{
-    if (storeBuffer.hasPostBarrierCallbacks())
-        evictNursery();
-}
-
-void
 GCRuntime::disableGenerationalGC()
 {
     if (isGenerationalGCEnabled()) {
         minorGC(JS::gcreason::API);
         nursery.disable();
         storeBuffer.disable();
     }
     ++rt->gc.generationalDisabled;