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) 2008 David Levin <levin@chromium.org> | 3 * Copyright (C) 2008 David Levin <levin@chromium.org> |
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 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 Value* HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Alloca
tor>::allocateTable(unsigned size) | 998 Value* HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Alloca
tor>::allocateTable(unsigned size) |
999 { | 999 { |
1000 size_t allocSize = size * sizeof(ValueType); | 1000 size_t allocSize = size * sizeof(ValueType); |
1001 ValueType* result; | 1001 ValueType* result; |
1002 // Assert that we will not use memset on things with a vtable entry. The | 1002 // Assert that we will not use memset on things with a vtable entry. The |
1003 // compiler will also check this on some platforms. We would like to check | 1003 // compiler will also check this on some platforms. We would like to check |
1004 // this on the whole value (key-value pair), but std::is_polymorphic will re
turn | 1004 // this on the whole value (key-value pair), but std::is_polymorphic will re
turn |
1005 // false for a pair of two types, even if one of the components is | 1005 // false for a pair of two types, even if one of the components is |
1006 // polymorphic. | 1006 // polymorphic. |
1007 static_assert(!Traits::emptyValueIsZero || !std::is_polymorphic<KeyType>::va
lue, "empty value cannot be zero for things with a vtable"); | 1007 static_assert(!Traits::emptyValueIsZero || !std::is_polymorphic<KeyType>::va
lue, "empty value cannot be zero for things with a vtable"); |
1008 | |
1009 #if ENABLE(OILPAN) | |
1010 static_assert(Allocator::isGarbageCollected | 1008 static_assert(Allocator::isGarbageCollected |
1011 || ((!AllowsOnlyPlacementNew<KeyType>::value || !NeedsTracing<KeyType>::
value) | 1009 || ((!AllowsOnlyPlacementNew<KeyType>::value || !NeedsTracing<KeyType>::
value) |
1012 && (!AllowsOnlyPlacementNew<ValueType>::value || !NeedsTracing<ValueType
>::value)) | 1010 && (!AllowsOnlyPlacementNew<ValueType>::value || !NeedsTracing<ValueType
>::value)) |
1013 , "Cannot put DISALLOW_NEW_EXCEPT_PLACEMENT_NEW objects that have trace
methods into an off-heap HashTable"); | 1011 , "Cannot put DISALLOW_NEW_EXCEPT_PLACEMENT_NEW objects that have trace
methods into an off-heap HashTable"); |
1014 #endif | 1012 |
1015 if (Traits::emptyValueIsZero) { | 1013 if (Traits::emptyValueIsZero) { |
1016 result = Allocator::template allocateZeroedHashTableBacking<ValueType, H
ashTable>(allocSize); | 1014 result = Allocator::template allocateZeroedHashTableBacking<ValueType, H
ashTable>(allocSize); |
1017 } else { | 1015 } else { |
1018 result = Allocator::template allocateHashTableBacking<ValueType, HashTab
le>(allocSize); | 1016 result = Allocator::template allocateHashTableBacking<ValueType, HashTab
le>(allocSize); |
1019 for (unsigned i = 0; i < size; i++) | 1017 for (unsigned i = 0; i < size; i++) |
1020 initializeBucket(result[i]); | 1018 initializeBucket(result[i]); |
1021 } | 1019 } |
1022 return result; | 1020 return result; |
1023 } | 1021 } |
1024 | 1022 |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1524 CollectionIterator end(toBeRemoved.end()); | 1522 CollectionIterator end(toBeRemoved.end()); |
1525 for (CollectionIterator it(toBeRemoved.begin()); it != end; ++it) | 1523 for (CollectionIterator it(toBeRemoved.begin()); it != end; ++it) |
1526 collection.remove(*it); | 1524 collection.remove(*it); |
1527 } | 1525 } |
1528 | 1526 |
1529 } // namespace WTF | 1527 } // namespace WTF |
1530 | 1528 |
1531 #include "wtf/HashIterators.h" | 1529 #include "wtf/HashIterators.h" |
1532 | 1530 |
1533 #endif // WTF_HashTable_h | 1531 #endif // WTF_HashTable_h |
OLD | NEW |