Made Weak<T> single-owner, adding PassWeak<T>
https://bugs.webkit.org/show_bug.cgi?id=78740
Reviewed by Sam Weinig.
Source/JavaScriptCore:
This works basically the same way as OwnPtr<T> and PassOwnPtr<T>.
This clarifies the semantics of finalizers: It's ambiguous and probably
a bug to copy a finalizer (i.e., it's a bug to run a C++ destructor
twice), so I've made Weak<T> non-copyable. Anywhere we used to copy a
Weak<T>, we now use PassWeak<T>.
This also makes Weak<T> HashMaps more efficient.
(OpaqueJSClass::prototype): Use PassWeak<T> instead of set(), since
set() is gone now.
(JSC):
(PassWeak):
(JSC::PassWeak::PassWeak):
(JSC::PassWeak::~PassWeak):
(JSC::PassWeak::get):
(JSC::::leakHandle):
(JSC::adoptWeak):
(JSC::operator==):
(JSC::operator!=): This is the Weak<T> version of PassOwnPtr<T>.
(Weak):
(JSC::Weak::Weak):
(JSC::Weak::release):
(JSC::Weak::hashTableDeletedValue):
(JSC::=):
(JSC): Changed to be non-copyable, removing a lot of copying-related
APIs. Added hash traits so hash maps still work.
(JSC::JITThunks::hostFunctionStub):
(JSC::RegExpCache::lookupOrCreate): Use PassWeak<T>, as required by
our new hash map API.
Source/WebCore:
- bindings/js/JSDOMBinding.cpp:
(WebCore::jsStringSlowCase): Use PassWeak<T>, as required by our new
hash map API.
- bindings/js/JSDOMBinding.h:
(WebCore::getCachedWrapper):
(WebCore::cacheWrapper): Use PassWeak<T> and raw pointer, as required by
our new hash map API.
- bindings/js/JSEventListener.h:
(WebCore::JSEventListener::setWrapper):
- bindings/js/ScriptWrappable.h:
(WebCore::ScriptWrappable::setWrapper):
- bridge/jsc/BridgeJSC.cpp:
(JSC::Bindings::Instance::createRuntimeObject):
(JSC::Bindings::RootObject::addRuntimeObject): Use PassWeak<T>, as
required by our new hash map and Weak<T> APIs.
Source/WebKit2:
- WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:
(WebKit::NPRuntimeObjectMap::getOrCreateJSObject): Use raw pointer and
PassWeak<T>, as required by our new hash map API.