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

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

Issue 106423003: [oilpan] Rename visit to mark. (Closed) Base URL: svn://svn.chromium.org/blink/branches/oilpan
Patch Set: Address comments. Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « Source/modules/websockets/WebSocket.h ('k') | Source/wtf/HashTraits.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 1194
1195 template<typename Key, typename Value, typename Extractor, typename HashFunc tions, typename Traits, typename KeyTraits, typename Allocator> 1195 template<typename Key, typename Value, typename Extractor, typename HashFunc tions, typename Traits, typename KeyTraits, typename Allocator>
1196 struct WeakProcessingHashTableHelper<true, Key, Value, Extractor, HashFuncti ons, Traits, KeyTraits, Allocator> { 1196 struct WeakProcessingHashTableHelper<true, Key, Value, Extractor, HashFuncti ons, Traits, KeyTraits, Allocator> {
1197 static void process(typename Allocator::Visitor* visitor, void* closure) 1197 static void process(typename Allocator::Visitor* visitor, void* closure)
1198 { 1198 {
1199 typedef HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyT raits, Allocator> HashTableType; 1199 typedef HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyT raits, Allocator> HashTableType;
1200 HashTableType* table = reinterpret_cast<HashTableType*>(closure); 1200 HashTableType* table = reinterpret_cast<HashTableType*>(closure);
1201 if (table->m_table) { 1201 if (table->m_table) {
1202 // This just marks it live and does not push anything onto the 1202 // This just marks it live and does not push anything onto the
1203 // marking stack because there is no trace for void*. 1203 // marking stack because there is no trace for void*.
1204 Allocator::visitWith(visitor, reinterpret_cast<void*>(table->m_t able)); 1204 Allocator::adjustAndMark(visitor, reinterpret_cast<void*>(table- >m_table));
1205 // Now perform weak processing (this is a no-op if the backing 1205 // Now perform weak processing (this is a no-op if the backing
1206 // was accessible through an iterator and was already marked 1206 // was accessible through an iterator and was already marked
1207 // strongly). 1207 // strongly).
1208 for (typename HashTableType::ValueType* element = table->m_table + table->m_tableSize - 1; element >= table->m_table; element--) { 1208 for (typename HashTableType::ValueType* element = table->m_table + table->m_tableSize - 1; element >= table->m_table; element--) {
1209 if (!HashTableType::isEmptyOrDeletedBucket(*element)) { 1209 if (!HashTableType::isEmptyOrDeletedBucket(*element)) {
1210 if (Allocator::hasDeadMember(visitor, *element)) { 1210 if (Allocator::hasDeadMember(visitor, *element)) {
1211 HashTableType::deleteBucket(*element); // Also calls the destructor. 1211 HashTableType::deleteBucket(*element); // Also calls the destructor.
1212 table->m_deletedCount++; 1212 table->m_deletedCount++;
1213 table->m_keyCount--; 1213 table->m_keyCount--;
1214 // We don't rehash the backing until the next add 1214 // We don't rehash the backing until the next add
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 return *this; 1328 return *this;
1329 } 1329 }
1330 1330
1331 template<typename Key, typename Value, typename Extractor, typename HashFunc tions, typename Traits, typename KeyTraits, typename Allocator> 1331 template<typename Key, typename Value, typename Extractor, typename HashFunc tions, typename Traits, typename KeyTraits, typename Allocator>
1332 void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allo cator>::trace(typename Allocator::Visitor* visitor) 1332 void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allo cator>::trace(typename Allocator::Visitor* visitor)
1333 { 1333 {
1334 // If someone else already marked the backing and queued up the trace 1334 // If someone else already marked the backing and queued up the trace
1335 // and/or weak callback then we are done. 1335 // and/or weak callback then we are done.
1336 if (!m_table || visitor->isAlive(m_table)) 1336 if (!m_table || visitor->isAlive(m_table))
1337 return; 1337 return;
1338 // Normally, we visit the backing store cast to a void pointer. This 1338 // Normally, we mark the backing store cast to a void pointer. This
1339 // means it is marked live, but the pointers inside it are not visited. 1339 // means it is marked live, but the pointers inside it are not marked.
1340 // Instead we will visit the pointers below. However, for backing 1340 // Instead we will mark the pointers below. However, for backing
1341 // stores that contain weak pointers the handling is rather different. 1341 // stores that contain weak pointers the handling is rather different.
1342 // We don't visit the backing store here, so the marking GC will leave 1342 // We don't mark the backing store here, so the marking GC will leave
1343 // the backing unmarked. If the backing is found in any other way than 1343 // the backing unmarked. If the backing is found in any other way than
1344 // through its HashTable (ie from an iterator) then the mark bit will 1344 // through its HashTable (ie from an iterator) then the mark bit will
1345 // be set and the pointers will be visited strongly, avoiding problems 1345 // be set and the pointers will be marked strongly, avoiding problems
1346 // with iterating over things that disappear due to weak processing 1346 // with iterating over things that disappear due to weak processing
1347 // while we are iterating over them. The weakProcessing callback will 1347 // while we are iterating over them. The weakProcessing callback will
1348 // visit the backing as a void pointer, marking it live and will 1348 // mark the backing as a void pointer, and will perform weak processing
1349 // perform weak processing if needed. 1349 // if needed.
1350 if (!Traits::isWeak) 1350 if (!Traits::isWeak)
1351 Allocator::visitWith(visitor, reinterpret_cast<void*>(m_table)); 1351 Allocator::adjustAndMark(visitor, reinterpret_cast<void*>(m_table));
1352 else 1352 else
1353 Allocator::registerWeakPointers(visitor, this, WeakProcessingHashTab leHelper<Traits::isWeak, Key, Value, Extractor, HashFunctions, Traits, KeyTraits , Allocator>::process); 1353 Allocator::registerWeakPointers(visitor, this, WeakProcessingHashTab leHelper<Traits::isWeak, Key, Value, Extractor, HashFunctions, Traits, KeyTraits , Allocator>::process);
1354 if (Traits::needsVisiting) { 1354 if (Traits::needsTracing) {
1355 for (ValueType* element = m_table + m_tableSize - 1; element >= m_ta ble; element--) { 1355 for (ValueType* element = m_table + m_tableSize - 1; element >= m_ta ble; element--) {
1356 if (!isEmptyOrDeletedBucket(*element)) 1356 if (!isEmptyOrDeletedBucket(*element))
1357 Allocator::template visitWith<ValueType, Traits>(visitor, *e lement); 1357 Allocator::template adjustAndMark<ValueType, Traits>(visitor , *element);
1358 } 1358 }
1359 } 1359 }
1360 } 1360 }
1361 1361
1362 #if !ASSERT_DISABLED 1362 #if !ASSERT_DISABLED
1363 1363
1364 template<typename Key, typename Value, typename Extractor, typename HashFunc tions, typename Traits, typename KeyTraits, typename Allocator> 1364 template<typename Key, typename Value, typename Extractor, typename HashFunc tions, typename Traits, typename KeyTraits, typename Allocator>
1365 void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allo cator>::checkTableConsistency() const 1365 void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allo cator>::checkTableConsistency() const
1366 { 1366 {
1367 checkTableConsistencyExceptSize(); 1367 checkTableConsistencyExceptSize();
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1563 inline bool operator!=(const HashTableIteratorAdapter<T, U>& a, const HashTa bleConstIteratorAdapter<T, U>& b) 1563 inline bool operator!=(const HashTableIteratorAdapter<T, U>& a, const HashTa bleConstIteratorAdapter<T, U>& b)
1564 { 1564 {
1565 return a.m_impl != b.m_impl; 1565 return a.m_impl != b.m_impl;
1566 } 1566 }
1567 1567
1568 } // namespace WTF 1568 } // namespace WTF
1569 1569
1570 #include <wtf/HashIterators.h> 1570 #include <wtf/HashIterators.h>
1571 1571
1572 #endif // WTF_HashTable_h 1572 #endif // WTF_HashTable_h
OLDNEW
« no previous file with comments | « Source/modules/websockets/WebSocket.h ('k') | Source/wtf/HashTraits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698