Changeset 108010 in webkit for trunk/Source/JavaScriptCore/API


Ignore:
Timestamp:
Feb 16, 2012, 5:56:13 PM (13 years ago)
Author:
[email protected]
Message:

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.

  • API/JSClassRef.cpp:

(OpaqueJSClass::prototype): Use PassWeak<T> instead of set(), since
set() is gone now.

  • 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSClassRef.cpp

    r103157 r108010  
    223223    if (!jsClassData.cachedPrototype) {
    224224        // Recursive, but should be good enough for our purposes
    225         jsClassData.cachedPrototype.set(exec->globalData(), JSCallbackObject<JSNonFinalObject>::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackObjectStructure(), prototypeClass, &jsClassData), 0); // set jsClassData as the object's private data, so it can clear our reference on destruction
     225        jsClassData.cachedPrototype = PassWeak<JSObject>(exec->globalData(), JSCallbackObject<JSNonFinalObject>::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackObjectStructure(), prototypeClass, &jsClassData), 0); // set jsClassData as the object's private data, so it can clear our reference on destruction
    226226        if (parentClass) {
    227227            if (JSObject* prototype = parentClass->prototype(exec))
Note: See TracChangeset for help on using the changeset viewer.