mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1225650 - Use stable hashing for JSObject2WrappedJSMap; r=jonco
This commit is contained in:
parent
93badb028e
commit
3d2f44a932
@ -119,12 +119,11 @@ JSObject2WrappedJSMap::UpdateWeakPointersAfterGC(XPCJSRuntime* runtime)
|
||||
|
||||
// Remove or update the JSObject key in the table if necessary.
|
||||
JSObject* obj = e.front().key();
|
||||
JSObject* prior = obj;
|
||||
JS_UpdateWeakPointerAfterGCUnbarriered(&obj);
|
||||
if (!obj)
|
||||
e.removeFront();
|
||||
else if (obj != prior)
|
||||
e.rekeyFront(obj);
|
||||
else
|
||||
e.front().mutableKey() = obj;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,8 +27,10 @@
|
||||
|
||||
class JSObject2WrappedJSMap
|
||||
{
|
||||
typedef js::HashMap<JSObject*, nsXPCWrappedJS*, js::PointerHasher<JSObject*, 3>,
|
||||
js::SystemAllocPolicy> Map;
|
||||
using Map = js::HashMap<JS::Heap<JSObject*>,
|
||||
nsXPCWrappedJS*,
|
||||
js::MovableCellHasher<JS::Heap<JSObject*>>,
|
||||
js::SystemAllocPolicy>;
|
||||
|
||||
public:
|
||||
static JSObject2WrappedJSMap* newMap(int length) {
|
||||
@ -66,7 +68,6 @@ public:
|
||||
return p->value();
|
||||
if (!mTable.add(p, obj, wrapper))
|
||||
return nullptr;
|
||||
JS_StoreObjectPostBarrierCallback(cx, KeyMarkCallback, obj, this);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@ -95,17 +96,6 @@ public:
|
||||
private:
|
||||
JSObject2WrappedJSMap() {}
|
||||
|
||||
/*
|
||||
* This function is called during minor GCs for each key in the HashMap that
|
||||
* has been moved.
|
||||
*/
|
||||
static void KeyMarkCallback(JSTracer* trc, JSObject* key, void* data) {
|
||||
JSObject2WrappedJSMap* self = static_cast<JSObject2WrappedJSMap*>(data);
|
||||
JSObject* prior = key;
|
||||
JS_CallUnbarrieredObjectTracer(trc, &key, "XPCJSRuntime::mWrappedJSMap key");
|
||||
self->mTable.rekeyIfMoved(prior, key);
|
||||
}
|
||||
|
||||
Map mTable;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user