| 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 |
| 304 #if !ENABLE(OILPAN) | 310 #if !ENABLE(OILPAN) |
| 305 // These trace methods are needed to allow compiling and calling trace on | 311 // These trace methods are needed to allow compiling and calling trace on |
| 306 // transition types. We need to support calls in the non-oilpan build | 312 // transition types. We need to support calls in the non-oilpan build |
| 307 // because a fully transitioned type (which will have its trace method | 313 // because a fully transitioned type (which will have its trace method |
| 308 // called) might trace a field that is in transition. Once transition types | 314 // called) might trace a field that is in transition. Once transition types |
| 309 // are removed these can be removed. | 315 // are removed these can be removed. |
| 310 template<typename T> void trace(const OwnPtr<T>&) { } | 316 template<typename T> void trace(const OwnPtr<T>&) { } |
| 311 template<typename T> void trace(const RefPtr<T>&) { } | 317 template<typename T> void trace(const RefPtr<T>&) { } |
| 312 template<typename T> void trace(const RawPtr<T>&) { } | 318 template<typename T> void trace(const RawPtr<T>&) { } |
| 313 template<typename T> void trace(const WeakPtr<T>&) { } | 319 template<typename T> void trace(const WeakPtr<T>&) { } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 private: | 429 private: |
| 424 template<typename T> | 430 template<typename T> |
| 425 static void handleWeakCell(Visitor* self, void* obj) | 431 static void handleWeakCell(Visitor* self, void* obj) |
| 426 { | 432 { |
| 427 T** cell = reinterpret_cast<T**>(obj); | 433 T** cell = reinterpret_cast<T**>(obj); |
| 428 if (*cell && !self->isAlive(*cell)) | 434 if (*cell && !self->isAlive(*cell)) |
| 429 *cell = 0; | 435 *cell = 0; |
| 430 } | 436 } |
| 431 }; | 437 }; |
| 432 | 438 |
| 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 |
| 433 // We trace vectors by using the trace trait on each element, which means you | 459 // We trace vectors by using the trace trait on each element, which means you |
| 434 // can have vectors of general objects (not just pointers to objects) that can | 460 // can have vectors of general objects (not just pointers to objects) that can |
| 435 // be traced. | 461 // be traced. |
| 436 template<typename T, size_t N> | 462 template<typename T, size_t N> |
| 437 struct OffHeapCollectionTraceTrait<WTF::Vector<T, N, WTF::DefaultAllocator> > { | 463 struct OffHeapCollectionTraceTrait<WTF::Vector<T, N, WTF::DefaultAllocator> > { |
| 438 typedef WTF::Vector<T, N, WTF::DefaultAllocator> Vector; | 464 typedef WTF::Vector<T, N, WTF::DefaultAllocator> Vector; |
| 439 | 465 |
| 440 static void trace(Visitor* visitor, const Vector& vector) | 466 static void trace(Visitor* visitor, const Vector& vector) |
| 441 { | 467 { |
| 442 if (vector.isEmpty()) | 468 if (vector.isEmpty()) |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 struct GCInfoTrait { | 656 struct GCInfoTrait { |
| 631 static const GCInfo* get() | 657 static const GCInfo* get() |
| 632 { | 658 { |
| 633 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get(); | 659 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get(); |
| 634 } | 660 } |
| 635 }; | 661 }; |
| 636 | 662 |
| 637 } | 663 } |
| 638 | 664 |
| 639 #endif | 665 #endif |
| OLD | NEW |