Bug 680937, part 2 - Add native wrapper preservation hook, call it in WeakMap_set. r=billm
This commit is contained in:
@@ -233,6 +233,15 @@ WeakMap_set(JSContext *cx, uintN argc, Value *vp)
|
||||
|
||||
if (!map->put(key, value))
|
||||
goto out_of_memory;
|
||||
|
||||
// Preserve wrapped native keys to prevent wrapper optimization.
|
||||
if (key->getClass()->ext.isWrappedNative) {
|
||||
if (!cx->runtime->preserveWrapperCallback ||
|
||||
!cx->runtime->preserveWrapperCallback(cx, key)) {
|
||||
JS_ReportWarning(cx, "Failed to preserve wrapper of wrapped native weak map key.");
|
||||
}
|
||||
}
|
||||
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user