File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -207,6 +207,6 @@ JSObject* OpaqueJSClass::prototype(ExecState* exec)
207207 prototype->setPrototype (exec->vm (), parentPrototype);
208208 }
209209
210- jsClassData.cachedPrototype = PassWeak <JSObject>(prototype);
210+ jsClassData.cachedPrototype = Weak <JSObject>(prototype);
211211 return prototype;
212212}
Original file line number Diff line number Diff line change 1+ 2013-09-26 Anders Carlsson <andersca@apple.com>
2+
3+ Weak should have a move constructor and move assignment operator
4+ https://bugs.webkit.org/show_bug.cgi?id=121963
5+
6+ Reviewed by Oliver Hunt.
7+
8+ This is the first step towards getting rid of PassWeak.
9+
10+ * API/JSClassRef.cpp:
11+ (OpaqueJSClass::prototype):
12+ * heap/Weak.h:
13+ * heap/WeakInlines.h:
14+ (JSC::::Weak):
15+ (JSC::::leakImpl):
16+ * runtime/SimpleTypedArrayController.cpp:
17+ (JSC::SimpleTypedArrayController::toJS):
18+
1192013-09-26 Mark Hahnenberg <mhahnenberg@apple.com>
220
321 op_to_this shouldn't use value profiling
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ template<typename T> class Weak {
5757 bool isHashTableDeletedValue () const ;
5858 Weak (HashTableDeletedValueTag);
5959
60+ Weak (Weak&&);
6061 template <typename U> Weak (const PassWeak<U>&);
6162
6263 ~Weak ()
@@ -65,6 +66,8 @@ template<typename T> class Weak {
6566 }
6667
6768 void swap (Weak&);
69+
70+ Weak& operator =(Weak&&);
6871 Weak& operator =(const PassWeak<T>&);
6972
7073 bool operator !() const ;
@@ -79,6 +82,7 @@ template<typename T> class Weak {
7982 operator UnspecifiedBoolType*() const ;
8083
8184 PassWeak<T> release ();
85+ WeakImpl* leakImpl () WARN_UNUSED_RETURN;
8286 void clear ()
8387 {
8488 if (!m_impl)
Original file line number Diff line number Diff line change @@ -53,6 +53,11 @@ template<typename T> template<typename U> inline Weak<T>::Weak(const PassWeak<U
5353{
5454}
5555
56+ template <typename T> inline Weak<T>::Weak(Weak&& other)
57+ : m_impl(other.leakImpl())
58+ {
59+ }
60+
5661template <class T > inline void swap (Weak<T>& a, Weak<T>& b)
5762{
5863 a.swap (b);
@@ -70,6 +75,13 @@ template<typename T> inline Weak<T>& Weak<T>::operator=(const PassWeak<T>& o)
7075 return *this ;
7176}
7277
78+ template <typename T> inline auto Weak<T>::operator =(Weak&& other) -> Weak&
79+ {
80+ Weak weak = std::move (other);
81+ swap (weak);
82+ return *this ;
83+ }
84+
7385template <typename T> inline T* Weak<T>::operator ->() const
7486{
7587 ASSERT (m_impl && m_impl->state () == WeakImpl::Live);
@@ -111,6 +123,13 @@ template<typename T> inline PassWeak<T> Weak<T>::release()
111123 return tmp;
112124}
113125
126+ template <typename T> inline WeakImpl* Weak<T>::leakImpl()
127+ {
128+ WeakImpl* impl = m_impl;
129+ m_impl = nullptr ;
130+ return impl;
131+ }
132+
114133template <typename T> inline WeakImpl* Weak<T>::hashTableDeletedValue()
115134{
116135 return reinterpret_cast <WeakImpl*>(-1 );
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ JSArrayBuffer* SimpleTypedArrayController::toJS(
4444
4545 JSArrayBuffer* result = JSArrayBuffer::create (
4646 exec->vm (), globalObject->arrayBufferStructure (), native);
47- native->m_wrapper = PassWeak <JSArrayBuffer>(result);
47+ native->m_wrapper = Weak <JSArrayBuffer>(result);
4848 return result;
4949}
5050
You can’t perform that action at this time.
0 commit comments