Skip to content
  • ggaren@apple.com's avatar
    Made Weak<T> single-owner, adding PassWeak<T> · 20d50256
    ggaren@apple.com authored
    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.
    
    * API/JSClassRef.cpp:
    (OpaqueJSClass::prototype): Use PassWeak<T> instead of set(), since 
    set() is gone now.
    
    * JavaScriptCore.xcodeproj/project.pbxproj: Export!
    
    * heap/PassWeak.h: Added.
    (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>.
    
    * heap/Weak.h:
    (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.
    
    * jit/JITStubs.cpp:
    (JSC::JITThunks::hostFunctionStub):
    * runtime/RegExpCache.cpp:
    (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):
    * bridge/runtime_root.cpp:
    (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.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@108010 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    20d50256