Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: third_party/WebKit/Source/wtf/HashTable.h

Issue 2065443002: Rename and improve "traceable" templates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment rewording Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 { 1012 {
1013 size_t allocSize = size * sizeof(ValueType); 1013 size_t allocSize = size * sizeof(ValueType);
1014 ValueType* result; 1014 ValueType* result;
1015 // Assert that we will not use memset on things with a vtable entry. The 1015 // Assert that we will not use memset on things with a vtable entry. The
1016 // compiler will also check this on some platforms. We would like to check 1016 // compiler will also check this on some platforms. We would like to check
1017 // this on the whole value (key-value pair), but std::is_polymorphic will re turn 1017 // this on the whole value (key-value pair), but std::is_polymorphic will re turn
1018 // false for a pair of two types, even if one of the components is 1018 // false for a pair of two types, even if one of the components is
1019 // polymorphic. 1019 // polymorphic.
1020 static_assert(!Traits::emptyValueIsZero || !std::is_polymorphic<KeyType>::va lue, "empty value cannot be zero for things with a vtable"); 1020 static_assert(!Traits::emptyValueIsZero || !std::is_polymorphic<KeyType>::va lue, "empty value cannot be zero for things with a vtable");
1021 static_assert(Allocator::isGarbageCollected 1021 static_assert(Allocator::isGarbageCollected
1022 || ((!AllowsOnlyPlacementNew<KeyType>::value || !NeedsTracing<KeyType>:: value) 1022 || ((!AllowsOnlyPlacementNew<KeyType>::value || !IsTraceable<KeyType>::v alue)
1023 && (!AllowsOnlyPlacementNew<ValueType>::value || !NeedsTracing<ValueType >::value)) 1023 && (!AllowsOnlyPlacementNew<ValueType>::value || !IsTraceable<ValueType> ::value))
1024 , "Cannot put DISALLOW_NEW_EXCEPT_PLACEMENT_NEW objects that have trace methods into an off-heap HashTable"); 1024 , "Cannot put DISALLOW_NEW_EXCEPT_PLACEMENT_NEW objects that have trace methods into an off-heap HashTable");
1025 1025
1026 if (Traits::emptyValueIsZero) { 1026 if (Traits::emptyValueIsZero) {
1027 result = Allocator::template allocateZeroedHashTableBacking<ValueType, H ashTable>(allocSize); 1027 result = Allocator::template allocateZeroedHashTableBacking<ValueType, H ashTable>(allocSize);
1028 } else { 1028 } else {
1029 result = Allocator::template allocateHashTableBacking<ValueType, HashTab le>(allocSize); 1029 result = Allocator::template allocateHashTableBacking<ValueType, HashTab le>(allocSize);
1030 for (unsigned i = 0; i < size; i++) 1030 for (unsigned i = 0; i < size; i++)
1031 initializeBucket(result[i]); 1031 initializeBucket(result[i]);
1032 } 1032 }
1033 return result; 1033 return result;
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 // needed. 1399 // needed.
1400 if (Traits::weakHandlingFlag == NoWeakHandlingInCollections) { 1400 if (Traits::weakHandlingFlag == NoWeakHandlingInCollections) {
1401 Allocator::markNoTracing(visitor, m_table); 1401 Allocator::markNoTracing(visitor, m_table);
1402 } else { 1402 } else {
1403 Allocator::registerDelayedMarkNoTracing(visitor, m_table); 1403 Allocator::registerDelayedMarkNoTracing(visitor, m_table);
1404 // Since we're delaying marking this HashTable, it is possible that the 1404 // Since we're delaying marking this HashTable, it is possible that the
1405 // registerWeakMembers is called multiple times (in rare 1405 // registerWeakMembers is called multiple times (in rare
1406 // cases). However, it shouldn't cause any issue. 1406 // cases). However, it shouldn't cause any issue.
1407 Allocator::registerWeakMembers(visitor, this, m_table, WeakProcessingHas hTableHelper<Traits::weakHandlingFlag, Key, Value, Extractor, HashFunctions, Tra its, KeyTraits, Allocator>::process); 1407 Allocator::registerWeakMembers(visitor, this, m_table, WeakProcessingHas hTableHelper<Traits::weakHandlingFlag, Key, Value, Extractor, HashFunctions, Tra its, KeyTraits, Allocator>::process);
1408 } 1408 }
1409 if (!NeedsTracingTrait<Traits>::value) 1409 if (!IsTraceableInCollectionTrait<Traits>::value)
1410 return; 1410 return;
1411 if (Traits::weakHandlingFlag == WeakHandlingInCollections) { 1411 if (Traits::weakHandlingFlag == WeakHandlingInCollections) {
1412 // If we have both strong and weak pointers in the collection then 1412 // If we have both strong and weak pointers in the collection then
1413 // we queue up the collection for fixed point iteration a la 1413 // we queue up the collection for fixed point iteration a la
1414 // Ephemerons: 1414 // Ephemerons:
1415 // http://dl.acm.org/citation.cfm?doid=263698.263733 - see also 1415 // http://dl.acm.org/citation.cfm?doid=263698.263733 - see also
1416 // http://www.jucs.org/jucs_14_21/eliminating_cycles_in_weak 1416 // http://www.jucs.org/jucs_14_21/eliminating_cycles_in_weak
1417 ASSERT(!enqueued() || Allocator::weakTableRegistered(visitor, this)); 1417 ASSERT(!enqueued() || Allocator::weakTableRegistered(visitor, this));
1418 if (!enqueued()) { 1418 if (!enqueued()) {
1419 Allocator::registerWeakTable(visitor, this, 1419 Allocator::registerWeakTable(visitor, this,
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 CollectionIterator end(toBeRemoved.end()); 1535 CollectionIterator end(toBeRemoved.end());
1536 for (CollectionIterator it(toBeRemoved.begin()); it != end; ++it) 1536 for (CollectionIterator it(toBeRemoved.begin()); it != end; ++it)
1537 collection.remove(*it); 1537 collection.remove(*it);
1538 } 1538 }
1539 1539
1540 } // namespace WTF 1540 } // namespace WTF
1541 1541
1542 #include "wtf/HashIterators.h" 1542 #include "wtf/HashIterators.h"
1543 1543
1544 #endif // WTF_HashTable_h 1544 #endif // WTF_HashTable_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698