OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 // GarbageCollected. | 911 // GarbageCollected. |
912 // | 912 // |
913 // Instances of GarbageCollectedFinalized will have their destructor | 913 // Instances of GarbageCollectedFinalized will have their destructor |
914 // called when the garbage collector determines that the object is no | 914 // called when the garbage collector determines that the object is no |
915 // longer reachable. | 915 // longer reachable. |
916 template<typename T> | 916 template<typename T> |
917 class GarbageCollectedFinalized : public GarbageCollected<T> { | 917 class GarbageCollectedFinalized : public GarbageCollected<T> { |
918 WTF_MAKE_NONCOPYABLE(GarbageCollectedFinalized); | 918 WTF_MAKE_NONCOPYABLE(GarbageCollectedFinalized); |
919 | 919 |
920 protected: | 920 protected: |
921 // Finalize is called when the object is freed from the heap. By | 921 // finalizeGarbageCollectedObject is called when the object is |
922 // default finalization means calling the destructor on the | 922 // freed from the heap. By default finalization means calling the |
923 // object. Finalize can be overridden to support calling the | 923 // destructor on the object. finalizeGarbageCollectedObject can be |
924 // destructor of a subclass. This is useful for objects without | 924 // overridden to support calling the destructor of a |
925 // vtables that require explicit dispatching. | 925 // subclass. This is useful for objects without vtables that |
926 void finalize() | 926 // require explicit dispatching. The name is intentionally a bit |
| 927 // long to make name conflicts less likely. |
| 928 void finalizeGarbageCollectedObject() |
927 { | 929 { |
928 static_cast<T*>(this)->~T(); | 930 static_cast<T*>(this)->~T(); |
929 } | 931 } |
930 | 932 |
931 GarbageCollectedFinalized() { } | 933 GarbageCollectedFinalized() { } |
932 ~GarbageCollectedFinalized() { } | 934 ~GarbageCollectedFinalized() { } |
933 | 935 |
934 template<typename U> friend struct HasFinalizer; | 936 template<typename U> friend struct HasFinalizer; |
935 template<typename U, bool> friend struct FinalizerTraitImpl; | 937 template<typename U, bool> friend struct FinalizerTraitImpl; |
936 }; | 938 }; |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1714 // to export. This forces it to export all the methods from ThreadHeap. | 1716 // to export. This forces it to export all the methods from ThreadHeap. |
1715 template<> void ThreadHeap<FinalizedHeapObjectHeader>::addPageToHeap(const GCInf
o*); | 1717 template<> void ThreadHeap<FinalizedHeapObjectHeader>::addPageToHeap(const GCInf
o*); |
1716 template<> void ThreadHeap<HeapObjectHeader>::addPageToHeap(const GCInfo*); | 1718 template<> void ThreadHeap<HeapObjectHeader>::addPageToHeap(const GCInfo*); |
1717 extern template class HEAP_EXPORT ThreadHeap<FinalizedHeapObjectHeader>; | 1719 extern template class HEAP_EXPORT ThreadHeap<FinalizedHeapObjectHeader>; |
1718 extern template class HEAP_EXPORT ThreadHeap<HeapObjectHeader>; | 1720 extern template class HEAP_EXPORT ThreadHeap<HeapObjectHeader>; |
1719 #endif | 1721 #endif |
1720 | 1722 |
1721 } | 1723 } |
1722 | 1724 |
1723 #endif // Heap_h | 1725 #endif // Heap_h |
OLD | NEW |