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

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

Issue 2688083002: Move VisitorMarkingMode into Visitor. (Closed)
Patch Set: Created 3 years, 10 months 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 /* 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 #define DEFINE_INLINE_TRACE_AFTER_DISPATCH() \ 87 #define DEFINE_INLINE_TRACE_AFTER_DISPATCH() \
88 void traceAfterDispatch(blink::Visitor* visitor) 88 void traceAfterDispatch(blink::Visitor* visitor)
89 89
90 #define EMPTY_MACRO_ARGUMENT 90 #define EMPTY_MACRO_ARGUMENT
91 91
92 #define DECLARE_TRACE() DECLARE_TRACE_IMPL(EMPTY_MACRO_ARGUMENT) 92 #define DECLARE_TRACE() DECLARE_TRACE_IMPL(EMPTY_MACRO_ARGUMENT)
93 #define DECLARE_VIRTUAL_TRACE() DECLARE_TRACE_IMPL(virtual) 93 #define DECLARE_VIRTUAL_TRACE() DECLARE_TRACE_IMPL(virtual)
94 #define DEFINE_INLINE_TRACE() DEFINE_INLINE_TRACE_IMPL(EMPTY_MACRO_ARGUMENT) 94 #define DEFINE_INLINE_TRACE() DEFINE_INLINE_TRACE_IMPL(EMPTY_MACRO_ARGUMENT)
95 #define DEFINE_INLINE_VIRTUAL_TRACE() DEFINE_INLINE_TRACE_IMPL(virtual) 95 #define DEFINE_INLINE_VIRTUAL_TRACE() DEFINE_INLINE_TRACE_IMPL(virtual)
96 96
97 enum class VisitorMarkingMode {
98 // This is a default visitor. This is used for GCType=GCWithSweep
99 // and GCType=GCWithoutSweep.
100 GlobalMarking,
101 // This visitor just marks objects and ignores weak processing.
102 // This is used for GCType=TakeSnapshot.
103 SnapshotMarking,
104 // This visitor is used to trace objects during weak processing.
105 // This visitor is allowed to trace only already marked objects.
106 WeakProcessing,
107 // Perform global marking along with preparing for additional sweep
108 // compaction of heap arenas afterwards. Compared to the GlobalMarking
109 // visitor, this visitor will also register references to objects
110 // that might be moved during arena compaction -- the compaction
111 // pass will then fix up those references when the object move goes
112 // ahead.
113 GlobalMarkingWithCompaction,
114 };
115
116 // Visitor is used to traverse the Blink object graph. Used for the 97 // Visitor is used to traverse the Blink object graph. Used for the
117 // marking phase of the mark-sweep garbage collector. 98 // marking phase of the mark-sweep garbage collector.
118 // 99 //
119 // Pointers are marked and pushed on the marking stack by calling the 100 // Pointers are marked and pushed on the marking stack by calling the
120 // |mark| method with the pointer as an argument. 101 // |mark| method with the pointer as an argument.
121 // 102 //
122 // Pointers within objects are traced by calling the |trace| methods 103 // Pointers within objects are traced by calling the |trace| methods
123 // with the object as an argument. Tracing objects will mark all of the 104 // with the object as an argument. Tracing objects will mark all of the
124 // contained pointers and push them on the marking stack. 105 // contained pointers and push them on the marking stack.
125 class PLATFORM_EXPORT Visitor { 106 class PLATFORM_EXPORT Visitor {
126 public: 107 public:
127 static std::unique_ptr<Visitor> create(ThreadState*, VisitorMarkingMode); 108 enum MarkingMode {
109 // This is a default visitor. This is used for GCType=GCWithSweep
110 // and GCType=GCWithoutSweep.
111 GlobalMarking,
112 // This visitor just marks objects and ignores weak processing.
113 // This is used for GCType=TakeSnapshot.
114 SnapshotMarking,
115 // This visitor is used to trace objects during weak processing.
116 // This visitor is allowed to trace only already marked objects.
117 WeakProcessing,
118 // Perform global marking along with preparing for additional sweep
119 // compaction of heap arenas afterwards. Compared to the GlobalMarking
120 // visitor, this visitor will also register references to objects
121 // that might be moved during arena compaction -- the compaction
122 // pass will then fix up those references when the object move goes
123 // ahead.
124 GlobalMarkingWithCompaction,
125 };
128 126
129 Visitor(ThreadState*, VisitorMarkingMode); 127 static std::unique_ptr<Visitor> create(ThreadState*, MarkingMode);
128
129 Visitor(ThreadState*, MarkingMode);
130 virtual ~Visitor(); 130 virtual ~Visitor();
131 131
132 // One-argument templated mark method. This uses the static type of 132 // One-argument templated mark method. This uses the static type of
133 // the argument to get the TraceTrait. By default, the mark method 133 // the argument to get the TraceTrait. By default, the mark method
134 // of the TraceTrait just calls the virtual two-argument mark method on this 134 // of the TraceTrait just calls the virtual two-argument mark method on this
135 // visitor, where the second argument is the static trace method of the trait. 135 // visitor, where the second argument is the static trace method of the trait.
136 template <typename T> 136 template <typename T>
137 void mark(T* t) { 137 void mark(T* t) {
138 static_assert(sizeof(T), "T must be fully defined"); 138 static_assert(sizeof(T), "T must be fully defined");
139 static_assert(IsGarbageCollectedType<T>::value, 139 static_assert(IsGarbageCollectedType<T>::value,
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 // Used to mark objects during conservative scanning. 303 // Used to mark objects during conservative scanning.
304 inline void markHeader(HeapObjectHeader*, 304 inline void markHeader(HeapObjectHeader*,
305 const void* objectPointer, 305 const void* objectPointer,
306 TraceCallback); 306 TraceCallback);
307 307
308 inline void markHeader(HeapObjectHeader*, TraceCallback); 308 inline void markHeader(HeapObjectHeader*, TraceCallback);
309 309
310 inline ThreadState* state() const { return m_state; } 310 inline ThreadState* state() const { return m_state; }
311 inline ThreadHeap& heap() const { return state()->heap(); } 311 inline ThreadHeap& heap() const { return state()->heap(); }
312 312
313 inline VisitorMarkingMode getMarkingMode() const { return m_markingMode; } 313 inline MarkingMode getMarkingMode() const { return m_markingMode; }
314 314
315 private: 315 private:
316 template <typename T> 316 template <typename T>
317 static void handleWeakCell(Visitor* self, void*); 317 static void handleWeakCell(Visitor* self, void*);
318 318
319 static void markNoTracingCallback(Visitor*, void*); 319 static void markNoTracingCallback(Visitor*, void*);
320 320
321 ThreadState* const m_state; 321 ThreadState* const m_state;
322 const VisitorMarkingMode m_markingMode; 322 const MarkingMode m_markingMode;
323 }; 323 };
324 324
325 } // namespace blink 325 } // namespace blink
326 326
327 #endif // Visitor_h 327 #endif // Visitor_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/ThreadState.cpp ('k') | third_party/WebKit/Source/platform/heap/Visitor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698