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

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

Issue 1753623002: Merge VisitorScope to Visitor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added explicit Created 4 years, 9 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 // GCing thread. This is used for GCType=ThreadTerminationGC. 310 // GCing thread. This is used for GCType=ThreadTerminationGC.
311 ThreadLocalMarking, 311 ThreadLocalMarking,
312 // This visitor just marks objects and ignores weak processing. 312 // This visitor just marks objects and ignores weak processing.
313 // This is used for GCType=TakeSnapshot. 313 // This is used for GCType=TakeSnapshot.
314 SnapshotMarking, 314 SnapshotMarking,
315 // This visitor is used to trace objects during weak processing. 315 // This visitor is used to trace objects during weak processing.
316 // This visitor is allowed to trace only already marked objects. 316 // This visitor is allowed to trace only already marked objects.
317 WeakProcessing, 317 WeakProcessing,
318 }; 318 };
319 319
320 virtual ~Visitor() { } 320 static PassOwnPtr<Visitor> create(ThreadState*, BlinkGC::GCType);
321
322 virtual ~Visitor();
321 323
322 using VisitorHelper<Visitor>::mark; 324 using VisitorHelper<Visitor>::mark;
323 325
324 // This method marks an object and adds it to the set of objects 326 // This method marks an object and adds it to the set of objects
325 // that should have their trace method called. Since not all 327 // that should have their trace method called. Since not all
326 // objects have vtables we have to have the callback as an 328 // objects have vtables we have to have the callback as an
327 // explicit argument, but we can use the templated one-argument 329 // explicit argument, but we can use the templated one-argument
328 // mark method above to automatically provide the callback 330 // mark method above to automatically provide the callback
329 // function. 331 // function.
330 virtual void mark(const void*, TraceCallback) = 0; 332 virtual void mark(const void*, TraceCallback) = 0;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 virtual void registerWeakTable(const void*, EphemeronCallback, EphemeronCall back) = 0; 369 virtual void registerWeakTable(const void*, EphemeronCallback, EphemeronCall back) = 0;
368 #if ENABLE(ASSERT) 370 #if ENABLE(ASSERT)
369 virtual bool weakTableRegistered(const void*) = 0; 371 virtual bool weakTableRegistered(const void*) = 0;
370 #endif 372 #endif
371 373
372 virtual bool ensureMarked(const void*) = 0; 374 virtual bool ensureMarked(const void*) = 0;
373 375
374 inline MarkingMode markingMode() const { return m_markingMode; } 376 inline MarkingMode markingMode() const { return m_markingMode; }
375 377
376 protected: 378 protected:
377 explicit Visitor(MarkingMode markingMode) 379 Visitor(ThreadState*, MarkingMode);
378 : m_markingMode(markingMode)
379 { }
380 380
381 virtual void registerWeakCellWithCallback(void**, WeakCallback) = 0; 381 virtual void registerWeakCellWithCallback(void**, WeakCallback) = 0;
382 382
383 private: 383 private:
384 static Visitor* fromHelper(VisitorHelper<Visitor>* helper) { return static_c ast<Visitor*>(helper); } 384 static Visitor* fromHelper(VisitorHelper<Visitor>* helper) { return static_c ast<Visitor*>(helper); }
385 385
386 ThreadState* m_state;
386 const MarkingMode m_markingMode; 387 const MarkingMode m_markingMode;
387 bool m_isGlobalMarkingVisitor; 388 bool m_isGlobalMarkingVisitor;
388 }; 389 };
389 390
390 class VisitorScope final {
391 STACK_ALLOCATED();
392 public:
393 VisitorScope(ThreadState*, BlinkGC::GCType);
394 ~VisitorScope();
395 Visitor* visitor() const { return m_visitor.get(); }
396
397 private:
398 ThreadState* m_state;
399 OwnPtr<Visitor> m_visitor;
400 };
401
402 } // namespace blink 391 } // namespace blink
403 392
404 #endif // Visitor_h 393 #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