Commit c21b1344 authored by andersca@apple.com's avatar andersca@apple.com

Stop using PassWeak

https://bugs.webkit.org/show_bug.cgi?id=121968

Reviewed by Sam Weinig.

Source/JavaScriptCore:

* heap/Weak.h:
Remove all knowledge of PassWeak.

(JSC::Weak::Weak):
These constructors don't need to be explicit.

* heap/WeakInlines.h:
(JSC::weakAdd):
Change Value to be an rvalue reference and use std::forward.

* jit/JITThunks.cpp:
(JSC::JITThunks::hostFunctionStub):
Remove PassWeak.

* runtime/RegExpCache.cpp:
(JSC::RegExpCache::lookupOrCreate):
Use Weak instead of PassWeak.

* runtime/SimpleTypedArrayController.cpp:
Change add and set to take Weak by value and std::move into place.

* runtime/WeakGCMap.h:
(JSC::WeakGCMap::get):
(JSC::WeakGCMap::set):
(JSC::WeakGCMap::add):

Source/WebCore:

Update for JavaScriptCore changes.

* bindings/js/JSDOMBinding.h:
(WebCore::setInlineCachedWrapper):
(WebCore::cacheWrapper):
* bindings/js/JSEventListener.cpp:
(WebCore::JSEventListener::JSEventListener):
* bindings/js/JSEventListener.h:
(WebCore::JSEventListener::setWrapper):
(WebCore::JSEventListener::jsFunction):
* bindings/js/JSMutationCallback.cpp:
(WebCore::JSMutationCallback::JSMutationCallback):
* bindings/js/JSNodeFilterCondition.cpp:
(WebCore::JSNodeFilterCondition::JSNodeFilterCondition):
* bindings/js/ScriptWrappableInlines.h:
(WebCore::ScriptWrappable::setWrapper):
* bindings/js/WebCoreTypedArrayController.cpp:
* bridge/jsc/BridgeJSC.cpp:
(JSC::Bindings::Instance::createRuntimeObject):
* bridge/runtime_root.cpp:
(JSC::Bindings::RootObject::addRuntimeObject):

Source/WebKit2:

Update for JavaScriptCore changes.

* WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:
(WebKit::NPRuntimeObjectMap::getOrCreateJSObject):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156487 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7552b8c5
2013-09-26 Anders Carlsson <andersca@apple.com>
Stop using PassWeak
https://bugs.webkit.org/show_bug.cgi?id=121968
Reviewed by Sam Weinig.
* heap/Weak.h:
Remove all knowledge of PassWeak.
(JSC::Weak::Weak):
These constructors don't need to be explicit.
* heap/WeakInlines.h:
(JSC::weakAdd):
Change Value to be an rvalue reference and use std::forward.
* jit/JITThunks.cpp:
(JSC::JITThunks::hostFunctionStub):
Remove PassWeak.
* runtime/RegExpCache.cpp:
(JSC::RegExpCache::lookupOrCreate):
Use Weak instead of PassWeak.
* runtime/SimpleTypedArrayController.cpp:
Change add and set to take Weak by value and std::move into place.
* runtime/WeakGCMap.h:
(JSC::WeakGCMap::get):
(JSC::WeakGCMap::set):
(JSC::WeakGCMap::add):
2013-09-26 Commit Queue <commit-queue@webkit.org>
Unreviewed, rolling out r156474.
......@@ -31,7 +31,6 @@
namespace JSC {
template<typename T> class PassWeak;
class WeakImpl;
class WeakHandleOwner;
......@@ -46,19 +45,18 @@ public:
{
}
explicit Weak(std::nullptr_t)
Weak(std::nullptr_t)
: m_impl(0)
{
}
explicit Weak(T*, WeakHandleOwner* = 0, void* context = 0);
Weak(T*, WeakHandleOwner* = 0, void* context = 0);
enum HashTableDeletedValueTag { HashTableDeletedValue };
bool isHashTableDeletedValue() const;
Weak(HashTableDeletedValueTag);
Weak(Weak&&);
template<typename U> Weak(const PassWeak<U>&);
~Weak()
{
......@@ -68,8 +66,7 @@ public:
void swap(Weak&);
Weak& operator=(Weak&&);
Weak& operator=(const PassWeak<T>&);
bool operator!() const;
T* operator->() const;
T& operator*() const;
......@@ -81,7 +78,6 @@ public:
typedef void* (Weak::*UnspecifiedBoolType);
operator UnspecifiedBoolType*() const;
PassWeak<T> release();
WeakImpl* leakImpl() WARN_UNUSED_RETURN;
void clear()
{
......
......@@ -48,11 +48,6 @@ template<typename T> inline Weak<T>::Weak(typename Weak<T>::HashTableDeletedValu
{
}
template<typename T> template<typename U> inline Weak<T>::Weak(const PassWeak<U>& other)
: m_impl(other.leakImpl())
{
}
template<typename T> inline Weak<T>::Weak(Weak&& other)
: m_impl(other.leakImpl())
{
......@@ -68,13 +63,6 @@ template<typename T> inline void Weak<T>::swap(Weak& other)
std::swap(m_impl, other.m_impl);
}
template<typename T> inline Weak<T>& Weak<T>::operator=(const PassWeak<T>& o)
{
clear();
m_impl = o.leakImpl();
return *this;
}
template<typename T> inline auto Weak<T>::operator=(Weak&& other) -> Weak&
{
Weak weak = std::move(other);
......@@ -116,13 +104,6 @@ template<typename T> inline Weak<T>::operator UnspecifiedBoolType*() const
return reinterpret_cast<UnspecifiedBoolType*>(!!*this);
}
template<typename T> inline PassWeak<T> Weak<T>::release()
{
PassWeak<T> tmp = adoptWeak<T>(m_impl);
m_impl = 0;
return tmp;
}
template<typename T> inline WeakImpl* Weak<T>::leakImpl()
{
WeakImpl* impl = m_impl;
......@@ -142,10 +123,10 @@ template <typename T> inline bool operator==(const Weak<T>& lhs, const Weak<T>&
// This function helps avoid modifying a weak table while holding an iterator into it. (Object allocation
// can run a finalizer that modifies the table. We avoid that by requiring a pre-constructed object as our value.)
template<typename Map, typename Key, typename Value> inline void weakAdd(Map& map, const Key& key, Value value)
template<typename Map, typename Key, typename Value> inline void weakAdd(Map& map, const Key& key, Value&& value)
{
ASSERT(!map.get(key));
map.set(key, value); // The table may still have a zombie for value.
map.set(key, std::forward<Value>(value)); // The table may still have a zombie for value.
}
template<typename Map, typename Key, typename Value> inline void weakRemove(Map& map, const Key& key, Value value)
......
......@@ -81,7 +81,7 @@ NativeExecutable* JITThunks::hostFunctionStub(VM* vm, NativeFunction function, N
return nativeExecutable;
NativeExecutable* nativeExecutable = NativeExecutable::create(*vm, JIT::compileCTINativeCall(vm, function), function, MacroAssemblerCodeRef::createSelfManagedCodeRef(ctiNativeConstruct(vm)), constructor, NoIntrinsic);
weakAdd(*m_hostFunctionStubMap, std::make_pair(function, constructor), PassWeak<NativeExecutable>(nativeExecutable));
weakAdd(*m_hostFunctionStubMap, std::make_pair(function, constructor), nativeExecutable);
return nativeExecutable;
}
......@@ -102,7 +102,7 @@ NativeExecutable* JITThunks::hostFunctionStub(VM* vm, NativeFunction function, T
code = JIT::compileCTINativeCall(vm, function);
NativeExecutable* nativeExecutable = NativeExecutable::create(*vm, code, function, MacroAssemblerCodeRef::createSelfManagedCodeRef(ctiNativeConstruct(vm)), callHostFunctionAsConstructor, intrinsic);
weakAdd(*m_hostFunctionStubMap, std::make_pair(function, &callHostFunctionAsConstructor), PassWeak<NativeExecutable>(nativeExecutable));
weakAdd(*m_hostFunctionStubMap, std::make_pair(function, &callHostFunctionAsConstructor), nativeExecutable);
return nativeExecutable;
}
......
......@@ -46,7 +46,7 @@ RegExp* RegExpCache::lookupOrCreate(const String& patternString, RegExpFlags fla
m_vm->addRegExpToTrace(regExp);
#endif
weakAdd(m_weakCache, key, PassWeak<RegExp>(regExp, this));
weakAdd(m_weakCache, key, Weak<RegExp>(regExp, this));
return regExp;
}
......
......@@ -29,7 +29,6 @@
#include "ArrayBuffer.h"
#include "JSArrayBuffer.h"
#include "Operations.h"
#include "PassWeak.h"
namespace JSC {
......
......@@ -34,13 +34,11 @@ namespace JSC {
// A HashMap with Weak<JSCell> values, which automatically removes values once they're garbage collected.
template<typename KeyArg, typename RawMappedArg, typename HashArg = typename DefaultHash<KeyArg>::Hash,
template<typename KeyArg, typename ValueArg, typename HashArg = typename DefaultHash<KeyArg>::Hash,
typename KeyTraitsArg = HashTraits<KeyArg>>
class WeakGCMap {
typedef Weak<RawMappedArg> MappedType;
typedef HashMap<KeyArg, MappedType, HashArg, KeyTraitsArg> HashMapType;
typedef HashTraits<MappedType> MappedTraits;
typedef typename MappedTraits::PassInType MappedPassInType;
typedef Weak<ValueArg> ValueType;
typedef HashMap<KeyArg, ValueType, HashArg, KeyTraitsArg> HashMapType;
public:
typedef typename HashMapType::KeyType KeyType;
......@@ -53,24 +51,24 @@ public:
{
}
RawMappedArg* get(const KeyType& key) const
ValueArg* get(const KeyType& key) const
{
return m_map.get(key);
}
AddResult set(const KeyType& key, MappedPassInType value)
AddResult set(const KeyType& key, ValueType value)
{
gcMapIfNeeded();
return m_map.set(key, value);
return m_map.set(key, std::move(value));
}
AddResult add(const KeyType& key, MappedPassInType value)
AddResult add(const KeyType& key, ValueType value)
{
gcMapIfNeeded();
AddResult addResult = m_map.add(key, nullptr);
if (!addResult.iterator->value) { // New value or found a zombie value.
addResult.isNewEntry = true;
addResult.iterator->value = value;
addResult.iterator->value = std::move(value);
}
return addResult;
}
......
2013-09-26 Anders Carlsson <andersca@apple.com>
Stop using PassWeak
https://bugs.webkit.org/show_bug.cgi?id=121968
Reviewed by Sam Weinig.
Update for JavaScriptCore changes.
* bindings/js/JSDOMBinding.h:
(WebCore::setInlineCachedWrapper):
(WebCore::cacheWrapper):
* bindings/js/JSEventListener.cpp:
(WebCore::JSEventListener::JSEventListener):
* bindings/js/JSEventListener.h:
(WebCore::JSEventListener::setWrapper):
(WebCore::JSEventListener::jsFunction):
* bindings/js/JSMutationCallback.cpp:
(WebCore::JSMutationCallback::JSMutationCallback):
* bindings/js/JSNodeFilterCondition.cpp:
(WebCore::JSNodeFilterCondition::JSNodeFilterCondition):
* bindings/js/ScriptWrappableInlines.h:
(WebCore::ScriptWrappable::setWrapper):
* bindings/js/WebCoreTypedArrayController.cpp:
* bridge/jsc/BridgeJSC.cpp:
(JSC::Bindings::Instance::createRuntimeObject):
* bridge/runtime_root.cpp:
(JSC::Bindings::RootObject::addRuntimeObject):
2013-09-25 Sam Weinig <sam@webkit.org>
Pass a JSC::VM& to JS bindings object creation functions, rather than a JSC::ExecState*
......@@ -152,7 +152,7 @@ class DOMStringList;
{
if (!world->isNormal())
return false;
domObject->m_wrapper = JSC::PassWeak<JSC::JSArrayBuffer>(wrapper, wrapperOwner, context);
domObject->m_wrapper = JSC::Weak<JSC::JSArrayBuffer>(wrapper, wrapperOwner, context);
return true;
}
......@@ -185,8 +185,7 @@ class DOMStringList;
void* context = wrapperContext(world, domObject);
if (setInlineCachedWrapper(world, domObject, wrapper, owner, context))
return;
JSC::PassWeak<JSC::JSObject> passWeak(wrapper, owner, context);
weakAdd(world->m_wrappers, (void*)domObject, passWeak);
weakAdd(world->m_wrappers, (void*)domObject, JSC::Weak<JSC::JSObject>(wrapper, owner, context));
}
template <typename DOMClass, typename WrapperClass> inline void uncacheWrapper(DOMWrapperWorld* world, DOMClass* domObject, WrapperClass* wrapper)
......
......@@ -47,7 +47,7 @@ JSEventListener::JSEventListener(JSObject* function, JSObject* wrapper, bool isA
{
if (wrapper) {
JSC::Heap::writeBarrier(wrapper, function);
m_jsFunction = JSC::PassWeak<JSC::JSObject>(function);
m_jsFunction = function;
} else
ASSERT(!function);
#if ENABLE(INSPECTOR)
......
......@@ -22,7 +22,6 @@
#include "EventListener.h"
#include "JSDOMWindow.h"
#include <heap/PassWeak.h>
#include <heap/StrongInlines.h>
#include <heap/Weak.h>
#include <heap/WeakInlines.h>
......@@ -57,7 +56,7 @@ namespace WebCore {
DOMWrapperWorld* isolatedWorld() const { return m_isolatedWorld.get(); }
JSC::JSObject* wrapper() const { return m_wrapper.get(); }
void setWrapper(JSC::VM&, JSC::JSObject* wrapper) const { m_wrapper = JSC::PassWeak<JSC::JSObject>(wrapper); }
void setWrapper(JSC::VM&, JSC::JSObject* wrapper) const { m_wrapper = JSC::Weak<JSC::JSObject>(wrapper); }
private:
virtual JSC::JSObject* initializeJSFunction(ScriptExecutionContext*) const;
......@@ -86,7 +85,7 @@ namespace WebCore {
if (!m_jsFunction) {
JSC::JSObject* function = initializeJSFunction(scriptExecutionContext);
JSC::Heap::writeBarrier(m_wrapper.get(), function);
m_jsFunction = JSC::PassWeak<JSC::JSObject>(function);
m_jsFunction = function;
}
// Verify that we have a valid wrapper protecting our function from
......
......@@ -42,7 +42,7 @@ namespace WebCore {
JSMutationCallback::JSMutationCallback(JSObject* callback, JSDOMGlobalObject* globalObject)
: ActiveDOMCallback(globalObject->scriptExecutionContext())
, m_callback(PassWeak<JSObject>(callback))
, m_callback(callback)
, m_isolatedWorld(globalObject->world())
{
}
......
......@@ -32,7 +32,7 @@ namespace WebCore {
using namespace JSC;
JSNodeFilterCondition::JSNodeFilterCondition(VM&, NodeFilter* owner, JSValue filter)
: m_filter(filter.isObject() ? PassWeak<JSObject>(jsCast<JSObject*>(filter), &m_weakOwner, owner) : nullptr)
: m_filter(filter.isObject() ? Weak<JSObject>(jsCast<JSObject*>(filter), &m_weakOwner, owner) : nullptr)
{
}
......
......@@ -46,7 +46,7 @@ inline JSDOMWrapper* ScriptWrappable::wrapper() const
inline void ScriptWrappable::setWrapper(JSDOMWrapper* wrapper, JSC::WeakHandleOwner* wrapperOwner, void* context)
{
ASSERT(!m_wrapper);
m_wrapper = JSC::PassWeak<JSDOMWrapper>(wrapper, wrapperOwner, context);
m_wrapper = JSC::Weak<JSDOMWrapper>(wrapper, wrapperOwner, context);
}
inline void ScriptWrappable::clearWrapper(JSDOMWrapper* wrapper)
......
......@@ -28,7 +28,6 @@
#include "JSDOMBinding.h"
#include "JSDOMGlobalObject.h"
#include <heap/PassWeak.h>
#include <runtime/ArrayBuffer.h>
#include <runtime/JSArrayBuffer.h>
#include <runtime/Operations.h>
......
......@@ -82,7 +82,7 @@ JSObject* Instance::createRuntimeObject(ExecState* exec)
JSLockHolder lock(exec);
RuntimeObject* newObject = newRuntimeObject(exec);
m_runtimeObject = PassWeak<RuntimeObject>(newObject);
m_runtimeObject = newObject;
m_rootObject->addRuntimeObject(exec->vm(), newObject);
return newObject;
}
......
......@@ -188,7 +188,7 @@ void RootObject::updateGlobalObject(JSGlobalObject* globalObject)
void RootObject::addRuntimeObject(VM&, RuntimeObject* object)
{
ASSERT(m_isValid);
weakAdd(m_runtimeObjects, object, JSC::PassWeak<RuntimeObject>(object, this));
weakAdd(m_runtimeObjects, object, JSC::Weak<RuntimeObject>(object, this));
}
void RootObject::removeRuntimeObject(RuntimeObject* object)
......
2013-09-26 Anders Carlsson <andersca@apple.com>
Stop using PassWeak
https://bugs.webkit.org/show_bug.cgi?id=121968
Reviewed by Sam Weinig.
Update for JavaScriptCore changes.
* WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:
(WebKit::NPRuntimeObjectMap::getOrCreateJSObject):
2013-09-25 Jer Noble <jer.noble@apple.com>
[WK2] Crash at at com.apple.WebKit2: WebKit::VoidCallback::invalidate + 46
......
......@@ -108,7 +108,7 @@ JSObject* NPRuntimeObjectMap::getOrCreateJSObject(JSGlobalObject* globalObject,
return jsNPObject;
JSNPObject* jsNPObject = JSNPObject::create(globalObject, this, npObject);
weakAdd(m_jsNPObjects, npObject, JSC::PassWeak<JSNPObject>(jsNPObject, this, npObject));
weakAdd(m_jsNPObjects, npObject, JSC::Weak<JSNPObject>(jsNPObject, this, npObject));
return jsNPObject;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment