Skip to content

Commit 10953d5

Browse files
committed
Bug 1513108 - Remove the separate class extension hook for getting a weakmap key delegate, r=jonco
Replace with just unwrapping the key, since there are no users that return anything else for a delegate. --HG-- extra : rebase_source : e72b825121ca3493364c9347f65e5dddd1ef53e0
1 parent 149087a commit 10953d5

26 files changed

+39
-131
lines changed

dom/bindings/Codegen.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,6 @@ def define(self):
508508
};
509509

510510
static const js::ClassExtension sClassExtension = {
511-
nullptr, /* weakmapKeyDelegateOp */
512511
${objectMoved} /* objectMovedOp */
513512
};
514513

dom/bindings/SimpleGlobalObject.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static const js::ClassOps SimpleGlobalClassOps = {
7474
};
7575

7676
static const js::ClassExtension SimpleGlobalClassExtension = {
77-
nullptr, SimpleGlobal_moved};
77+
SimpleGlobal_moved};
7878

7979
const js::Class SimpleGlobalClass = {
8080
"",

js/public/Class.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,6 @@ typedef bool (*JSHasInstanceOp)(JSContext* cx, JS::HandleObject obj,
493493
*/
494494
typedef void (*JSTraceOp)(JSTracer* trc, JSObject* obj);
495495

496-
typedef JSObject* (*JSWeakmapKeyDelegateOp)(JSObject* obj);
497-
498496
typedef size_t (*JSObjectMovedOp)(JSObject* obj, JSObject* old);
499497

500498
/* js::Class operation signatures. */
@@ -687,19 +685,6 @@ struct MOZ_STATIC_CLASS ClassSpec {
687685
};
688686

689687
struct MOZ_STATIC_CLASS ClassExtension {
690-
/**
691-
* If an object is used as a key in a weakmap, it may be desirable for the
692-
* garbage collector to keep that object around longer than it otherwise
693-
* would. A common case is when the key is a wrapper around an object in
694-
* another compartment, and we want to avoid collecting the wrapper (and
695-
* removing the weakmap entry) as long as the wrapped object is alive. In
696-
* that case, the wrapped object is returned by the wrapper's
697-
* weakmapKeyDelegateOp hook. As long as the wrapper is used as a weakmap
698-
* key, it will not be collected (and remain in the weakmap) until the
699-
* wrapped object is collected.
700-
*/
701-
JSWeakmapKeyDelegateOp weakmapKeyDelegateOp;
702-
703688
/**
704689
* Optional hook called when an object is moved by generational or
705690
* compacting GC.
@@ -952,9 +937,6 @@ struct MOZ_STATIC_CLASS Class {
952937
return spec ? spec->finishInit : nullptr;
953938
}
954939

955-
JSWeakmapKeyDelegateOp extWeakmapKeyDelegateOp() const {
956-
return ext ? ext->weakmapKeyDelegateOp : nullptr;
957-
}
958940
JSObjectMovedOp extObjectMovedOp() const {
959941
return ext ? ext->objectMovedOp : nullptr;
960942
}

js/public/Proxy.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,6 @@ class JS_FRIEND_API BaseProxyHandler {
373373
virtual bool getElements(JSContext* cx, HandleObject proxy, uint32_t begin,
374374
uint32_t end, ElementAdder* adder) const;
375375

376-
/* See comment for weakmapKeyDelegateOp in js/Class.h. */
377-
virtual JSObject* weakmapKeyDelegate(JSObject* proxy) const;
378376
virtual bool isScripted() const { return false; }
379377
};
380378

js/public/Wrapper.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ class JS_FRIEND_API Wrapper : public ForwardingProxyHandler {
133133
mFlags(aFlags) {}
134134

135135
virtual bool finalizeInBackground(const Value& priv) const override;
136-
virtual JSObject* weakmapKeyDelegate(JSObject* proxy) const override;
137136

138137
using BaseProxyHandler::Action;
139138

js/rust/src/jsglue.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ struct ProxyTraps {
9494

9595
// getElements
9696

97-
// weakmapKeyDelegate
9897
// isScripted
9998
};
10099

js/src/builtin/MapObject.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ static const ClassOps MapIteratorObjectClassOps = {nullptr, /* addProperty */
141141
MapIteratorObject::finalize};
142142

143143
static const ClassExtension MapIteratorObjectClassExtension = {
144-
nullptr, /* weakmapKeyDelegateOp */
145144
MapIteratorObject::objectMoved};
146145

147146
const Class MapIteratorObject::class_ = {
@@ -912,7 +911,6 @@ static const ClassOps SetIteratorObjectClassOps = {nullptr, /* addProperty */
912911
SetIteratorObject::finalize};
913912

914913
static const ClassExtension SetIteratorObjectClassExtension = {
915-
nullptr, /* weakmapKeyDelegateOp */
916914
SetIteratorObject::objectMoved};
917915

918916
const Class SetIteratorObject::class_ = {

js/src/builtin/TypedObject.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2301,8 +2301,7 @@ const ObjectOps TypedObject::objectOps_ = {
23012301
Trace, \
23022302
}; \
23032303
static const ClassExtension Name##ClassExt = { \
2304-
nullptr, /* weakmapKeyDelegateOp */ \
2305-
Moved /* objectMovedOp */ \
2304+
Moved /* objectMovedOp */ \
23062305
}; \
23072306
const Class Name::class_ = { \
23082307
#Name, Class::NON_NATIVE | JSCLASS_DELAY_METADATA_BUILDER, \

js/src/builtin/WeakMapObject-inl.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,9 @@ static MOZ_ALWAYS_INLINE bool WeakCollectionPutEntryInternal(
4747
return false;
4848
}
4949

50-
if (JSWeakmapKeyDelegateOp op = key->getClass()->extWeakmapKeyDelegateOp()) {
51-
RootedObject delegate(cx, op(key));
52-
if (delegate && !TryPreserveReflector(cx, delegate)) {
53-
return false;
54-
}
50+
RootedObject delegate(cx, UncheckedUnwrapWithoutExpose(key));
51+
if (delegate && !TryPreserveReflector(cx, delegate)) {
52+
return false;
5553
}
5654

5755
MOZ_ASSERT(key->compartment() == obj->compartment());

js/src/devtools/rootAnalysis/annotations.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ function indirectCallCannotGC(fullCaller, fullVariable)
3131
if (name == "params" && caller == "PR_ExplodeTime")
3232
return true;
3333

34-
if (name == "op" && /GetWeakmapKeyDelegate/.test(caller))
35-
return true;
36-
3734
// hook called during script finalization which cannot GC.
3835
if (/CallDestroyScriptHook/.test(caller))
3936
return true;
@@ -168,7 +165,6 @@ var ignoreFunctions = {
168165
"PR_ExplodeTime" : true,
169166
"PR_ErrorInstallTable" : true,
170167
"PR_SetThreadPrivate" : true,
171-
"JSObject* js::GetWeakmapKeyDelegate(JSObject*)" : true, // FIXME: mark with AutoSuppressGCAnalysis instead
172168
"uint8 NS_IsMainThread()" : true,
173169

174170
// Has an indirect call under it by the name "__f", which seemed too

0 commit comments

Comments
 (0)