Bug 777385 - Support (some) Paris bindings objects as weak map keys. r=peterv
This adds support for many kinds of Paris bindings objects as weak map keys. This patch supports nsISupports objects as well as non-cycle-collected non-nsISupports objects. What is needed for support is to preserve any wrapper, if the object is wrapper cached. In other cases, we don't need to do anything.
This commit is contained in:
@@ -291,7 +291,10 @@ WeakMap_set_impl(JSContext *cx, CallArgs args)
|
||||
}
|
||||
|
||||
// Preserve wrapped native keys to prevent wrapper optimization.
|
||||
if (key->getClass()->ext.isWrappedNative) {
|
||||
if (key->getClass()->ext.isWrappedNative ||
|
||||
(key->getClass()->flags & JSCLASS_IS_DOMJSCLASS) ||
|
||||
(key->isProxy() && GetProxyHandler(key)->family() == GetListBaseHandlerFamily()))
|
||||
{
|
||||
JS_ASSERT(cx->runtime->preserveWrapperCallback);
|
||||
if (!cx->runtime->preserveWrapperCallback(cx, key)) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BAD_WEAKMAP_KEY);
|
||||
|
||||
Reference in New Issue
Block a user