| 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 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 // makes it possible to use this with types that don't support copying. | 784 // makes it possible to use this with types that don't support copying. |
| 785 // The memset to 0 looks like a slow operation but is optimized by the | 785 // The memset to 0 looks like a slow operation but is optimized by the |
| 786 // compilers. | 786 // compilers. |
| 787 memset(&bucket, 0, sizeof(bucket)); | 787 memset(&bucket, 0, sizeof(bucket)); |
| 788 } | 788 } |
| 789 }; | 789 }; |
| 790 | 790 |
| 791 template <typename Key, typename Value, typename Extractor, typename HashFunctio
ns, typename Traits, typename KeyTraits, typename Allocator> | 791 template <typename Key, typename Value, typename Extractor, typename HashFunctio
ns, typename Traits, typename KeyTraits, typename Allocator> |
| 792 inline void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, A
llocator>::initializeBucket(ValueType& bucket) | 792 inline void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, A
llocator>::initializeBucket(ValueType& bucket) |
| 793 { | 793 { |
| 794 // The key and value cannot be initialied atomically, and it would be wrong | |
| 795 // to have a GC when only one was initialized and the other still contained | |
| 796 // garbage (eg. from a previous use of the same slot). Therefore we forbid | |
| 797 // a GC while both the key and the value are initialized. | |
| 798 Allocator::enterGCForbiddenScope(); | |
| 799 HashTableBucketInitializer<Traits::emptyValueIsZero>::template initialize<Tr
aits>(bucket); | 794 HashTableBucketInitializer<Traits::emptyValueIsZero>::template initialize<Tr
aits>(bucket); |
| 800 Allocator::leaveGCForbiddenScope(); | |
| 801 } | 795 } |
| 802 | 796 |
| 803 template <typename Key, typename Value, typename Extractor, typename HashFunctio
ns, typename Traits, typename KeyTraits, typename Allocator> | 797 template <typename Key, typename Value, typename Extractor, typename HashFunctio
ns, typename Traits, typename KeyTraits, typename Allocator> |
| 804 template <typename HashTranslator, typename T, typename Extra> | 798 template <typename HashTranslator, typename T, typename Extra> |
| 805 typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allo
cator>::AddResult HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTra
its, Allocator>::add(const T& key, const Extra& extra) | 799 typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allo
cator>::AddResult HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTra
its, Allocator>::add(const T& key, const Extra& extra) |
| 806 { | 800 { |
| 807 ASSERT(Allocator::isAllocationAllowed()); | 801 ASSERT(Allocator::isAllocationAllowed()); |
| 808 if (!m_table) | 802 if (!m_table) |
| 809 expand(); | 803 expand(); |
| 810 | 804 |
| (...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1463 CollectionIterator end(toBeRemoved.end()); | 1457 CollectionIterator end(toBeRemoved.end()); |
| 1464 for (CollectionIterator it(toBeRemoved.begin()); it != end; ++it) | 1458 for (CollectionIterator it(toBeRemoved.begin()); it != end; ++it) |
| 1465 collection.remove(*it); | 1459 collection.remove(*it); |
| 1466 } | 1460 } |
| 1467 | 1461 |
| 1468 } // namespace WTF | 1462 } // namespace WTF |
| 1469 | 1463 |
| 1470 #include "wtf/HashIterators.h" | 1464 #include "wtf/HashIterators.h" |
| 1471 | 1465 |
| 1472 #endif // WTF_HashTable_h | 1466 #endif // WTF_HashTable_h |
| OLD | NEW |