OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights | 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights |
3 * reserved. | 3 * reserved. |
4 * Copyright (C) 2008 David Levin <levin@chromium.org> | 4 * Copyright (C) 2008 David Levin <levin@chromium.org> |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library |
14 * General Public License for more details. | 14 * General Public License for more details. |
15 * | 15 * |
16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
20 * | 20 * |
21 */ | 21 */ |
22 | 22 |
23 #ifndef WTF_HashTable_h | 23 #ifndef WTF_HashTable_h |
24 #define WTF_HashTable_h | 24 #define WTF_HashTable_h |
25 | 25 |
| 26 #include <memory> |
26 #include "wtf/Alignment.h" | 27 #include "wtf/Alignment.h" |
27 #include "wtf/Allocator.h" | 28 #include "wtf/Allocator.h" |
28 #include "wtf/Assertions.h" | 29 #include "wtf/Assertions.h" |
29 #include "wtf/ConditionalDestructor.h" | 30 #include "wtf/ConditionalDestructor.h" |
30 #include "wtf/HashTraits.h" | 31 #include "wtf/HashTraits.h" |
31 #include "wtf/PtrUtil.h" | 32 #include "wtf/PtrUtil.h" |
32 #include "wtf/allocator/PartitionAllocator.h" | 33 #include "wtf/allocator/PartitionAllocator.h" |
33 #include <memory> | |
34 | 34 |
35 #define DUMP_HASHTABLE_STATS 0 | 35 #define DUMP_HASHTABLE_STATS 0 |
36 #define DUMP_HASHTABLE_STATS_PER_TABLE 0 | 36 #define DUMP_HASHTABLE_STATS_PER_TABLE 0 |
37 | 37 |
38 #if DUMP_HASHTABLE_STATS | 38 #if DUMP_HASHTABLE_STATS |
39 #include "wtf/Atomics.h" | 39 #include "wtf/Atomics.h" |
40 #include "wtf/Threading.h" | 40 #include "wtf/Threading.h" |
41 #endif | 41 #endif |
42 | 42 |
43 #if DUMP_HASHTABLE_STATS_PER_TABLE | 43 #if DUMP_HASHTABLE_STATS_PER_TABLE |
| 44 #include <type_traits> |
44 #include "wtf/DataLog.h" | 45 #include "wtf/DataLog.h" |
45 #include <type_traits> | |
46 #endif | 46 #endif |
47 | 47 |
48 #if DUMP_HASHTABLE_STATS | 48 #if DUMP_HASHTABLE_STATS |
49 #if DUMP_HASHTABLE_STATS_PER_TABLE | 49 #if DUMP_HASHTABLE_STATS_PER_TABLE |
50 | 50 |
51 #define UPDATE_PROBE_COUNTS() \ | 51 #define UPDATE_PROBE_COUNTS() \ |
52 ++probeCount; \ | 52 ++probeCount; \ |
53 HashTableStats::instance().recordCollisionAtCount(probeCount); \ | 53 HashTableStats::instance().recordCollisionAtCount(probeCount); \ |
54 ++perTableProbeCount; \ | 54 ++perTableProbeCount; \ |
55 m_stats->recordCollisionAtCount(perTableProbeCount) | 55 m_stats->recordCollisionAtCount(perTableProbeCount) |
(...skipping 2040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2096 KeyTraits, Allocator>::process); | 2096 KeyTraits, Allocator>::process); |
2097 } | 2097 } |
2098 // If the backing store will be moved by sweep compaction, register the | 2098 // If the backing store will be moved by sweep compaction, register the |
2099 // table reference pointing to the backing store object, so that the | 2099 // table reference pointing to the backing store object, so that the |
2100 // reference is updated upon object relocation. A no-op if not enabled | 2100 // reference is updated upon object relocation. A no-op if not enabled |
2101 // by the visitor. | 2101 // by the visitor. |
2102 Allocator::registerBackingStoreReference(visitor, &m_table); | 2102 Allocator::registerBackingStoreReference(visitor, &m_table); |
2103 if (!IsTraceableInCollectionTrait<Traits>::value) | 2103 if (!IsTraceableInCollectionTrait<Traits>::value) |
2104 return; | 2104 return; |
2105 if (Traits::weakHandlingFlag == WeakHandlingInCollections) { | 2105 if (Traits::weakHandlingFlag == WeakHandlingInCollections) { |
2106 // If we have both strong and weak pointers in the collection then | 2106 // If we have both strong and weak pointers in the collection then |
2107 // we queue up the collection for fixed point iteration a la | 2107 // we queue up the collection for fixed point iteration a la |
2108 // Ephemerons: | 2108 // Ephemerons: |
2109 // http://dl.acm.org/citation.cfm?doid=263698.263733 - see also | 2109 // http://dl.acm.org/citation.cfm?doid=263698.263733 - see also |
2110 // http://www.jucs.org/jucs_14_21/eliminating_cycles_in_weak | 2110 // http://www.jucs.org/jucs_14_21/eliminating_cycles_in_weak |
2111 #if DCHECK_IS_ON() | 2111 #if DCHECK_IS_ON() |
2112 DCHECK(!enqueued() || Allocator::weakTableRegistered(visitor, this)); | 2112 DCHECK(!enqueued() || Allocator::weakTableRegistered(visitor, this)); |
2113 #endif | 2113 #endif |
2114 if (!enqueued()) { | 2114 if (!enqueued()) { |
2115 Allocator::registerWeakTable( | 2115 Allocator::registerWeakTable( |
2116 visitor, this, | 2116 visitor, this, |
2117 WeakProcessingHashTableHelper< | 2117 WeakProcessingHashTableHelper< |
2118 Traits::weakHandlingFlag, Key, Value, Extractor, HashFunctions, | 2118 Traits::weakHandlingFlag, Key, Value, Extractor, HashFunctions, |
2119 Traits, KeyTraits, Allocator>::ephemeronIteration, | 2119 Traits, KeyTraits, Allocator>::ephemeronIteration, |
2120 WeakProcessingHashTableHelper< | 2120 WeakProcessingHashTableHelper< |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2270 CollectionIterator end(toBeRemoved.end()); | 2270 CollectionIterator end(toBeRemoved.end()); |
2271 for (CollectionIterator it(toBeRemoved.begin()); it != end; ++it) | 2271 for (CollectionIterator it(toBeRemoved.begin()); it != end; ++it) |
2272 collection.erase(*it); | 2272 collection.erase(*it); |
2273 } | 2273 } |
2274 | 2274 |
2275 } // namespace WTF | 2275 } // namespace WTF |
2276 | 2276 |
2277 #include "wtf/HashIterators.h" | 2277 #include "wtf/HashIterators.h" |
2278 | 2278 |
2279 #endif // WTF_HashTable_h | 2279 #endif // WTF_HashTable_h |
OLD | NEW |