| OLD | NEW |
| 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 #ifndef Visitor_h | 31 #ifndef Visitor_h |
| 32 #define Visitor_h | 32 #define Visitor_h |
| 33 | 33 |
| 34 #include "platform/PlatformExport.h" | 34 #include "platform/PlatformExport.h" |
| 35 #include "platform/heap/ThreadState.h" | 35 #include "platform/heap/ThreadState.h" |
| 36 #include "wtf/Assertions.h" | 36 #include "wtf/Assertions.h" |
| 37 #include "wtf/Deque.h" | 37 #include "wtf/Deque.h" |
| 38 #include "wtf/Forward.h" | 38 #include "wtf/Forward.h" |
| 39 #include "wtf/HashMap.h" | 39 #include "wtf/HashMap.h" |
| 40 #include "wtf/HashSet.h" | |
| 41 #include "wtf/HashTraits.h" | 40 #include "wtf/HashTraits.h" |
| 42 #include "wtf/InstanceCounter.h" | 41 #include "wtf/InstanceCounter.h" |
| 43 #include "wtf/LinkedHashSet.h" | |
| 44 #include "wtf/ListHashSet.h" | |
| 45 #include "wtf/OwnPtr.h" | 42 #include "wtf/OwnPtr.h" |
| 46 #include "wtf/RefPtr.h" | 43 #include "wtf/RefPtr.h" |
| 47 #include "wtf/TypeTraits.h" | 44 #include "wtf/TypeTraits.h" |
| 48 #include "wtf/WeakPtr.h" | 45 #include "wtf/WeakPtr.h" |
| 49 #if ENABLE(GC_TRACING) | 46 #if ENABLE(GC_TRACING) |
| 50 #include "wtf/text/WTFString.h" | 47 #include "wtf/text/WTFString.h" |
| 51 #endif | 48 #endif |
| 52 | 49 |
| 53 #ifndef NDEBUG | 50 #ifndef NDEBUG |
| 54 #define DEBUG_ONLY(x) x | 51 #define DEBUG_ONLY(x) x |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 const_cast<T&>(t).trace(this); | 288 const_cast<T&>(t).trace(this); |
| 292 } | 289 } |
| 293 | 290 |
| 294 // The following trace methods are for off-heap collections. | 291 // The following trace methods are for off-heap collections. |
| 295 template<typename T, size_t inlineCapacity> | 292 template<typename T, size_t inlineCapacity> |
| 296 void trace(const Vector<T, inlineCapacity>& vector) | 293 void trace(const Vector<T, inlineCapacity>& vector) |
| 297 { | 294 { |
| 298 OffHeapCollectionTraceTrait<Vector<T, inlineCapacity, WTF::DefaultAlloca
tor> >::trace(this, vector); | 295 OffHeapCollectionTraceTrait<Vector<T, inlineCapacity, WTF::DefaultAlloca
tor> >::trace(this, vector); |
| 299 } | 296 } |
| 300 | 297 |
| 301 template<typename T, typename U, typename V> | |
| 302 void trace(const HashSet<T, U, V>& hashSet) | |
| 303 { | |
| 304 OffHeapCollectionTraceTrait<HashSet<T, U, V> >::trace(this, hashSet); | |
| 305 } | |
| 306 | |
| 307 template<typename T, size_t N> | 298 template<typename T, size_t N> |
| 308 void trace(const Deque<T, N>& deque) | 299 void trace(const Deque<T, N>& deque) |
| 309 { | 300 { |
| 310 OffHeapCollectionTraceTrait<Deque<T, N> >::trace(this, deque); | 301 OffHeapCollectionTraceTrait<Deque<T, N> >::trace(this, deque); |
| 311 } | 302 } |
| 312 | 303 |
| 313 template<typename T, typename U, typename V, typename W, typename X> | 304 template<typename T, typename U, typename V, typename W, typename X> |
| 314 void trace(const HashMap<T, U, V, W, X, WTF::DefaultAllocator>& map) | 305 void trace(const HashMap<T, U, V, W, X, WTF::DefaultAllocator>& map) |
| 315 { | 306 { |
| 316 OffHeapCollectionTraceTrait<HashMap<T, U, V, W, X, WTF::DefaultAllocator
> >::trace(this, map); | 307 OffHeapCollectionTraceTrait<HashMap<T, U, V, W, X, WTF::DefaultAllocator
> >::trace(this, map); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 private: | 429 private: |
| 439 template<typename T> | 430 template<typename T> |
| 440 static void handleWeakCell(Visitor* self, void* obj) | 431 static void handleWeakCell(Visitor* self, void* obj) |
| 441 { | 432 { |
| 442 T** cell = reinterpret_cast<T**>(obj); | 433 T** cell = reinterpret_cast<T**>(obj); |
| 443 if (*cell && !self->isAlive(*cell)) | 434 if (*cell && !self->isAlive(*cell)) |
| 444 *cell = 0; | 435 *cell = 0; |
| 445 } | 436 } |
| 446 }; | 437 }; |
| 447 | 438 |
| 448 template<typename T, typename HashFunctions, typename Traits> | |
| 449 struct OffHeapCollectionTraceTrait<WTF::HashSet<T, HashFunctions, Traits, WTF::D
efaultAllocator> > { | |
| 450 typedef WTF::HashSet<T, HashFunctions, Traits, WTF::DefaultAllocator> HashSe
t; | |
| 451 | |
| 452 static void trace(Visitor* visitor, const HashSet& set) | |
| 453 { | |
| 454 if (set.isEmpty()) | |
| 455 return; | |
| 456 if (WTF::ShouldBeTraced<Traits>::value) { | |
| 457 HashSet& iterSet = const_cast<HashSet&>(set); | |
| 458 for (typename HashSet::iterator it = iterSet.begin(), end = iterSet.
end(); it != end; ++it) { | |
| 459 const T& t = *it; | |
| 460 CollectionBackingTraceTrait<WTF::ShouldBeTraced<Traits>::value,
Traits::weakHandlingFlag, WTF::WeakPointersActWeak, T, Traits>::trace(visitor, c
onst_cast<T&>(t)); | |
| 461 } | |
| 462 } | |
| 463 COMPILE_ASSERT(Traits::weakHandlingFlag == WTF::NoWeakHandlingInCollecti
ons, WeakOffHeapCollectionsConsideredDangerous0); | |
| 464 } | |
| 465 }; | |
| 466 | |
| 467 template<typename Key, typename Value, typename HashFunctions, typename KeyTrait
s, typename ValueTraits> | 439 template<typename Key, typename Value, typename HashFunctions, typename KeyTrait
s, typename ValueTraits> |
| 468 struct OffHeapCollectionTraceTrait<WTF::HashMap<Key, Value, HashFunctions, KeyTr
aits, ValueTraits, WTF::DefaultAllocator> > { | 440 struct OffHeapCollectionTraceTrait<WTF::HashMap<Key, Value, HashFunctions, KeyTr
aits, ValueTraits, WTF::DefaultAllocator> > { |
| 469 typedef WTF::HashMap<Key, Value, HashFunctions, KeyTraits, ValueTraits, WTF:
:DefaultAllocator> HashMap; | 441 typedef WTF::HashMap<Key, Value, HashFunctions, KeyTraits, ValueTraits, WTF:
:DefaultAllocator> HashMap; |
| 470 | 442 |
| 471 static void trace(Visitor* visitor, const HashMap& map) | 443 static void trace(Visitor* visitor, const HashMap& map) |
| 472 { | 444 { |
| 473 if (map.isEmpty()) | 445 if (map.isEmpty()) |
| 474 return; | 446 return; |
| 475 if (WTF::ShouldBeTraced<KeyTraits>::value || WTF::ShouldBeTraced<ValueTr
aits>::value) { | 447 if (WTF::ShouldBeTraced<KeyTraits>::value || WTF::ShouldBeTraced<ValueTr
aits>::value) { |
| 476 HashMap& iterMap = const_cast<HashMap&>(map); | 448 HashMap& iterMap = const_cast<HashMap&>(map); |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 struct GCInfoTrait { | 655 struct GCInfoTrait { |
| 684 static const GCInfo* get() | 656 static const GCInfo* get() |
| 685 { | 657 { |
| 686 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get(); | 658 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get(); |
| 687 } | 659 } |
| 688 }; | 660 }; |
| 689 | 661 |
| 690 } | 662 } |
| 691 | 663 |
| 692 #endif | 664 #endif |
| OLD | NEW |