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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 #else | 90 #else |
91 const size_t sizeMask = ~static_cast<size_t>(7); | 91 const size_t sizeMask = ~static_cast<size_t>(7); |
92 #endif | 92 #endif |
93 const uint8_t freelistZapValue = 42; | 93 const uint8_t freelistZapValue = 42; |
94 const uint8_t finalizedZapValue = 24; | 94 const uint8_t finalizedZapValue = 24; |
95 // The orphaned zap value must be zero in the lowest bits to allow for using | 95 // The orphaned zap value must be zero in the lowest bits to allow for using |
96 // the mark bit when tracing. | 96 // the mark bit when tracing. |
97 const uint8_t orphanedZapValue = 240; | 97 const uint8_t orphanedZapValue = 240; |
98 const int numberOfPagesToConsiderForCoalescing = 100; | 98 const int numberOfPagesToConsiderForCoalescing = 100; |
99 | 99 |
100 enum CallbackInvocationMode { | |
101 GlobalMarking, | |
102 ThreadLocalMarking, | |
103 }; | |
104 | |
105 class CallbackStack; | 100 class CallbackStack; |
106 class PageMemory; | 101 class PageMemory; |
107 template<ThreadAffinity affinity> class ThreadLocalPersistents; | 102 template<ThreadAffinity affinity> class ThreadLocalPersistents; |
108 template<typename T, typename RootsAccessor = ThreadLocalPersistents<ThreadingTr
ait<T>::Affinity > > class Persistent; | 103 template<typename T, typename RootsAccessor = ThreadLocalPersistents<ThreadingTr
ait<T>::Affinity > > class Persistent; |
109 | 104 |
110 #if ENABLE(GC_PROFILE_HEAP) | 105 #if ENABLE(GC_PROFILE_HEAP) |
111 class TracedValue; | 106 class TracedValue; |
112 #endif | 107 #endif |
113 | 108 |
114 // Blink heap pages are set up with a guard page before and after the | 109 // Blink heap pages are set up with a guard page before and after the |
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 static void pushWeakPointerCallback(void* closure, void* containerObject, We
akPointerCallback); | 875 static void pushWeakPointerCallback(void* closure, void* containerObject, We
akPointerCallback); |
881 | 876 |
882 // Similar to the more general pushWeakPointerCallback, but cell | 877 // Similar to the more general pushWeakPointerCallback, but cell |
883 // pointer callbacks are added to a static callback work list and the weak | 878 // pointer callbacks are added to a static callback work list and the weak |
884 // callback is performed on the thread performing garbage collection. This | 879 // callback is performed on the thread performing garbage collection. This |
885 // is OK because cells are just cleared and no deallocation can happen. | 880 // is OK because cells are just cleared and no deallocation can happen. |
886 static void pushWeakCellPointerCallback(void** cell, WeakPointerCallback); | 881 static void pushWeakCellPointerCallback(void** cell, WeakPointerCallback); |
887 | 882 |
888 // Pop the top of a marking stack and call the callback with the visitor | 883 // Pop the top of a marking stack and call the callback with the visitor |
889 // and the object. Returns false when there is nothing more to do. | 884 // and the object. Returns false when there is nothing more to do. |
890 template<CallbackInvocationMode Mode> static bool popAndInvokeTraceCallback(
CallbackStack*, Visitor*); | 885 static bool popAndInvokeTraceCallback(CallbackStack*, Visitor*); |
891 | 886 |
892 // Remove an item from the post-marking callback stack and call | 887 // Remove an item from the post-marking callback stack and call |
893 // the callback with the visitor and the object pointer. Returns | 888 // the callback with the visitor and the object pointer. Returns |
894 // false when there is nothing more to do. | 889 // false when there is nothing more to do. |
895 static bool popAndInvokePostMarkingCallback(Visitor*); | 890 static bool popAndInvokePostMarkingCallback(Visitor*); |
896 | 891 |
897 // Remove an item from the weak callback work list and call the callback | 892 // Remove an item from the weak callback work list and call the callback |
898 // with the visitor and the closure pointer. Returns false when there is | 893 // with the visitor and the closure pointer. Returns false when there is |
899 // nothing more to do. | 894 // nothing more to do. |
900 static bool popAndInvokeWeakPointerCallback(Visitor*); | 895 static bool popAndInvokeWeakPointerCallback(Visitor*); |
901 | 896 |
902 // Register an ephemeron table for fixed-point iteration. | 897 // Register an ephemeron table for fixed-point iteration. |
903 static void registerWeakTable(void* containerObject, EphemeronCallback, Ephe
meronCallback); | 898 static void registerWeakTable(void* containerObject, EphemeronCallback, Ephe
meronCallback); |
904 #if ENABLE(ASSERT) | 899 #if ENABLE(ASSERT) |
905 static bool weakTableRegistered(const void*); | 900 static bool weakTableRegistered(const void*); |
906 #endif | 901 #endif |
907 | 902 |
908 template<typename T, typename HeapTraits> static Address allocate(size_t); | 903 template<typename T, typename HeapTraits> static Address allocate(size_t); |
909 // FIXME: remove this once c++11 is allowed everywhere: | 904 // FIXME: remove this once c++11 is allowed everywhere: |
910 template<typename T> static Address allocate(size_t); | 905 template<typename T> static Address allocate(size_t); |
911 | 906 |
912 template<typename T> static Address reallocate(void* previous, size_t); | 907 template<typename T> static Address reallocate(void* previous, size_t); |
913 | 908 |
914 static void collectGarbage(ThreadState::StackState, ThreadState::CauseOfGC =
ThreadState::NormalGC); | 909 static void collectGarbage(ThreadState::StackState, ThreadState::CauseOfGC =
ThreadState::NormalGC); |
915 static void collectGarbageForTerminatingThread(ThreadState*); | 910 static void collectGarbageForTerminatingThread(ThreadState*); |
916 static void collectAllGarbage(); | 911 static void collectAllGarbage(); |
917 template<CallbackInvocationMode Mode> static void processMarkingStack(); | 912 static void processMarkingStack(); |
918 static void postMarkingProcessing(); | 913 static void postMarkingProcessing(); |
919 static void globalWeakProcessing(); | 914 static void globalWeakProcessing(); |
920 static void setForcePreciseGCForTesting(); | 915 static void setForcePreciseGCForTesting(); |
921 | 916 |
922 static void preGC(); | 917 static void preGC(); |
923 static void postGC(); | 918 static void postGC(); |
924 | 919 |
925 // Conservatively checks whether an address is a pointer in any of the threa
d | 920 // Conservatively checks whether an address is a pointer in any of the threa
d |
926 // heaps. If so marks the object pointed to as live. | 921 // heaps. If so marks the object pointed to as live. |
927 static Address checkAndMarkPointer(Visitor*, Address); | 922 static Address checkAndMarkPointer(Visitor*, Address); |
(...skipping 1418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2346 template<typename T, size_t inlineCapacity> | 2341 template<typename T, size_t inlineCapacity> |
2347 struct GCInfoTrait<HeapVector<T, inlineCapacity> > : public GCInfoTrait<Vector<T
, inlineCapacity, HeapAllocator> > { }; | 2342 struct GCInfoTrait<HeapVector<T, inlineCapacity> > : public GCInfoTrait<Vector<T
, inlineCapacity, HeapAllocator> > { }; |
2348 template<typename T, size_t inlineCapacity> | 2343 template<typename T, size_t inlineCapacity> |
2349 struct GCInfoTrait<HeapDeque<T, inlineCapacity> > : public GCInfoTrait<Deque<T,
inlineCapacity, HeapAllocator> > { }; | 2344 struct GCInfoTrait<HeapDeque<T, inlineCapacity> > : public GCInfoTrait<Deque<T,
inlineCapacity, HeapAllocator> > { }; |
2350 template<typename T, typename U, typename V> | 2345 template<typename T, typename U, typename V> |
2351 struct GCInfoTrait<HeapHashCountedSet<T, U, V> > : public GCInfoTrait<HashCounte
dSet<T, U, V, HeapAllocator> > { }; | 2346 struct GCInfoTrait<HeapHashCountedSet<T, U, V> > : public GCInfoTrait<HashCounte
dSet<T, U, V, HeapAllocator> > { }; |
2352 | 2347 |
2353 } // namespace blink | 2348 } // namespace blink |
2354 | 2349 |
2355 #endif // Heap_h | 2350 #endif // Heap_h |
OLD | NEW |