OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BlinkGC_h | 5 #ifndef BlinkGC_h |
6 #define BlinkGC_h | 6 #define BlinkGC_h |
7 | 7 |
8 // BlinkGC.h is a file that defines common things used by Blink GC. | 8 // BlinkGC.h is a file that defines common things used by Blink GC. |
9 | 9 |
10 #include "platform/PlatformExport.h" | 10 #include "platform/PlatformExport.h" |
11 #include "wtf/Allocator.h" | 11 #include "wtf/Allocator.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 class Visitor; | 15 class Visitor; |
16 | 16 |
17 #define PRINT_HEAP_STATS 0 // Enable this macro to print heap stats to stderr. | 17 #define PRINT_HEAP_STATS 0 // Enable this macro to print heap stats to stderr. |
18 | 18 |
19 using Address = uint8_t*; | 19 using Address = uint8_t*; |
20 | 20 |
21 using FinalizationCallback = void (*)(void*); | 21 using FinalizationCallback = void (*)(void*); |
22 using VisitorCallback = void (*)(Visitor*, void* self); | 22 using VisitorCallback = void (*)(Visitor*, void* self); |
23 using TraceCallback = VisitorCallback; | 23 using TraceCallback = VisitorCallback; |
24 using WeakCallback = VisitorCallback; | 24 using WeakCallback = VisitorCallback; |
25 using EphemeronCallback = VisitorCallback; | 25 using EphemeronCallback = VisitorCallback; |
26 using PreFinalizerCallback = bool (*)(void*); | 26 using PreFinalizerCallback = bool (*)(void*); |
27 | 27 |
28 // Simple alias to avoid heap compaction type signatures turning into | |
29 // a sea of generic |void*|s. | |
30 using MovableReference = void*; | |
31 | |
32 // Heap compaction supports registering callbacks that are to be invoked | |
33 // when an object is moved during compaction. This is to support internal | |
34 // location fixups that need to happen as a result. | |
35 // | |
36 // i.e., when the object residing at |from| is moved to |to| by the compaction | |
37 // pass, invoke the callback to adjust any internal references that now need | |
38 // to be |to|-relative. | |
39 using MovingObjectCallback = void (*)(void* callbackData, | |
40 MovableReference from, | |
41 MovableReference to, | |
42 size_t); | |
43 | |
44 // List of typed arenas. The list is used to generate the implementation | 28 // List of typed arenas. The list is used to generate the implementation |
45 // of typed arena related methods. | 29 // of typed arena related methods. |
46 // | 30 // |
47 // To create a new typed arena add a H(<ClassName>) to the | 31 // To create a new typed arena add a H(<ClassName>) to the |
48 // FOR_EACH_TYPED_ARENA macro below. | 32 // FOR_EACH_TYPED_ARENA macro below. |
49 #define FOR_EACH_TYPED_ARENA(H) \ | 33 #define FOR_EACH_TYPED_ARENA(H) \ |
50 H(Node) \ | 34 H(Node) \ |
51 H(CSSValue) | 35 H(CSSValue) |
52 | 36 |
53 #define TypedArenaEnumName(Type) Type##ArenaIndex, | 37 #define TypedArenaEnumName(Type) Type##ArenaIndex, |
54 | 38 |
55 class PLATFORM_EXPORT BlinkGC final { | 39 class PLATFORM_EXPORT BlinkGC final { |
56 STATIC_ONLY(BlinkGC); | 40 STATIC_ONLY(BlinkGC); |
57 | 41 |
58 public: | 42 public: |
59 // When garbage collecting we need to know whether or not there | 43 // When garbage collecting we need to know whether or not there |
60 // can be pointers to Blink GC managed objects on the stack for | 44 // can be pointers to Blink GC managed objects on the stack for |
61 // each thread. When threads reach a safe point they record | 45 // each thread. When threads reach a safe point they record |
62 // whether or not they have pointers on the stack. | 46 // whether or not they have pointers on the stack. |
63 enum StackState { NoHeapPointersOnStack, HeapPointersOnStack }; | 47 enum StackState { NoHeapPointersOnStack, HeapPointersOnStack }; |
64 | 48 |
65 enum GCType { | 49 enum GCType { |
66 // Both of the marking task and the sweeping task run in | 50 // Both of the marking task and the sweeping task run in |
67 // ThreadHeap::collectGarbage(). | 51 // ThreadHeap::collectGarbage(). |
68 GCWithSweep, | 52 GCWithSweep, |
69 // Only the marking task runs in ThreadHeap::collectGarbage(). | 53 // Only the marking task runs in ThreadHeap::collectGarbage(). |
70 // The sweeping task is split into chunks and scheduled lazily. | 54 // The sweeping task is split into chunks and scheduled lazily. |
71 GCWithoutSweep, | 55 GCWithoutSweep, |
72 // After the marking task has run in ThreadHeap::collectGarbage(), | |
73 // sweep compaction of some heap arenas is performed. The sweeping | |
74 // of the remaining arenas is split into chunks and scheduled lazily. | |
75 GCWithSweepCompaction, | |
76 // Only the marking task runs just to take a heap snapshot. | 56 // Only the marking task runs just to take a heap snapshot. |
77 // The sweeping task doesn't run. The marks added in the marking task | 57 // The sweeping task doesn't run. The marks added in the marking task |
78 // are just cleared. | 58 // are just cleared. |
79 TakeSnapshot, | 59 TakeSnapshot, |
80 // The marking task does not mark objects outside the heap of the GCing | 60 // The marking task does not mark objects outside the heap of the GCing |
81 // thread. | 61 // thread. |
82 ThreadTerminationGC, | 62 ThreadTerminationGC, |
83 // Just run thread-local weak processing. The weak processing may trace | 63 // Just run thread-local weak processing. The weak processing may trace |
84 // already marked objects but it must not trace any unmarked object. | 64 // already marked objects but it must not trace any unmarked object. |
85 // It's unfortunate that the thread-local weak processing requires | 65 // It's unfortunate that the thread-local weak processing requires |
86 // a marking visitor. See TODO in HashTable::process. | 66 // a marking visitor. See TODO in HashTable::process. |
87 ThreadLocalWeakProcessing, | 67 ThreadLocalWeakProcessing, |
88 }; | 68 }; |
89 | 69 |
90 enum GCReason { | 70 enum GCReason { |
91 IdleGC, | 71 IdleGC, |
92 PreciseGC, | 72 PreciseGC, |
93 ConservativeGC, | 73 ConservativeGC, |
94 ForcedGC, | 74 ForcedGC, |
95 MemoryPressureGC, | 75 MemoryPressureGC, |
96 PageNavigationGC, | 76 PageNavigationGC, |
97 NumberOfGCReason, | 77 NumberOfGCReason, |
98 }; | 78 }; |
99 | 79 |
100 enum ArenaIndices { | 80 enum HeapIndices { |
101 EagerSweepArenaIndex = 0, | 81 EagerSweepArenaIndex = 0, |
102 NormalPage1ArenaIndex, | 82 NormalPage1ArenaIndex, |
103 NormalPage2ArenaIndex, | 83 NormalPage2ArenaIndex, |
104 NormalPage3ArenaIndex, | 84 NormalPage3ArenaIndex, |
105 NormalPage4ArenaIndex, | 85 NormalPage4ArenaIndex, |
106 Vector1ArenaIndex, | 86 Vector1ArenaIndex, |
107 Vector2ArenaIndex, | 87 Vector2ArenaIndex, |
108 Vector3ArenaIndex, | 88 Vector3ArenaIndex, |
109 Vector4ArenaIndex, | 89 Vector4ArenaIndex, |
110 InlineVectorArenaIndex, | 90 InlineVectorArenaIndex, |
(...skipping 10 matching lines...) Expand all Loading... |
121 | 101 |
122 enum ThreadHeapMode { | 102 enum ThreadHeapMode { |
123 MainThreadHeapMode, | 103 MainThreadHeapMode, |
124 PerThreadHeapMode, | 104 PerThreadHeapMode, |
125 }; | 105 }; |
126 }; | 106 }; |
127 | 107 |
128 } // namespace blink | 108 } // namespace blink |
129 | 109 |
130 #endif | 110 #endif |
OLD | NEW |