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

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

Issue 1112363003: Oilpan: Remove OffHeapCollectionTrait (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/platform/heap/HeapTest.cpp ('k') | Source/web/TextFinder.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 static const bool value = TraceEagerlyTrait<T>::value; 260 static const bool value = TraceEagerlyTrait<T>::value;
261 }; 261 };
262 262
263 template<typename ValueArg, size_t inlineCapacity> class HeapListHashSetAllocato r; 263 template<typename ValueArg, size_t inlineCapacity> class HeapListHashSetAllocato r;
264 template<typename T, size_t inlineCapacity> 264 template<typename T, size_t inlineCapacity>
265 class TraceEagerlyTrait<WTF::ListHashSetNode<T, HeapListHashSetAllocator<T, inli neCapacity>>> { 265 class TraceEagerlyTrait<WTF::ListHashSetNode<T, HeapListHashSetAllocator<T, inli neCapacity>>> {
266 public: 266 public:
267 static const bool value = false; 267 static const bool value = false;
268 }; 268 };
269 269
270 template<typename Collection>
271 struct OffHeapCollectionTraceTrait;
272
273 template<typename T, bool = NeedsAdjustAndMark<T>::value> class ObjectAliveTrait ; 270 template<typename T, bool = NeedsAdjustAndMark<T>::value> class ObjectAliveTrait ;
274 271
275 template<typename T> 272 template<typename T>
276 class ObjectAliveTrait<T, false> { 273 class ObjectAliveTrait<T, false> {
277 public: 274 public:
278 template<typename VisitorDispatcher> 275 template<typename VisitorDispatcher>
279 static bool isHeapObjectAlive(VisitorDispatcher visitor, T* obj) 276 static bool isHeapObjectAlive(VisitorDispatcher visitor, T* obj)
280 { 277 {
281 return visitor->isMarked(obj); 278 return visitor->isMarked(obj);
282 } 279 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 // Check that we actually know the definition of T when tracing. 371 // Check that we actually know the definition of T when tracing.
375 static_assert(sizeof(T), "T must be fully defined"); 372 static_assert(sizeof(T), "T must be fully defined");
376 if (WTF::IsPolymorphic<T>::value) { 373 if (WTF::IsPolymorphic<T>::value) {
377 intptr_t vtable = *reinterpret_cast<const intptr_t*>(&t); 374 intptr_t vtable = *reinterpret_cast<const intptr_t*>(&t);
378 if (!vtable) 375 if (!vtable)
379 return; 376 return;
380 } 377 }
381 TraceTrait<T>::trace(Derived::fromHelper(this), &const_cast<T&>(t)); 378 TraceTrait<T>::trace(Derived::fromHelper(this), &const_cast<T&>(t));
382 } 379 }
383 380
384 // The following trace methods are for off-heap collections.
385 template<typename T, size_t inlineCapacity>
386 void trace(const Vector<T, inlineCapacity>& vector)
387 {
388 OffHeapCollectionTraceTrait<Vector<T, inlineCapacity, WTF::DefaultAlloca tor>>::trace(Derived::fromHelper(this), vector);
389 }
390
391 template<typename T, size_t N>
392 void trace(const Deque<T, N>& deque)
393 {
394 OffHeapCollectionTraceTrait<Deque<T, N>>::trace(Derived::fromHelper(this ), deque);
395 }
396
397 #if !ENABLE(OILPAN) 381 #if !ENABLE(OILPAN)
398 // These trace methods are needed to allow compiling and calling trace on 382 // These trace methods are needed to allow compiling and calling trace on
399 // transition types. We need to support calls in the non-oilpan build 383 // transition types. We need to support calls in the non-oilpan build
400 // because a fully transitioned type (which will have its trace method 384 // because a fully transitioned type (which will have its trace method
401 // called) might trace a field that is in transition. Once transition types 385 // called) might trace a field that is in transition. Once transition types
402 // are removed these can be removed. 386 // are removed these can be removed.
403 template<typename T> void trace(const OwnPtr<T>&) { } 387 template<typename T> void trace(const OwnPtr<T>&) { }
404 template<typename T> void trace(const RefPtr<T>&) { } 388 template<typename T> void trace(const RefPtr<T>&) { }
405 template<typename T> void trace(const RawPtr<T>&) { } 389 template<typename T> void trace(const RawPtr<T>&) { }
406 template<typename T> void trace(const WeakPtr<T>&) { } 390 template<typename T> void trace(const WeakPtr<T>&) { }
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 590
607 template <typename Derived> 591 template <typename Derived>
608 template <typename T> 592 template <typename T>
609 void VisitorHelper<Derived>::handleWeakCell(Visitor* self, void* obj) 593 void VisitorHelper<Derived>::handleWeakCell(Visitor* self, void* obj)
610 { 594 {
611 T** cell = reinterpret_cast<T**>(obj); 595 T** cell = reinterpret_cast<T**>(obj);
612 if (*cell && !self->isHeapObjectAlive(*cell)) 596 if (*cell && !self->isHeapObjectAlive(*cell))
613 *cell = nullptr; 597 *cell = nullptr;
614 } 598 }
615 599
616 // We trace vectors by using the trace trait on each element, which means you
617 // can have vectors of general objects (not just pointers to objects) that can
618 // be traced.
619 template<typename T, size_t N>
620 struct OffHeapCollectionTraceTrait<WTF::Vector<T, N, WTF::DefaultAllocator>> {
621 typedef WTF::Vector<T, N, WTF::DefaultAllocator> Vector;
622
623 template<typename VisitorDispatcher>
624 static void trace(VisitorDispatcher visitor, const Vector& vector)
625 {
626 if (vector.isEmpty())
627 return;
628 for (typename Vector::const_iterator it = vector.begin(), end = vector.e nd(); it != end; ++it)
629 TraceTrait<T>::trace(visitor, const_cast<T*>(it));
630 }
631 };
632
633 template<typename T, size_t N>
634 struct OffHeapCollectionTraceTrait<WTF::Deque<T, N>> {
635 typedef WTF::Deque<T, N> Deque;
636
637 template<typename VisitorDispatcher>
638 static void trace(VisitorDispatcher visitor, const Deque& deque)
639 {
640 if (deque.isEmpty())
641 return;
642 for (typename Deque::const_iterator it = deque.begin(), end = deque.end( ); it != end; ++it)
643 TraceTrait<T>::trace(visitor, const_cast<T*>(&(*it)));
644 }
645 };
646
647 template<typename T> struct GCInfoTrait; 600 template<typename T> struct GCInfoTrait;
648 601
649 template<typename T> 602 template<typename T>
650 class DefaultTraceTrait<T, false> { 603 class DefaultTraceTrait<T, false> {
651 public: 604 public:
652 template<typename VisitorDispatcher> 605 template<typename VisitorDispatcher>
653 static void mark(VisitorDispatcher visitor, const T* t) 606 static void mark(VisitorDispatcher visitor, const T* t)
654 { 607 {
655 // Default mark method of the trait just calls the two-argument mark 608 // Default mark method of the trait just calls the two-argument mark
656 // method on the visitor. The second argument is the static trace method 609 // method on the visitor. The second argument is the static trace method
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 { 676 {
724 DEFINE_STATIC_LOCAL(String, typenameString, (WTF::extractTypeNameFromFun ctionName(WTF::extractNameFunction<T>()))); 677 DEFINE_STATIC_LOCAL(String, typenameString, (WTF::extractTypeNameFromFun ctionName(WTF::extractNameFunction<T>())));
725 return typenameString; 678 return typenameString;
726 } 679 }
727 }; 680 };
728 #endif 681 #endif
729 682
730 } // namespace blink 683 } // namespace blink
731 684
732 #endif // Visitor_h 685 #endif // Visitor_h
OLDNEW
« no previous file with comments | « Source/platform/heap/HeapTest.cpp ('k') | Source/web/TextFinder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698