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 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
845 static void init(); | 845 static void init(); |
846 static void shutdown(); | 846 static void shutdown(); |
847 static void doShutdown(); | 847 static void doShutdown(); |
848 | 848 |
849 #if ENABLE(ASSERT) | 849 #if ENABLE(ASSERT) |
850 static BaseHeapPage* findPageFromAddress(Address); | 850 static BaseHeapPage* findPageFromAddress(Address); |
851 static BaseHeapPage* findPageFromAddress(void* pointer) { return findPageFro mAddress(reinterpret_cast<Address>(pointer)); } | 851 static BaseHeapPage* findPageFromAddress(void* pointer) { return findPageFro mAddress(reinterpret_cast<Address>(pointer)); } |
852 static bool containedInHeapOrOrphanedPage(void*); | 852 static bool containedInHeapOrOrphanedPage(void*); |
853 #endif | 853 #endif |
854 | 854 |
855 // Is the finalizable GC object still alive? If no GC is in progress, | 855 // Is the finalizable GC object still alive, but slated for lazy sweeping? |
856 // it must be true. If a lazy sweep is in progress, it will be true if | 856 // If a lazy sweep is in progress, returns true if the object was found |
857 // the object hasn't been swept yet and it is marked, or it has | 857 // to be not reachable during the marking phase, but it has yet to be swept |
858 // been swept and it is still alive. | 858 // and finalized. The predicate returns false in all other cases. |
859 // | 859 // |
860 // isFinalizedObjectAlive() must not be used with already-finalized object | 860 // Holding a reference to an already-dead object is not a valid state |
861 // references. | 861 // to be in; willObjectBeLazilySwept() has undefined behavior if passed |
haraken
2015/01/22 09:29:29
Can we assert this by checking header->checkHeader
sof
2015/01/22 09:56:23
That would be helpful, added.
| |
862 // | 862 // such a reference. |
863 template<typename T> | 863 template<typename T> |
864 static bool isFinalizedObjectAlive(const T* objectPointer) | 864 static bool willObjectBeLazilySwept(const T* objectPointer) |
865 { | 865 { |
866 static_assert(IsGarbageCollectedType<T>::value, "only objects deriving f rom GarbageCollected can be used."); | 866 static_assert(IsGarbageCollectedType<T>::value, "only objects deriving f rom GarbageCollected can be used."); |
867 #if ENABLE(OILPAN) | 867 #if ENABLE(OILPAN) |
868 BaseHeapPage* page = pageFromObject(objectPointer); | 868 BaseHeapPage* page = pageFromObject(objectPointer); |
869 if (page->hasBeenSwept()) | 869 if (page->hasBeenSwept()) |
870 return true; | 870 return false; |
871 ASSERT(page->heap()->threadState()->isSweepingInProgress()); | 871 ASSERT(page->heap()->threadState()->isSweepingInProgress()); |
872 | 872 |
873 return ObjectAliveTrait<T>::isHeapObjectAlive(s_markingVisitor, const_ca st<T*>(objectPointer)); | 873 return !ObjectAliveTrait<T>::isHeapObjectAlive(s_markingVisitor, const_c ast<T*>(objectPointer)); |
874 #else | 874 #else |
875 // FIXME: remove when lazy sweeping is always on | 875 // FIXME: remove when lazy sweeping is always on |
876 // (cf. ThreadState::postGCProcessing()). | 876 // (cf. ThreadState::postGCProcessing()). |
877 return true; | 877 return false; |
878 #endif | 878 #endif |
879 } | 879 } |
880 | 880 |
881 // Push a trace callback on the marking stack. | 881 // Push a trace callback on the marking stack. |
882 static void pushTraceCallback(void* containerObject, TraceCallback); | 882 static void pushTraceCallback(void* containerObject, TraceCallback); |
883 | 883 |
884 // Push a trace callback on the post-marking callback stack. These | 884 // Push a trace callback on the post-marking callback stack. These |
885 // callbacks are called after normal marking (including ephemeron | 885 // callbacks are called after normal marking (including ephemeron |
886 // iteration). | 886 // iteration). |
887 static void pushPostMarkingCallback(void*, TraceCallback); | 887 static void pushPostMarkingCallback(void*, TraceCallback); |
(...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2428 template<typename T, size_t inlineCapacity> | 2428 template<typename T, size_t inlineCapacity> |
2429 struct GCInfoTrait<HeapVector<T, inlineCapacity>> : public GCInfoTrait<Vector<T, inlineCapacity, HeapAllocator>> { }; | 2429 struct GCInfoTrait<HeapVector<T, inlineCapacity>> : public GCInfoTrait<Vector<T, inlineCapacity, HeapAllocator>> { }; |
2430 template<typename T, size_t inlineCapacity> | 2430 template<typename T, size_t inlineCapacity> |
2431 struct GCInfoTrait<HeapDeque<T, inlineCapacity>> : public GCInfoTrait<Deque<T, i nlineCapacity, HeapAllocator>> { }; | 2431 struct GCInfoTrait<HeapDeque<T, inlineCapacity>> : public GCInfoTrait<Deque<T, i nlineCapacity, HeapAllocator>> { }; |
2432 template<typename T, typename U, typename V> | 2432 template<typename T, typename U, typename V> |
2433 struct GCInfoTrait<HeapHashCountedSet<T, U, V>> : public GCInfoTrait<HashCounted Set<T, U, V, HeapAllocator>> { }; | 2433 struct GCInfoTrait<HeapHashCountedSet<T, U, V>> : public GCInfoTrait<HashCounted Set<T, U, V, HeapAllocator>> { }; |
2434 | 2434 |
2435 } // namespace blink | 2435 } // namespace blink |
2436 | 2436 |
2437 #endif // Heap_h | 2437 #endif // Heap_h |
OLD | NEW |