Bug 1225650 - Use stable hashing for JSObject2WrappedJSMap; r=jonco

This commit is contained in:
Terrence Cole 2015-11-17 13:40:55 -08:00
parent 93badb028e
commit 3d2f44a932
2 changed files with 6 additions and 17 deletions

View File

@ -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;
}
}

View File

@ -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;
};