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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 { | 294 { |
295 OffHeapCollectionTraceTrait<Vector<T, inlineCapacity, WTF::DefaultAlloca
tor> >::trace(this, vector); | 295 OffHeapCollectionTraceTrait<Vector<T, inlineCapacity, WTF::DefaultAlloca
tor> >::trace(this, vector); |
296 } | 296 } |
297 | 297 |
298 template<typename T, size_t N> | 298 template<typename T, size_t N> |
299 void trace(const Deque<T, N>& deque) | 299 void trace(const Deque<T, N>& deque) |
300 { | 300 { |
301 OffHeapCollectionTraceTrait<Deque<T, N> >::trace(this, deque); | 301 OffHeapCollectionTraceTrait<Deque<T, N> >::trace(this, deque); |
302 } | 302 } |
303 | 303 |
304 template<typename T, typename U, typename V, typename W, typename X> | |
305 void trace(const HashMap<T, U, V, W, X, WTF::DefaultAllocator>& map) | |
306 { | |
307 OffHeapCollectionTraceTrait<HashMap<T, U, V, W, X, WTF::DefaultAllocator
> >::trace(this, map); | |
308 } | |
309 | |
310 #if !ENABLE(OILPAN) | 304 #if !ENABLE(OILPAN) |
311 // These trace methods are needed to allow compiling and calling trace on | 305 // These trace methods are needed to allow compiling and calling trace on |
312 // transition types. We need to support calls in the non-oilpan build | 306 // transition types. We need to support calls in the non-oilpan build |
313 // because a fully transitioned type (which will have its trace method | 307 // because a fully transitioned type (which will have its trace method |
314 // called) might trace a field that is in transition. Once transition types | 308 // called) might trace a field that is in transition. Once transition types |
315 // are removed these can be removed. | 309 // are removed these can be removed. |
316 template<typename T> void trace(const OwnPtr<T>&) { } | 310 template<typename T> void trace(const OwnPtr<T>&) { } |
317 template<typename T> void trace(const RefPtr<T>&) { } | 311 template<typename T> void trace(const RefPtr<T>&) { } |
318 template<typename T> void trace(const RawPtr<T>&) { } | 312 template<typename T> void trace(const RawPtr<T>&) { } |
319 template<typename T> void trace(const WeakPtr<T>&) { } | 313 template<typename T> void trace(const WeakPtr<T>&) { } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 private: | 423 private: |
430 template<typename T> | 424 template<typename T> |
431 static void handleWeakCell(Visitor* self, void* obj) | 425 static void handleWeakCell(Visitor* self, void* obj) |
432 { | 426 { |
433 T** cell = reinterpret_cast<T**>(obj); | 427 T** cell = reinterpret_cast<T**>(obj); |
434 if (*cell && !self->isAlive(*cell)) | 428 if (*cell && !self->isAlive(*cell)) |
435 *cell = 0; | 429 *cell = 0; |
436 } | 430 } |
437 }; | 431 }; |
438 | 432 |
439 template<typename Key, typename Value, typename HashFunctions, typename KeyTrait
s, typename ValueTraits> | |
440 struct OffHeapCollectionTraceTrait<WTF::HashMap<Key, Value, HashFunctions, KeyTr
aits, ValueTraits, WTF::DefaultAllocator> > { | |
441 typedef WTF::HashMap<Key, Value, HashFunctions, KeyTraits, ValueTraits, WTF:
:DefaultAllocator> HashMap; | |
442 | |
443 static void trace(Visitor* visitor, const HashMap& map) | |
444 { | |
445 if (map.isEmpty()) | |
446 return; | |
447 if (WTF::ShouldBeTraced<KeyTraits>::value || WTF::ShouldBeTraced<ValueTr
aits>::value) { | |
448 HashMap& iterMap = const_cast<HashMap&>(map); | |
449 for (typename HashMap::iterator it = iterMap.begin(), end = iterMap.
end(); it != end; ++it) { | |
450 CollectionBackingTraceTrait<WTF::ShouldBeTraced<KeyTraits>::valu
e, KeyTraits::weakHandlingFlag, WTF::WeakPointersActWeak, typename HashMap::KeyT
ype, KeyTraits>::trace(visitor, it->key); | |
451 CollectionBackingTraceTrait<WTF::ShouldBeTraced<ValueTraits>::va
lue, ValueTraits::weakHandlingFlag, WTF::WeakPointersActWeak, typename HashMap::
MappedType, ValueTraits>::trace(visitor, it->value); | |
452 } | |
453 } | |
454 COMPILE_ASSERT(KeyTraits::weakHandlingFlag == WTF::NoWeakHandlingInColle
ctions, WeakOffHeapCollectionsConsideredDangerous1); | |
455 COMPILE_ASSERT(ValueTraits::weakHandlingFlag == WTF::NoWeakHandlingInCol
lections, WeakOffHeapCollectionsConsideredDangerous2); | |
456 } | |
457 }; | |
458 | |
459 // We trace vectors by using the trace trait on each element, which means you | 433 // We trace vectors by using the trace trait on each element, which means you |
460 // can have vectors of general objects (not just pointers to objects) that can | 434 // can have vectors of general objects (not just pointers to objects) that can |
461 // be traced. | 435 // be traced. |
462 template<typename T, size_t N> | 436 template<typename T, size_t N> |
463 struct OffHeapCollectionTraceTrait<WTF::Vector<T, N, WTF::DefaultAllocator> > { | 437 struct OffHeapCollectionTraceTrait<WTF::Vector<T, N, WTF::DefaultAllocator> > { |
464 typedef WTF::Vector<T, N, WTF::DefaultAllocator> Vector; | 438 typedef WTF::Vector<T, N, WTF::DefaultAllocator> Vector; |
465 | 439 |
466 static void trace(Visitor* visitor, const Vector& vector) | 440 static void trace(Visitor* visitor, const Vector& vector) |
467 { | 441 { |
468 if (vector.isEmpty()) | 442 if (vector.isEmpty()) |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 struct GCInfoTrait { | 630 struct GCInfoTrait { |
657 static const GCInfo* get() | 631 static const GCInfo* get() |
658 { | 632 { |
659 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get(); | 633 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get(); |
660 } | 634 } |
661 }; | 635 }; |
662 | 636 |
663 } | 637 } |
664 | 638 |
665 #endif | 639 #endif |
OLD | NEW |