Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Side by Side Diff: third_party/WebKit/Source/platform/heap/BlinkGC.h

Issue 2531973002: Simple BlinkGC heap compaction. (Closed)
Patch Set: add pointer alignment handling to SparseHeapBitmap Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
28 // List of typed arenas. The list is used to generate the implementation 44 // List of typed arenas. The list is used to generate the implementation
29 // of typed arena related methods. 45 // of typed arena related methods.
30 // 46 //
31 // To create a new typed arena add a H(<ClassName>) to the 47 // To create a new typed arena add a H(<ClassName>) to the
32 // FOR_EACH_TYPED_ARENA macro below. 48 // FOR_EACH_TYPED_ARENA macro below.
33 #define FOR_EACH_TYPED_ARENA(H) \ 49 #define FOR_EACH_TYPED_ARENA(H) \
34 H(Node) \ 50 H(Node) \
35 H(CSSValue) 51 H(CSSValue)
36 52
37 #define TypedArenaEnumName(Type) Type##ArenaIndex, 53 #define TypedArenaEnumName(Type) Type##ArenaIndex,
38 54
39 class PLATFORM_EXPORT BlinkGC final { 55 class PLATFORM_EXPORT BlinkGC final {
40 STATIC_ONLY(BlinkGC); 56 STATIC_ONLY(BlinkGC);
41 57
42 public: 58 public:
43 // When garbage collecting we need to know whether or not there 59 // When garbage collecting we need to know whether or not there
44 // can be pointers to Blink GC managed objects on the stack for 60 // can be pointers to Blink GC managed objects on the stack for
45 // each thread. When threads reach a safe point they record 61 // each thread. When threads reach a safe point they record
46 // whether or not they have pointers on the stack. 62 // whether or not they have pointers on the stack.
47 enum StackState { NoHeapPointersOnStack, HeapPointersOnStack }; 63 enum StackState { NoHeapPointersOnStack, HeapPointersOnStack };
48 64
49 enum GCType { 65 enum GCType {
50 // Both of the marking task and the sweeping task run in 66 // Both of the marking task and the sweeping task run in
51 // ThreadHeap::collectGarbage(). 67 // ThreadHeap::collectGarbage().
52 GCWithSweep, 68 GCWithSweep,
53 // Only the marking task runs in ThreadHeap::collectGarbage(). 69 // Only the marking task runs in ThreadHeap::collectGarbage().
54 // The sweeping task is split into chunks and scheduled lazily. 70 // The sweeping task is split into chunks and scheduled lazily.
55 GCWithoutSweep, 71 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,
56 // Only the marking task runs just to take a heap snapshot. 76 // Only the marking task runs just to take a heap snapshot.
57 // The sweeping task doesn't run. The marks added in the marking task 77 // The sweeping task doesn't run. The marks added in the marking task
58 // are just cleared. 78 // are just cleared.
59 TakeSnapshot, 79 TakeSnapshot,
60 // The marking task does not mark objects outside the heap of the GCing 80 // The marking task does not mark objects outside the heap of the GCing
61 // thread. 81 // thread.
62 ThreadTerminationGC, 82 ThreadTerminationGC,
63 // Just run thread-local weak processing. The weak processing may trace 83 // Just run thread-local weak processing. The weak processing may trace
64 // already marked objects but it must not trace any unmarked object. 84 // already marked objects but it must not trace any unmarked object.
65 // It's unfortunate that the thread-local weak processing requires 85 // It's unfortunate that the thread-local weak processing requires
66 // a marking visitor. See TODO in HashTable::process. 86 // a marking visitor. See TODO in HashTable::process.
67 ThreadLocalWeakProcessing, 87 ThreadLocalWeakProcessing,
68 }; 88 };
69 89
70 enum GCReason { 90 enum GCReason {
71 IdleGC, 91 IdleGC,
72 PreciseGC, 92 PreciseGC,
73 ConservativeGC, 93 ConservativeGC,
74 ForcedGC, 94 ForcedGC,
75 MemoryPressureGC, 95 MemoryPressureGC,
76 PageNavigationGC, 96 PageNavigationGC,
77 NumberOfGCReason, 97 NumberOfGCReason,
78 }; 98 };
79 99
80 enum HeapIndices { 100 enum ArenaIndices {
81 EagerSweepArenaIndex = 0, 101 EagerSweepArenaIndex = 0,
82 NormalPage1ArenaIndex, 102 NormalPage1ArenaIndex,
83 NormalPage2ArenaIndex, 103 NormalPage2ArenaIndex,
84 NormalPage3ArenaIndex, 104 NormalPage3ArenaIndex,
85 NormalPage4ArenaIndex, 105 NormalPage4ArenaIndex,
86 Vector1ArenaIndex, 106 Vector1ArenaIndex,
87 Vector2ArenaIndex, 107 Vector2ArenaIndex,
88 Vector3ArenaIndex, 108 Vector3ArenaIndex,
89 Vector4ArenaIndex, 109 Vector4ArenaIndex,
90 InlineVectorArenaIndex, 110 InlineVectorArenaIndex,
(...skipping 10 matching lines...) Expand all
101 121
102 enum ThreadHeapMode { 122 enum ThreadHeapMode {
103 MainThreadHeapMode, 123 MainThreadHeapMode,
104 PerThreadHeapMode, 124 PerThreadHeapMode,
105 }; 125 };
106 }; 126 };
107 127
108 } // namespace blink 128 } // namespace blink
109 129
110 #endif 130 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698