+2017-08-02 Joseph Pecoraro <pecoraro@apple.com>
+
+ NeverDestroyed related leaks seen on bots
+ https://bugs.webkit.org/show_bug.cgi?id=175113
+
+ Reviewed by Yusuke Suzuki.
+
+ * wtf/NeverDestroyed.h:
+ (WTF::NeverDestroyed::NeverDestroyed):
+ Previously the result of makeNeverDestroyed was not always moving into
+ the `static NeverDestroyed` static local variable. In some cases it would
+ re-invoke the constructor, creating a new NeverDestroyed object. In the
+ case of a Vector it was causing leaks.
+
+ Adding a move constructor convinces the compiler to move the result
+ of makeNeverDestroyed into the NeverDestroyed static. It doesn't actually
+ invoke the move constructor here, which I believe means it is deciding
+ to perform optional copy elision optimization.
+ 'http://en.cppreference.com/w/cpp/language/copy_elision
+
2017-08-02 Filip Pizlo <fpizlo@apple.com>
All C++ accesses to JSObject::m_butterfly should do caging
MaybeRelax<T>(new (storagePointer()) T(std::forward<Args>(args)...));
}
+ NeverDestroyed(NeverDestroyed&& other)
+ {
+ MaybeRelax<T>(new (storagePointer()) T(WTFMove(other)));
+ }
+
operator T&() { return *storagePointer(); }
T& get() { return *storagePointer(); }