| 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 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 static void init(); | 765 static void init(); |
| 766 static void shutdown(); | 766 static void shutdown(); |
| 767 | 767 |
| 768 static BaseHeapPage* contains(Address); | 768 static BaseHeapPage* contains(Address); |
| 769 static BaseHeapPage* contains(void* pointer) { return contains(reinterpret_c
ast<Address>(pointer)); } | 769 static BaseHeapPage* contains(void* pointer) { return contains(reinterpret_c
ast<Address>(pointer)); } |
| 770 static BaseHeapPage* contains(const void* pointer) { return contains(const_c
ast<void*>(pointer)); } | 770 static BaseHeapPage* contains(const void* pointer) { return contains(const_c
ast<void*>(pointer)); } |
| 771 | 771 |
| 772 // Push a trace callback on the marking stack. | 772 // Push a trace callback on the marking stack. |
| 773 static void pushTraceCallback(void* containerObject, TraceCallback); | 773 static void pushTraceCallback(void* containerObject, TraceCallback); |
| 774 | 774 |
| 775 // Push a weak pointer callback on the weak callback | 775 // Add a weak pointer callback to the weak callback work list. General |
| 776 // stack. General object pointer callbacks are pushed on a thread | 776 // object pointer callbacks are added to a thread local weak callback work |
| 777 // local weak callback stack and the callback is called on the | 777 // list and the callback is called on the thread that owns the object, with |
| 778 // thread that owns the object. Cell pointer callbacks are pushed | 778 // the closure pointer as an argument. Most of the time, the closure and |
| 779 // on a static callback stack and the weak callback is performed | 779 // the containerObject can be the same thing, but the containerObject is |
| 780 // on the thread performing garbage collection. This is OK because | 780 // constrained to be on the heap, since the heap is used to identify the |
| 781 // cells are just cleared and no deallocation can happen. | 781 // correct thread. |
| 782 static void pushWeakObjectPointerCallback(void* containerObject, WeakPointer
Callback); | 782 static void pushWeakObjectPointerCallback(void* closure, void* containerObje
ct, WeakPointerCallback); |
| 783 |
| 784 // Similar to the more general pushWeakObjectPointerCallback, but cell |
| 785 // pointer callbacks are added to a static callback work list and the weak |
| 786 // callback is performed on the thread performing garbage collection. This |
| 787 // is OK because cells are just cleared and no deallocation can happen. |
| 783 static void pushWeakCellPointerCallback(void** cell, WeakPointerCallback); | 788 static void pushWeakCellPointerCallback(void** cell, WeakPointerCallback); |
| 784 | 789 |
| 785 // Pop the top of the marking stack and call the callback with the visitor | 790 // Pop the top of the marking stack and call the callback with the visitor |
| 786 // and the object. Returns false when there is nothing more to do. | 791 // and the object. Returns false when there is nothing more to do. |
| 787 static bool popAndInvokeTraceCallback(Visitor*); | 792 static bool popAndInvokeTraceCallback(Visitor*); |
| 788 | 793 |
| 789 // Pop the top of the weak callback stack and call the callback with the vis
itor | 794 // Remove an item from the weak callback work list and call the callback |
| 790 // and the object. Returns false when there is nothing more to do. | 795 // with the visitor and the closure pointer. Returns false when there is |
| 796 // nothing more to do. |
| 791 static bool popAndInvokeWeakPointerCallback(Visitor*); | 797 static bool popAndInvokeWeakPointerCallback(Visitor*); |
| 792 | 798 |
| 793 template<typename T> static Address allocate(size_t); | 799 template<typename T> static Address allocate(size_t); |
| 794 template<typename T> static Address reallocate(void* previous, size_t); | 800 template<typename T> static Address reallocate(void* previous, size_t); |
| 795 | 801 |
| 796 static void collectGarbage(ThreadState::StackState, GCType = Normal); | 802 static void collectGarbage(ThreadState::StackState, GCType = Normal); |
| 797 static void collectAllGarbage(ThreadState::StackState, GCType = Normal); | 803 static void collectAllGarbage(ThreadState::StackState, GCType = Normal); |
| 798 | 804 |
| 799 static void prepareForGC(); | 805 static void prepareForGC(); |
| 800 | 806 |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1256 { | 1262 { |
| 1257 return !visitor->isAlive(t); | 1263 return !visitor->isAlive(t); |
| 1258 } | 1264 } |
| 1259 | 1265 |
| 1260 template<typename T, typename U> | 1266 template<typename T, typename U> |
| 1261 static bool hasDeadMember(Visitor* visitor, const WTF::KeyValuePair<T, U>& t
) | 1267 static bool hasDeadMember(Visitor* visitor, const WTF::KeyValuePair<T, U>& t
) |
| 1262 { | 1268 { |
| 1263 return hasDeadMember(visitor, t.key) || hasDeadMember(visitor, t.value); | 1269 return hasDeadMember(visitor, t.key) || hasDeadMember(visitor, t.value); |
| 1264 } | 1270 } |
| 1265 | 1271 |
| 1266 static void registerWeakMembers(Visitor* visitor, const void* object, WeakPo
interCallback callback) | 1272 static void registerWeakMembers(Visitor* visitor, const void* closure, const
void* object, WeakPointerCallback callback) |
| 1267 { | 1273 { |
| 1268 visitor->registerWeakMembers(object, callback); | 1274 visitor->registerWeakMembers(closure, object, callback); |
| 1269 } | 1275 } |
| 1270 | 1276 |
| 1271 template<typename T> | 1277 template<typename T> |
| 1272 struct ResultType { | 1278 struct ResultType { |
| 1273 typedef T* Type; | 1279 typedef T* Type; |
| 1274 }; | 1280 }; |
| 1275 | 1281 |
| 1276 // The WTF classes use Allocator::VectorBackingHelper in order to find a | 1282 // The WTF classes use Allocator::VectorBackingHelper in order to find a |
| 1277 // class to template their backing allocation operation on. For off-heap | 1283 // class to template their backing allocation operation on. For off-heap |
| 1278 // allocations the VectorBackingHelper is a dummy class, since the class is | 1284 // allocations the VectorBackingHelper is a dummy class, since the class is |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1709 // to export. This forces it to export all the methods from ThreadHeap. | 1715 // to export. This forces it to export all the methods from ThreadHeap. |
| 1710 template<> void ThreadHeap<FinalizedHeapObjectHeader>::addPageToHeap(const GCInf
o*); | 1716 template<> void ThreadHeap<FinalizedHeapObjectHeader>::addPageToHeap(const GCInf
o*); |
| 1711 template<> void ThreadHeap<HeapObjectHeader>::addPageToHeap(const GCInfo*); | 1717 template<> void ThreadHeap<HeapObjectHeader>::addPageToHeap(const GCInfo*); |
| 1712 extern template class HEAP_EXPORT ThreadHeap<FinalizedHeapObjectHeader>; | 1718 extern template class HEAP_EXPORT ThreadHeap<FinalizedHeapObjectHeader>; |
| 1713 extern template class HEAP_EXPORT ThreadHeap<HeapObjectHeader>; | 1719 extern template class HEAP_EXPORT ThreadHeap<HeapObjectHeader>; |
| 1714 #endif | 1720 #endif |
| 1715 | 1721 |
| 1716 } | 1722 } |
| 1717 | 1723 |
| 1718 #endif // Heap_h | 1724 #endif // Heap_h |
| OLD | NEW |