diff --git a/js/src/gc/StoreBuffer.h b/js/src/gc/StoreBuffer.h index b734b97082c..137f9d7b1f6 100644 --- a/js/src/gc/StoreBuffer.h +++ b/js/src/gc/StoreBuffer.h @@ -356,17 +356,18 @@ class StoreBuffer class CallbackRef : public BufferableRef { public: - typedef void (*MarkCallback)(JSTracer *trc, void *key); + typedef void (*MarkCallback)(JSTracer *trc, void *key, void *data); - CallbackRef(MarkCallback cb, void *k) : callback(cb), key(k) {} + CallbackRef(MarkCallback cb, void *k, void *d) : callback(cb), key(k), data(d) {} virtual void mark(JSTracer *trc) { - callback(trc, key); + callback(trc, key, data); } private: MarkCallback callback; void *key; + void *data; }; MonoTypeBuffer bufferVal; @@ -451,8 +452,9 @@ class StoreBuffer } /* Insert or update a callback entry. */ - void putCallback(CallbackRef::MarkCallback callback, void *key) { - bufferGeneric.put(CallbackRef(callback, key)); + void putCallback(CallbackRef::MarkCallback callback, Cell *key, void *data) { + if (!key->isTenured()) + bufferGeneric.put(CallbackRef(callback, key, data)); } /* Mark the source of all edges in the store buffer. */ diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp index 483b818eae9..11ee2d207c9 100644 --- a/js/src/jsfriendapi.cpp +++ b/js/src/jsfriendapi.cpp @@ -1121,8 +1121,18 @@ js::IsInRequest(JSContext *cx) #ifdef JSGC_GENERATIONAL JS_FRIEND_API(void) -JS_StorePostBarrierCallback(JSContext* cx, void (*callback)(JSTracer *trc, void *key), void *key) +JS_StoreObjectPostBarrierCallback(JSContext* cx, + void (*callback)(JSTracer *trc, void *key, void *data), + JSObject *key, void *data) { - cx->runtime()->gcStoreBuffer.putCallback(callback, key); + cx->runtime()->gcStoreBuffer.putCallback(callback, key, data); +} + +extern JS_FRIEND_API(void) +JS_StoreStringPostBarrierCallback(JSContext* cx, + void (*callback)(JSTracer *trc, void *key, void *data), + JSString *key, void *data) +{ + cx->runtime()->gcStoreBuffer.putCallback(callback, key, data); } #endif /* JSGC_GENERATIONAL */ diff --git a/js/src/jsfriendapi.h b/js/src/jsfriendapi.h index be8613c9048..9339dd7ee21 100644 --- a/js/src/jsfriendapi.h +++ b/js/src/jsfriendapi.h @@ -1794,10 +1794,24 @@ js_ReportIsNotFunction(JSContext *cx, const JS::Value& v); #ifdef JSGC_GENERATIONAL extern JS_FRIEND_API(void) -JS_StorePostBarrierCallback(JSContext* cx, void (*callback)(JSTracer *trc, void *key), void *key); +JS_StoreObjectPostBarrierCallback(JSContext* cx, + void (*callback)(JSTracer *trc, void *key, void *data), + JSObject *key, void *data); + +extern JS_FRIEND_API(void) +JS_StoreStringPostBarrierCallback(JSContext* cx, + void (*callback)(JSTracer *trc, void *key, void *data), + JSString *key, void *data); #else inline void -JS_StorePostBarrierCallback(JSContext* cx, void (*callback)(JSTracer *trc, void *key), void *key) {} +JS_StoreObjectPostBarrierCallback(JSContext* cx, + void (*callback)(JSTracer *trc, void *key, void *data), + JSObject *key, void *data) {} + +inline void +JS_StoreStringPostBarrierCallback(JSContext* cx, + void (*callback)(JSTracer *trc, void *key, void *data), + JSString *key, void *data) {} #endif /* JSGC_GENERATIONAL */ #endif /* jsfriendapi_h */ diff --git a/js/xpconnect/src/XPCMaps.h b/js/xpconnect/src/XPCMaps.h index 2978af41966..1a8152658f4 100644 --- a/js/xpconnect/src/XPCMaps.h +++ b/js/xpconnect/src/XPCMaps.h @@ -54,7 +54,7 @@ public: return p->value; if (!mTable.add(p, obj, wrapper)) return nullptr; - JS_StorePostBarrierCallback(cx, KeyMarkCallback, obj); + JS_StoreObjectPostBarrierCallback(cx, KeyMarkCallback, obj, this); return wrapper; } @@ -87,12 +87,11 @@ private: * This function is called during minor GCs for each key in the HashMap that * has been moved. */ - static void KeyMarkCallback(JSTracer *trc, void *k) { + static void KeyMarkCallback(JSTracer *trc, void *k, void *d) { JSObject *key = static_cast(k); + JSObject2WrappedJSMap* self = static_cast(d); JSObject *prior = key; JS_CallObjectTracer(trc, &key, "XPCJSRuntime::mWrappedJSMap key"); - XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance(); - JSObject2WrappedJSMap* self = rt->GetWrappedJSMap(); self->mTable.rekey(prior, key); } @@ -650,7 +649,7 @@ public: if (!mTable.add(p, key, value)) return nullptr; MOZ_ASSERT(xpc::GetObjectScope(key)->mWaiverWrapperMap == this); - JS_StorePostBarrierCallback(cx, KeyMarkCallback, key); + JS_StoreObjectPostBarrierCallback(cx, KeyMarkCallback, key, this); return value; } @@ -697,11 +696,11 @@ private: * This function is called during minor GCs for each key in the HashMap that * has been moved. */ - static void KeyMarkCallback(JSTracer *trc, void *k) { + static void KeyMarkCallback(JSTracer *trc, void *k, void *d) { JSObject *key = static_cast(k); + JSObject2JSObjectMap *self = static_cast(d); JSObject *prior = key; JS_CallObjectTracer(trc, &key, "XPCWrappedNativeScope::mWaiverWrapperMap key"); - JSObject2JSObjectMap *self = xpc::GetObjectScope(key)->mWaiverWrapperMap; self->mTable.rekey(prior, key); }