From 3d2f44a932796e91c287d51e493970e14f577619 Mon Sep 17 00:00:00 2001 From: Terrence Cole Date: Tue, 17 Nov 2015 13:40:55 -0800 Subject: [PATCH] Bug 1225650 - Use stable hashing for JSObject2WrappedJSMap; r=jonco --- js/xpconnect/src/XPCMaps.cpp | 5 ++--- js/xpconnect/src/XPCMaps.h | 18 ++++-------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/js/xpconnect/src/XPCMaps.cpp b/js/xpconnect/src/XPCMaps.cpp index 297e9776ce7..45876a9138d 100644 --- a/js/xpconnect/src/XPCMaps.cpp +++ b/js/xpconnect/src/XPCMaps.cpp @@ -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; } } diff --git a/js/xpconnect/src/XPCMaps.h b/js/xpconnect/src/XPCMaps.h index 15f10b6a360..7d585e93ea7 100644 --- a/js/xpconnect/src/XPCMaps.h +++ b/js/xpconnect/src/XPCMaps.h @@ -27,8 +27,10 @@ class JSObject2WrappedJSMap { - typedef js::HashMap, - js::SystemAllocPolicy> Map; + using Map = js::HashMap, + nsXPCWrappedJS*, + js::MovableCellHasher>, + 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(data); - JSObject* prior = key; - JS_CallUnbarrieredObjectTracer(trc, &key, "XPCJSRuntime::mWrappedJSMap key"); - self->mTable.rekeyIfMoved(prior, key); - } - Map mTable; };