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

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

Issue 2570483002: Revert of Simple BlinkGC heap compaction. (Closed)
Patch Set: 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 /* 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 Derived::fromHelper(this)->registerWeakCellWithCallback( 236 Derived::fromHelper(this)->registerWeakCellWithCallback(
237 reinterpret_cast<void**>( 237 reinterpret_cast<void**>(
238 const_cast<typename std::remove_const<T>::type**>(cell)), 238 const_cast<typename std::remove_const<T>::type**>(cell)),
239 &handleWeakCell<T>); 239 &handleWeakCell<T>);
240 } 240 }
241 241
242 template <typename T, void (T::*method)(Visitor*)> 242 template <typename T, void (T::*method)(Visitor*)>
243 void registerWeakMembers(const T* obj) { 243 void registerWeakMembers(const T* obj) {
244 registerWeakMembers(obj, &TraceMethodDelegate<T, method>::trampoline); 244 registerWeakMembers(obj, &TraceMethodDelegate<T, method>::trampoline);
245 } 245 }
246
247 void registerWeakMembers(const void* object, WeakCallback callback) { 246 void registerWeakMembers(const void* object, WeakCallback callback) {
248 Derived::fromHelper(this)->registerWeakMembers(object, object, callback); 247 Derived::fromHelper(this)->registerWeakMembers(object, object, callback);
249 } 248 }
250 249
251 template <typename T>
252 void registerBackingStoreReference(T** slot) {
253 Derived::fromHelper(this)->registerMovingObjectReference(
254 reinterpret_cast<MovableReference*>(slot));
255 }
256
257 template <typename T>
258 void registerBackingStoreCallback(T* backingStore,
259 MovingObjectCallback callback,
260 void* callbackData) {
261 Derived::fromHelper(this)->registerMovingObjectCallback(
262 reinterpret_cast<MovableReference>(backingStore), callback,
263 callbackData);
264 }
265
266 inline ThreadState* state() const { return m_state; } 250 inline ThreadState* state() const { return m_state; }
267 inline ThreadHeap& heap() const { return state()->heap(); } 251 inline ThreadHeap& heap() const { return state()->heap(); }
268 252
269 private: 253 private:
270 template <typename T> 254 template <typename T>
271 static void handleWeakCell(Visitor* self, void* object); 255 static void handleWeakCell(Visitor* self, void* object);
272 256
273 ThreadState* const m_state; 257 ThreadState* m_state;
274 }; 258 };
275 259
276 // Visitor is used to traverse the Blink object graph. Used for the 260 // Visitor is used to traverse the Blink object graph. Used for the
277 // marking phase of the mark-sweep garbage collector. 261 // marking phase of the mark-sweep garbage collector.
278 // 262 //
279 // Pointers are marked and pushed on the marking stack by calling the 263 // Pointers are marked and pushed on the marking stack by calling the
280 // |mark| method with the pointer as an argument. 264 // |mark| method with the pointer as an argument.
281 // 265 //
282 // Pointers within objects are traced by calling the |trace| methods 266 // Pointers within objects are traced by calling the |trace| methods
283 // with the object as an argument. Tracing objects will mark all of the 267 // with the object as an argument. Tracing objects will mark all of the
284 // contained pointers and push them on the marking stack. 268 // contained pointers and push them on the marking stack.
285 class PLATFORM_EXPORT Visitor : public VisitorHelper<Visitor> { 269 class PLATFORM_EXPORT Visitor : public VisitorHelper<Visitor> {
286 public: 270 public:
287 friend class VisitorHelper<Visitor>; 271 friend class VisitorHelper<Visitor>;
288 friend class InlinedGlobalMarkingVisitor; 272 friend class InlinedGlobalMarkingVisitor;
289 273
290 enum MarkingMode { 274 enum MarkingMode {
291 // This is a default visitor. This is used for GCType=GCWithSweep 275 // This is a default visitor. This is used for GCType=GCWithSweep
292 // and GCType=GCWithoutSweep. 276 // and GCType=GCWithoutSweep.
293 GlobalMarking, 277 GlobalMarking,
294 // This visitor does not trace objects outside the heap of the 278 // This visitor does not trace objects outside the heap of the
295 // GCing thread. This is used for GCType=ThreadTerminationGC. 279 // GCing thread. This is used for GCType=ThreadTerminationGC.
296 ThreadLocalMarking, 280 ThreadLocalMarking,
297 // This visitor just marks objects and ignores weak processing. 281 // This visitor just marks objects and ignores weak processing.
298 // This is used for GCType=TakeSnapshot. 282 // This is used for GCType=TakeSnapshot.
299 SnapshotMarking, 283 SnapshotMarking,
300 // This visitor is used to trace objects during weak processing. 284 // This visitor is used to trace objects during weak processing.
301 // This visitor is allowed to trace only already marked objects. 285 // This visitor is allowed to trace only already marked objects.
302 WeakProcessing, 286 WeakProcessing,
303 // Perform global marking along with preparing for additional sweep
304 // compaction of heap arenas afterwards. Compared to the GlobalMarking
305 // visitor, this visitor will also register references to objects
306 // that might be moved during arena compaction -- the compaction
307 // pass will then fix up those references when the object move goes
308 // ahead.
309 GlobalMarkingWithCompaction,
310 }; 287 };
311 288
312 static std::unique_ptr<Visitor> create(ThreadState*, BlinkGC::GCType); 289 static std::unique_ptr<Visitor> create(ThreadState*, BlinkGC::GCType);
313 290
314 virtual ~Visitor(); 291 virtual ~Visitor();
315 292
316 using VisitorHelper<Visitor>::mark; 293 using VisitorHelper<Visitor>::mark;
317 294
318 // This method marks an object and adds it to the set of objects 295 // This method marks an object and adds it to the set of objects
319 // that should have their trace method called. Since not all 296 // that should have their trace method called. Since not all
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 337
361 virtual void registerWeakTable(const void*, 338 virtual void registerWeakTable(const void*,
362 EphemeronCallback, 339 EphemeronCallback,
363 EphemeronCallback) = 0; 340 EphemeronCallback) = 0;
364 #if ENABLE(ASSERT) 341 #if ENABLE(ASSERT)
365 virtual bool weakTableRegistered(const void*) = 0; 342 virtual bool weakTableRegistered(const void*) = 0;
366 #endif 343 #endif
367 344
368 virtual bool ensureMarked(const void*) = 0; 345 virtual bool ensureMarked(const void*) = 0;
369 346
370 virtual void registerMovingObjectReference(MovableReference*) = 0;
371
372 virtual void registerMovingObjectCallback(MovableReference,
373 MovingObjectCallback,
374 void*) = 0;
375
376 virtual void registerWeakCellWithCallback(void**, WeakCallback) = 0; 347 virtual void registerWeakCellWithCallback(void**, WeakCallback) = 0;
377 348
378 inline MarkingMode getMarkingMode() const { return m_markingMode; } 349 inline MarkingMode getMarkingMode() const { return m_markingMode; }
379 350
380 inline bool isGlobalMarking() const {
381 return m_markingMode == GlobalMarking ||
382 m_markingMode == GlobalMarkingWithCompaction;
383 }
384
385 protected: 351 protected:
386 Visitor(ThreadState*, MarkingMode); 352 Visitor(ThreadState*, MarkingMode);
387 353
388 private: 354 private:
389 static Visitor* fromHelper(VisitorHelper<Visitor>* helper) { 355 static Visitor* fromHelper(VisitorHelper<Visitor>* helper) {
390 return static_cast<Visitor*>(helper); 356 return static_cast<Visitor*>(helper);
391 } 357 }
392 358
359 ThreadState* m_state;
393 const MarkingMode m_markingMode; 360 const MarkingMode m_markingMode;
394 }; 361 };
395 362
396 } // namespace blink 363 } // namespace blink
397 364
398 #endif // Visitor_h 365 #endif // Visitor_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/TraceTraits.h ('k') | third_party/WebKit/Source/platform/heap/Visitor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698