Changeset 68414 in webkit


Ignore:
Timestamp:
Sep 27, 2010 12:18:17 PM (14 years ago)
Author:
andersca@apple.com
Message:

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.

Location:
trunk/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r68405 r68414  
     12010-09-26  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Alexey Proskuryakov and Adam Barth.
     4
     5        Add WTF_MAKE_NONCOPYABLE macro
     6        https://bugs.webkit.org/show_bug.cgi?id=46589
     7
     8        Going forward, we'd like to get rid of the Noncopyable and FastAllocBase classes. The
     9        reason for this is that the Itanium C++ ABI states that no empty classes of the same type
     10        can be laid out at the same offset in the class. This can result in objects getting larger
     11        which leads to memory regressions. (One example of this is the String class which grew by
     12        sizeof(void*) when both its base class and its first member variable inherited indirectly
     13        from FastAllocBase).
     14
     15        * wtf/Noncopyable.h:
     16        Add a WTF_MAKE_NONCOPYABLE macro and get rid of NoncopyableCustomAllocated.
     17       
     18        * runtime/JSCell.h:
     19        * wtf/RefCounted.h:
     20        Don't inherit from NoncopyableCustomAllocated. Instead, use WTF_MAKE_NONCOPYABLE.
     21
    1222010-09-27  Philippe Normand  <pnormand@igalia.com>
    223
  • trunk/JavaScriptCore/runtime/JSCell.h

    r65146 r68414  
    3535namespace JSC {
    3636
    37     class JSCell : public NoncopyableCustomAllocated {
     37    class JSCell {
     38        WTF_MAKE_NONCOPYABLE(JSCell);
     39
    3840        friend class GetterSetter;
    3941        friend class Heap;
  • trunk/JavaScriptCore/wtf/Noncopyable.h

    r46933 r68414  
    2222#define WTF_Noncopyable_h
    2323
     24#ifndef __has_feature
     25    #define __has_feature(x) 0
     26#endif
     27
     28#if __has_feature(cxx_deleted_functions)
     29    #define WTF_MAKE_NONCOPYABLE(ClassName) \
     30        _Pragma("clang diagnostic push") \
     31        _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") \
     32        _Pragma("clang diagnostic ignored \"-Wc++0x-extensions\"") \
     33        private: \
     34            ClassName(const ClassName&) = delete; \
     35            ClassName& operator=(const ClassName&) = delete; \
     36        _Pragma("clang diagnostic pop")
     37#else
     38    #define WTF_MAKE_NONCOPYABLE(ClassName) \
     39        private: \
     40            ClassName(const ClassName&); \
     41            ClassName& operator=(const ClassName&);
     42#endif
     43
    2444// We don't want argument-dependent lookup to pull in everything from the WTF
    2545// namespace when you use Noncopyable, so put it in its own namespace.
     
    3757    };
    3858
    39     class NoncopyableCustomAllocated {
    40         NoncopyableCustomAllocated(const NoncopyableCustomAllocated&);
    41         NoncopyableCustomAllocated& operator=(const NoncopyableCustomAllocated&);
    42     protected:
    43         NoncopyableCustomAllocated() { }
    44         ~NoncopyableCustomAllocated() { }
    45     };
    46 
    4759} // namespace WTFNoncopyable
    4860
    4961using WTFNoncopyable::Noncopyable;
    50 using WTFNoncopyable::NoncopyableCustomAllocated;
    5162
    5263#endif // WTF_Noncopyable_h
  • trunk/JavaScriptCore/wtf/RefCounted.h

    r62696 r68414  
    146146};
    147147
    148 template<typename T> class RefCountedCustomAllocated : public RefCountedBase, public NoncopyableCustomAllocated {
     148template<typename T> class RefCountedCustomAllocated : public RefCountedBase {
     149    WTF_MAKE_NONCOPYABLE(RefCountedCustomAllocated);
     150
    149151public:
    150152    void deref()
Note: See TracChangeset for help on using the changeset viewer.