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 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 static void pushWeakPointerCallback(void* closure, void* containerObject, We
akPointerCallback); | 878 static void pushWeakPointerCallback(void* closure, void* containerObject, We
akPointerCallback); |
884 | 879 |
885 // Similar to the more general pushWeakPointerCallback, but cell | 880 // Similar to the more general pushWeakPointerCallback, but cell |
886 // pointer callbacks are added to a static callback work list and the weak | 881 // pointer callbacks are added to a static callback work list and the weak |
887 // callback is performed on the thread performing garbage collection. This | 882 // callback is performed on the thread performing garbage collection. This |
888 // is OK because cells are just cleared and no deallocation can happen. | 883 // is OK because cells are just cleared and no deallocation can happen. |
889 static void pushWeakCellPointerCallback(void** cell, WeakPointerCallback); | 884 static void pushWeakCellPointerCallback(void** cell, WeakPointerCallback); |
890 | 885 |
891 // Pop the top of a marking stack and call the callback with the visitor | 886 // Pop the top of a marking stack and call the callback with the visitor |
892 // and the object. Returns false when there is nothing more to do. | 887 // and the object. Returns false when there is nothing more to do. |
893 template<CallbackInvocationMode Mode> static bool popAndInvokeTraceCallback(
CallbackStack*, Visitor*); | 888 static bool popAndInvokeTraceCallback(CallbackStack*, Visitor*); |
894 | 889 |
895 // Remove an item from the post-marking callback stack and call | 890 // Remove an item from the post-marking callback stack and call |
896 // the callback with the visitor and the object pointer. Returns | 891 // the callback with the visitor and the object pointer. Returns |
897 // false when there is nothing more to do. | 892 // false when there is nothing more to do. |
898 static bool popAndInvokePostMarkingCallback(Visitor*); | 893 static bool popAndInvokePostMarkingCallback(Visitor*); |
899 | 894 |
900 // Remove an item from the weak callback work list and call the callback | 895 // Remove an item from the weak callback work list and call the callback |
901 // with the visitor and the closure pointer. Returns false when there is | 896 // with the visitor and the closure pointer. Returns false when there is |
902 // nothing more to do. | 897 // nothing more to do. |
903 static bool popAndInvokeWeakPointerCallback(Visitor*); | 898 static bool popAndInvokeWeakPointerCallback(Visitor*); |
904 | 899 |
905 // Register an ephemeron table for fixed-point iteration. | 900 // Register an ephemeron table for fixed-point iteration. |
906 static void registerWeakTable(void* containerObject, EphemeronCallback, Ephe
meronCallback); | 901 static void registerWeakTable(void* containerObject, EphemeronCallback, Ephe
meronCallback); |
907 #if ENABLE(ASSERT) | 902 #if ENABLE(ASSERT) |
908 static bool weakTableRegistered(const void*); | 903 static bool weakTableRegistered(const void*); |
909 #endif | 904 #endif |
910 | 905 |
911 template<typename T, typename HeapTraits> static Address allocate(size_t); | 906 template<typename T, typename HeapTraits> static Address allocate(size_t); |
912 // FIXME: remove this once c++11 is allowed everywhere: | 907 // FIXME: remove this once c++11 is allowed everywhere: |
913 template<typename T> static Address allocate(size_t); | 908 template<typename T> static Address allocate(size_t); |
914 | 909 |
915 template<typename T> static Address reallocate(void* previous, size_t); | 910 template<typename T> static Address reallocate(void* previous, size_t); |
916 | 911 |
917 static void collectGarbage(ThreadState::StackState, ThreadState::GCType = Th
readState::ForcedGC); | 912 static void collectGarbage(ThreadState::StackState, ThreadState::GCType = Th
readState::ForcedGC); |
918 static void collectGarbageForTerminatingThread(ThreadState*); | 913 static void collectGarbageForTerminatingThread(ThreadState*); |
919 static void collectAllGarbage(); | 914 static void collectAllGarbage(); |
920 template<CallbackInvocationMode Mode> static void processMarkingStack(); | 915 |
921 static void postMarkingProcessing(); | 916 static void processMarkingStack(Visitor*); |
922 static void globalWeakProcessing(); | 917 static void postMarkingProcessing(Visitor*); |
| 918 static void globalWeakProcessing(Visitor*); |
923 static void setForcePreciseGCForTesting(); | 919 static void setForcePreciseGCForTesting(); |
924 | 920 |
925 static void preGC(); | 921 static void preGC(); |
926 static void postGC(); | 922 static void postGC(); |
927 | 923 |
928 // Conservatively checks whether an address is a pointer in any of the threa
d | 924 // Conservatively checks whether an address is a pointer in any of the threa
d |
929 // heaps. If so marks the object pointed to as live. | 925 // heaps. If so marks the object pointed to as live. |
930 static Address checkAndMarkPointer(Visitor*, Address); | 926 static Address checkAndMarkPointer(Visitor*, Address); |
931 | 927 |
932 #if ENABLE(GC_PROFILE_MARKING) | 928 #if ENABLE(GC_PROFILE_MARKING) |
(...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2316 template<typename T, size_t inlineCapacity> | 2312 template<typename T, size_t inlineCapacity> |
2317 struct GCInfoTrait<HeapVector<T, inlineCapacity> > : public GCInfoTrait<Vector<T
, inlineCapacity, HeapAllocator> > { }; | 2313 struct GCInfoTrait<HeapVector<T, inlineCapacity> > : public GCInfoTrait<Vector<T
, inlineCapacity, HeapAllocator> > { }; |
2318 template<typename T, size_t inlineCapacity> | 2314 template<typename T, size_t inlineCapacity> |
2319 struct GCInfoTrait<HeapDeque<T, inlineCapacity> > : public GCInfoTrait<Deque<T,
inlineCapacity, HeapAllocator> > { }; | 2315 struct GCInfoTrait<HeapDeque<T, inlineCapacity> > : public GCInfoTrait<Deque<T,
inlineCapacity, HeapAllocator> > { }; |
2320 template<typename T, typename U, typename V> | 2316 template<typename T, typename U, typename V> |
2321 struct GCInfoTrait<HeapHashCountedSet<T, U, V> > : public GCInfoTrait<HashCounte
dSet<T, U, V, HeapAllocator> > { }; | 2317 struct GCInfoTrait<HeapHashCountedSet<T, U, V> > : public GCInfoTrait<HashCounte
dSet<T, U, V, HeapAllocator> > { }; |
2322 | 2318 |
2323 } // namespace blink | 2319 } // namespace blink |
2324 | 2320 |
2325 #endif // Heap_h | 2321 #endif // Heap_h |
OLD | NEW |