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 "platform/wtf/Alignment.h" | 27 #include "platform/wtf/Alignment.h" |
27 #include "platform/wtf/Allocator.h" | 28 #include "platform/wtf/Allocator.h" |
28 #include "platform/wtf/Assertions.h" | 29 #include "platform/wtf/Assertions.h" |
29 #include "platform/wtf/ConditionalDestructor.h" | 30 #include "platform/wtf/ConditionalDestructor.h" |
30 #include "platform/wtf/HashTraits.h" | 31 #include "platform/wtf/HashTraits.h" |
31 #include "platform/wtf/PtrUtil.h" | 32 #include "platform/wtf/PtrUtil.h" |
32 #include "platform/wtf/allocator/PartitionAllocator.h" | 33 #include "platform/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 "platform/wtf/Atomics.h" | 39 #include "platform/wtf/Atomics.h" |
40 #include "platform/wtf/Threading.h" | 40 #include "platform/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 "platform/wtf/DataLog.h" | 45 #include "platform/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 stats_->recordCollisionAtCount(perTableProbeCount) | 55 stats_->recordCollisionAtCount(perTableProbeCount) |
(...skipping 2049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2105 KeyTraits, Allocator>::Process); | 2105 KeyTraits, Allocator>::Process); |
2106 } | 2106 } |
2107 // If the backing store will be moved by sweep compaction, register the | 2107 // If the backing store will be moved by sweep compaction, register the |
2108 // table reference pointing to the backing store object, so that the | 2108 // table reference pointing to the backing store object, so that the |
2109 // reference is updated upon object relocation. A no-op if not enabled | 2109 // reference is updated upon object relocation. A no-op if not enabled |
2110 // by the visitor. | 2110 // by the visitor. |
2111 Allocator::RegisterBackingStoreReference(visitor, &table_); | 2111 Allocator::RegisterBackingStoreReference(visitor, &table_); |
2112 if (!IsTraceableInCollectionTrait<Traits>::value) | 2112 if (!IsTraceableInCollectionTrait<Traits>::value) |
2113 return; | 2113 return; |
2114 if (Traits::kWeakHandlingFlag == kWeakHandlingInCollections) { | 2114 if (Traits::kWeakHandlingFlag == kWeakHandlingInCollections) { |
2115 // If we have both strong and weak pointers in the collection then | 2115 // If we have both strong and weak pointers in the collection then |
2116 // we queue up the collection for fixed point iteration a la | 2116 // we queue up the collection for fixed point iteration a la |
2117 // Ephemerons: | 2117 // Ephemerons: |
2118 // http://dl.acm.org/citation.cfm?doid=263698.263733 - see also | 2118 // http://dl.acm.org/citation.cfm?doid=263698.263733 - see also |
2119 // http://www.jucs.org/jucs_14_21/eliminating_cycles_in_weak | 2119 // http://www.jucs.org/jucs_14_21/eliminating_cycles_in_weak |
2120 #if DCHECK_IS_ON() | 2120 #if DCHECK_IS_ON() |
2121 DCHECK(!Enqueued() || Allocator::WeakTableRegistered(visitor, this)); | 2121 DCHECK(!Enqueued() || Allocator::WeakTableRegistered(visitor, this)); |
2122 #endif | 2122 #endif |
2123 if (!Enqueued()) { | 2123 if (!Enqueued()) { |
2124 Allocator::RegisterWeakTable( | 2124 Allocator::RegisterWeakTable( |
2125 visitor, this, | 2125 visitor, this, |
2126 WeakProcessingHashTableHelper< | 2126 WeakProcessingHashTableHelper< |
2127 Traits::kWeakHandlingFlag, Key, Value, Extractor, HashFunctions, | 2127 Traits::kWeakHandlingFlag, Key, Value, Extractor, HashFunctions, |
2128 Traits, KeyTraits, Allocator>::EphemeronIteration, | 2128 Traits, KeyTraits, Allocator>::EphemeronIteration, |
2129 WeakProcessingHashTableHelper< | 2129 WeakProcessingHashTableHelper< |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2280 CollectionIterator end(to_be_removed.end()); | 2280 CollectionIterator end(to_be_removed.end()); |
2281 for (CollectionIterator it(to_be_removed.begin()); it != end; ++it) | 2281 for (CollectionIterator it(to_be_removed.begin()); it != end; ++it) |
2282 collection.erase(*it); | 2282 collection.erase(*it); |
2283 } | 2283 } |
2284 | 2284 |
2285 } // namespace WTF | 2285 } // namespace WTF |
2286 | 2286 |
2287 #include "platform/wtf/HashIterators.h" | 2287 #include "platform/wtf/HashIterators.h" |
2288 | 2288 |
2289 #endif // WTF_HashTable_h | 2289 #endif // WTF_HashTable_h |
OLD | NEW |