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 |
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(ASSERT) |
| 868 ASSERT(objectPointer); |
| 869 HeapObjectHeader::fromPayload(objectPointer)->checkHeader(); |
| 870 #endif |
867 #if ENABLE(OILPAN) | 871 #if ENABLE(OILPAN) |
868 BaseHeapPage* page = pageFromObject(objectPointer); | 872 BaseHeapPage* page = pageFromObject(objectPointer); |
869 if (page->hasBeenSwept()) | 873 if (page->hasBeenSwept()) |
870 return true; | 874 return false; |
871 ASSERT(page->heap()->threadState()->isSweepingInProgress()); | 875 ASSERT(page->heap()->threadState()->isSweepingInProgress()); |
872 | 876 |
873 return ObjectAliveTrait<T>::isHeapObjectAlive(s_markingVisitor, const_ca
st<T*>(objectPointer)); | 877 return !ObjectAliveTrait<T>::isHeapObjectAlive(s_markingVisitor, const_c
ast<T*>(objectPointer)); |
874 #else | 878 #else |
875 // FIXME: remove when lazy sweeping is always on | 879 // FIXME: remove when lazy sweeping is always on |
876 // (cf. ThreadState::postGCProcessing()). | 880 // (cf. ThreadState::postGCProcessing()). |
877 return true; | 881 return false; |
878 #endif | 882 #endif |
879 } | 883 } |
880 | 884 |
881 // Push a trace callback on the marking stack. | 885 // Push a trace callback on the marking stack. |
882 static void pushTraceCallback(void* containerObject, TraceCallback); | 886 static void pushTraceCallback(void* containerObject, TraceCallback); |
883 | 887 |
884 // Push a trace callback on the post-marking callback stack. These | 888 // Push a trace callback on the post-marking callback stack. These |
885 // callbacks are called after normal marking (including ephemeron | 889 // callbacks are called after normal marking (including ephemeron |
886 // iteration). | 890 // iteration). |
887 static void pushPostMarkingCallback(void*, TraceCallback); | 891 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> | 2432 template<typename T, size_t inlineCapacity> |
2429 struct GCInfoTrait<HeapVector<T, inlineCapacity>> : public GCInfoTrait<Vector<T,
inlineCapacity, HeapAllocator>> { }; | 2433 struct GCInfoTrait<HeapVector<T, inlineCapacity>> : public GCInfoTrait<Vector<T,
inlineCapacity, HeapAllocator>> { }; |
2430 template<typename T, size_t inlineCapacity> | 2434 template<typename T, size_t inlineCapacity> |
2431 struct GCInfoTrait<HeapDeque<T, inlineCapacity>> : public GCInfoTrait<Deque<T, i
nlineCapacity, HeapAllocator>> { }; | 2435 struct GCInfoTrait<HeapDeque<T, inlineCapacity>> : public GCInfoTrait<Deque<T, i
nlineCapacity, HeapAllocator>> { }; |
2432 template<typename T, typename U, typename V> | 2436 template<typename T, typename U, typename V> |
2433 struct GCInfoTrait<HeapHashCountedSet<T, U, V>> : public GCInfoTrait<HashCounted
Set<T, U, V, HeapAllocator>> { }; | 2437 struct GCInfoTrait<HeapHashCountedSet<T, U, V>> : public GCInfoTrait<HashCounted
Set<T, U, V, HeapAllocator>> { }; |
2434 | 2438 |
2435 } // namespace blink | 2439 } // namespace blink |
2436 | 2440 |
2437 #endif // Heap_h | 2441 #endif // Heap_h |
OLD | NEW |