| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights reserv
ed. |
| 3 * Copyright (C) 2011, Benjamin Poulain <ikipou@gmail.com> | 3 * Copyright (C) 2011, Benjamin Poulain <ikipou@gmail.com> |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 self->m_value.~ValueArg(); | 389 self->m_value.~ValueArg(); |
| 390 } | 390 } |
| 391 | 391 |
| 392 void destroy(NodeAllocator* allocator) | 392 void destroy(NodeAllocator* allocator) |
| 393 { | 393 { |
| 394 this->~ListHashSetNode(); | 394 this->~ListHashSetNode(); |
| 395 setWasAlreadyDestructed(); | 395 setWasAlreadyDestructed(); |
| 396 allocator->deallocate(this); | 396 allocator->deallocate(this); |
| 397 } | 397 } |
| 398 | 398 |
| 399 // This is not called in normal tracing, but it is called if we find a | |
| 400 // pointer to a node on the stack using conservative scanning. Since | |
| 401 // the original ListHashSet may no longer exist we make sure to mark | |
| 402 // the neighbours in the chain too. | |
| 403 void trace(typename NodeAllocator::Visitor* visitor) | |
| 404 { | |
| 405 // The conservative stack scan can find nodes that have been | |
| 406 // removed from the set and destructed. We don't need to trace | |
| 407 // these, and it would be wrong to do so, because the class will | |
| 408 // not expect the trace method to be called after the destructor. | |
| 409 // It's an error to remove a node from the ListHashSet while an | |
| 410 // iterator is positioned at that node, so there should be no valid | |
| 411 // pointers from the stack to a destructed node. | |
| 412 if (wasAlreadyDestructed()) | |
| 413 return; | |
| 414 NodeAllocator::traceValue(visitor, this); | |
| 415 visitor->mark(next()); | |
| 416 visitor->mark(prev()); | |
| 417 } | |
| 418 | |
| 419 ListHashSetNode* next() const { return reinterpret_cast<ListHashSetNode*
>(this->m_next); } | 399 ListHashSetNode* next() const { return reinterpret_cast<ListHashSetNode*
>(this->m_next); } |
| 420 ListHashSetNode* prev() const { return reinterpret_cast<ListHashSetNode*
>(this->m_prev); } | 400 ListHashSetNode* prev() const { return reinterpret_cast<ListHashSetNode*
>(this->m_prev); } |
| 421 | 401 |
| 422 // Don't add fields here, the ListHashSetNodeBase and this should have | 402 // Don't add fields here, the ListHashSetNodeBase and this should have |
| 423 // the same size. | 403 // the same size. |
| 424 | 404 |
| 425 static ListHashSetNode* unlinkedNodePointer() { return reinterpret_cast<
ListHashSetNode*>(-1); } | 405 static ListHashSetNode* unlinkedNodePointer() { return reinterpret_cast<
ListHashSetNode*>(-1); } |
| 426 | 406 |
| 427 template<typename HashArg> | 407 template<typename HashArg> |
| 428 friend struct ListHashSetNodeHashFunctions; | 408 friend struct ListHashSetNodeHashFunctions; |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1008 struct NeedsTracing<ListHashSet<T, U, V> > { | 988 struct NeedsTracing<ListHashSet<T, U, V> > { |
| 1009 static const bool value = false; | 989 static const bool value = false; |
| 1010 }; | 990 }; |
| 1011 #endif | 991 #endif |
| 1012 | 992 |
| 1013 } // namespace WTF | 993 } // namespace WTF |
| 1014 | 994 |
| 1015 using WTF::ListHashSet; | 995 using WTF::ListHashSet; |
| 1016 | 996 |
| 1017 #endif /* WTF_ListHashSet_h */ | 997 #endif /* WTF_ListHashSet_h */ |
| OLD | NEW |