Skip to content
Permalink
Browse files
Add WTF_MAKE_NONCOPYABLE macro
https://bugs.webkit.org/show_bug.cgi?id=46589

Reviewed by Alexey Proskuryakov and Adam Barth.

Going forward, we'd like to get rid of the Noncopyable and FastAllocBase classes. The
reason for this is that the Itanium C++ ABI states that no empty classes of the same type
can be laid out at the same offset in the class. This can result in objects getting larger
which leads to memory regressions. (One example of this is the String class which grew by
sizeof(void*) when both its base class and its first member variable inherited indirectly
from FastAllocBase).

* wtf/Noncopyable.h:
Add a WTF_MAKE_NONCOPYABLE macro and get rid of NoncopyableCustomAllocated.

* runtime/JSCell.h:
* wtf/RefCounted.h:
Don't inherit from NoncopyableCustomAllocated. Instead, use WTF_MAKE_NONCOPYABLE.

Canonical link: https://commits.webkit.org/59104@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@68414 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Anders Carlsson committed Sep 27, 2010
1 parent 4e81a80 commit 3af4b634e2096fedf587ee1d17ab4bd47bcb444f
Showing 4 changed files with 47 additions and 11 deletions.
@@ -1,3 +1,24 @@
2010-09-26 Anders Carlsson <andersca@apple.com>

Reviewed by Alexey Proskuryakov and Adam Barth.

Add WTF_MAKE_NONCOPYABLE macro
https://bugs.webkit.org/show_bug.cgi?id=46589

Going forward, we'd like to get rid of the Noncopyable and FastAllocBase classes. The
reason for this is that the Itanium C++ ABI states that no empty classes of the same type
can be laid out at the same offset in the class. This can result in objects getting larger
which leads to memory regressions. (One example of this is the String class which grew by
sizeof(void*) when both its base class and its first member variable inherited indirectly
from FastAllocBase).

* wtf/Noncopyable.h:
Add a WTF_MAKE_NONCOPYABLE macro and get rid of NoncopyableCustomAllocated.

* runtime/JSCell.h:
* wtf/RefCounted.h:
Don't inherit from NoncopyableCustomAllocated. Instead, use WTF_MAKE_NONCOPYABLE.

2010-09-27 Philippe Normand <pnormand@igalia.com>

Reviewed by Martin Robinson.
@@ -34,7 +34,9 @@

namespace JSC {

class JSCell : public NoncopyableCustomAllocated {
class JSCell {
WTF_MAKE_NONCOPYABLE(JSCell);

friend class GetterSetter;
friend class Heap;
friend class JIT;
@@ -21,6 +21,26 @@
#ifndef WTF_Noncopyable_h
#define WTF_Noncopyable_h

#ifndef __has_feature
#define __has_feature(x) 0
#endif

#if __has_feature(cxx_deleted_functions)
#define WTF_MAKE_NONCOPYABLE(ClassName) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") \
_Pragma("clang diagnostic ignored \"-Wc++0x-extensions\"") \
private: \
ClassName(const ClassName&) = delete; \
ClassName& operator=(const ClassName&) = delete; \
_Pragma("clang diagnostic pop")
#else
#define WTF_MAKE_NONCOPYABLE(ClassName) \
private: \
ClassName(const ClassName&); \
ClassName& operator=(const ClassName&);
#endif

// We don't want argument-dependent lookup to pull in everything from the WTF
// namespace when you use Noncopyable, so put it in its own namespace.

@@ -36,17 +56,8 @@ namespace WTFNoncopyable {
~Noncopyable() { }
};

class NoncopyableCustomAllocated {
NoncopyableCustomAllocated(const NoncopyableCustomAllocated&);
NoncopyableCustomAllocated& operator=(const NoncopyableCustomAllocated&);
protected:
NoncopyableCustomAllocated() { }
~NoncopyableCustomAllocated() { }
};

} // namespace WTFNoncopyable

using WTFNoncopyable::Noncopyable;
using WTFNoncopyable::NoncopyableCustomAllocated;

#endif // WTF_Noncopyable_h
@@ -145,7 +145,9 @@ template<typename T> class RefCounted : public RefCountedBase, public Noncopyabl
}
};

template<typename T> class RefCountedCustomAllocated : public RefCountedBase, public NoncopyableCustomAllocated {
template<typename T> class RefCountedCustomAllocated : public RefCountedBase {
WTF_MAKE_NONCOPYABLE(RefCountedCustomAllocated);

public:
void deref()
{

0 comments on commit 3af4b63

Please sign in to comment.