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 "ThreadState.h" | 34 #include "ThreadState.h" |
35 #include <wtf/Deque.h> | 35 #include <wtf/Deque.h> |
36 #include <wtf/Forward.h> | 36 #include <wtf/Forward.h> |
37 #include <wtf/HashMap.h> | 37 #include <wtf/HashMap.h> |
38 #include <wtf/HashSet.h> | 38 #include <wtf/HashSet.h> |
39 #include <wtf/HashTraits.h> | 39 #include <wtf/HashTraits.h> |
| 40 #include <wtf/ListHashSet.h> |
40 | 41 |
41 #define TRACE_GC_MARKING 0 | 42 #define TRACE_GC_MARKING 0 |
42 #define TRACE_GC_FINALIZATION 0 | 43 #define TRACE_GC_FINALIZATION 0 |
43 | 44 |
44 #if TRACE_GC_MARKING || TRACE_GC_FINALIZATION | 45 #if TRACE_GC_MARKING || TRACE_GC_FINALIZATION |
45 #define TRACE_GC_USING_CLASSOF 1 | 46 #define TRACE_GC_USING_CLASSOF 1 |
46 #else | 47 #else |
47 #define TRACE_GC_USING_CLASSOF 0 | 48 #define TRACE_GC_USING_CLASSOF 0 |
48 #endif | 49 #endif |
49 | 50 |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 | 267 |
267 // Doesn't keep the visited thing alive, but will write null to the | 268 // Doesn't keep the visited thing alive, but will write null to the |
268 // WeakMember later if the pointed-to object is dead. | 269 // WeakMember later if the pointed-to object is dead. |
269 template<typename T> | 270 template<typename T> |
270 void trace(const WeakMember<T>& t) | 271 void trace(const WeakMember<T>& t) |
271 { | 272 { |
272 registerWeakCell(t.cell()); | 273 registerWeakCell(t.cell()); |
273 } | 274 } |
274 | 275 |
275 // The following visit methods are for off-heap collections. | 276 // The following visit methods are for off-heap collections. |
276 template<typename T, size_t N> | 277 template<typename T, size_t inlineCapacity> |
277 void trace(const Vector<T, N, WTF::FastAllocator>& vector) | 278 void trace(const Vector<T, inlineCapacity, WTF::FastAllocator>& vector) |
278 { | 279 { |
279 CollectionVisitingTrait<Vector<T, N, WTF::FastAllocator> >::visit(this,
vector); | 280 CollectionVisitingTrait<Vector<T, inlineCapacity, WTF::FastAllocator> >:
:visit(this, vector); |
280 } | 281 } |
281 | 282 |
282 template<typename T, typename U, typename V> | 283 template<typename T, typename U, typename V> |
283 void trace(const HashSet<T, WTF::FastAllocator, U, V>& hashSet) | 284 void trace(const HashSet<T, WTF::FastAllocator, U, V>& hashSet) |
284 { | 285 { |
285 CollectionVisitingTrait<HashSet<T, WTF::FastAllocator, U, V> >::visit(th
is, hashSet); | 286 CollectionVisitingTrait<HashSet<T, WTF::FastAllocator, U, V> >::visit(th
is, hashSet); |
286 } | 287 } |
287 | 288 |
| 289 template<typename T, size_t inlineCapacity, typename U> |
| 290 void trace(const ListHashSet<T, inlineCapacity, U>& hashSet) |
| 291 { |
| 292 CollectionVisitingTrait<ListHashSet<T, inlineCapacity, U> >::visit(this,
hashSet); |
| 293 } |
| 294 |
288 template<typename T, size_t N> | 295 template<typename T, size_t N> |
289 void trace(const Deque<T, N>& deque) | 296 void trace(const Deque<T, N>& deque) |
290 { | 297 { |
291 CollectionVisitingTrait<Deque<T, N> >::visit(this, deque); | 298 CollectionVisitingTrait<Deque<T, N> >::visit(this, deque); |
292 } | 299 } |
293 | 300 |
294 template<typename T, typename U, typename V, typename W, typename X> | 301 template<typename T, typename U, typename V, typename W, typename X> |
295 void trace(const HashMap<T, U, WTF::FastAllocator, V, W, X>& map) | 302 void trace(const HashMap<T, U, WTF::FastAllocator, V, W, X>& map) |
296 { | 303 { |
297 CollectionVisitingTrait<HashMap<T, U, WTF::FastAllocator, V, W, X> >::vi
sit(this, map); | 304 CollectionVisitingTrait<HashMap<T, U, WTF::FastAllocator, V, W, X> >::vi
sit(this, map); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 for (typename HashSet::const_iterator it = set.begin(), end = set.en
d(); it != end; ++it) | 410 for (typename HashSet::const_iterator it = set.begin(), end = set.en
d(); it != end; ++it) |
404 VisitCollectionBackingTrait<Traits::needsVisiting, Traits::isWea
k, false, T, Traits>::visit(v, *it); | 411 VisitCollectionBackingTrait<Traits::needsVisiting, Traits::isWea
k, false, T, Traits>::visit(v, *it); |
405 } | 412 } |
406 if (Traits::isWeak) { | 413 if (Traits::isWeak) { |
407 if (!set.isEmpty()) | 414 if (!set.isEmpty()) |
408 v->registerWeakPointers(&set, processWeakOffHeapHashSet<T, HashF
unctions, Traits>); | 415 v->registerWeakPointers(&set, processWeakOffHeapHashSet<T, HashF
unctions, Traits>); |
409 } | 416 } |
410 } | 417 } |
411 }; | 418 }; |
412 | 419 |
| 420 template<typename T, size_t inlineCapacity, typename HashFunctions> |
| 421 struct CollectionVisitingTrait<WTF::ListHashSet<T, inlineCapacity, HashFunctions
> > { |
| 422 typedef WTF::ListHashSet<T, inlineCapacity, HashFunctions> ListHashSet; |
| 423 |
| 424 static void visit(Visitor* visitor, const ListHashSet& set) |
| 425 { |
| 426 if (set.isEmpty()) |
| 427 return; |
| 428 for (typename ListHashSet::const_iterator it = set.begin(), end = set.en
d(); it != end; ++it) |
| 429 visitor->trace(*it); |
| 430 } |
| 431 }; |
| 432 |
413 template<typename Key, typename Value, typename HashFunctions, typename KeyTrait
s, typename ValueTraits> | 433 template<typename Key, typename Value, typename HashFunctions, typename KeyTrait
s, typename ValueTraits> |
414 struct CollectionVisitingTrait<WTF::HashMap<Key, Value, WTF::FastAllocator, Hash
Functions, KeyTraits, ValueTraits> > { | 434 struct CollectionVisitingTrait<WTF::HashMap<Key, Value, WTF::FastAllocator, Hash
Functions, KeyTraits, ValueTraits> > { |
415 typedef WTF::HashMap<Key, Value, WTF::FastAllocator, HashFunctions, KeyTrait
s, ValueTraits> HashMap; | 435 typedef WTF::HashMap<Key, Value, WTF::FastAllocator, HashFunctions, KeyTrait
s, ValueTraits> HashMap; |
416 | 436 |
417 static void visit(Visitor* v, const HashMap& map) | 437 static void visit(Visitor* v, const HashMap& map) |
418 { | 438 { |
419 if (map.isEmpty()) | 439 if (map.isEmpty()) |
420 return; | 440 return; |
421 if (WTF::NeedsVisiting<Key>::value || WTF::NeedsVisiting<Value>::value)
{ | 441 if (WTF::NeedsVisiting<Key>::value || WTF::NeedsVisiting<Value>::value)
{ |
422 for (typename HashMap::const_iterator it = map.begin(), end = map.en
d(); it != end; ++it) { | 442 for (typename HashMap::const_iterator it = map.begin(), end = map.en
d(); it != end; ++it) { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 class HeapVisitable { | 549 class HeapVisitable { |
530 public: | 550 public: |
531 virtual void trace(Visitor*) = 0; | 551 virtual void trace(Visitor*) = 0; |
532 virtual ~HeapVisitable() | 552 virtual ~HeapVisitable() |
533 { | 553 { |
534 } | 554 } |
535 }; | 555 }; |
536 | 556 |
537 } | 557 } |
538 #endif | 558 #endif |
OLD | NEW |