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

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

Issue 2531973002: Simple BlinkGC heap compaction. (Closed)
Patch Set: tweak assert Created 4 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
OLDNEW
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 *
(...skipping 2074 matching lines...) Expand 10 before | Expand all | Expand 10 after
2085 // weak pointers the handling is rather different. We don't mark the 2085 // weak pointers the handling is rather different. We don't mark the
2086 // backing store here, so the marking GC will leave the backing unmarked. If 2086 // backing store here, so the marking GC will leave the backing unmarked. If
2087 // the backing is found in any other way than through its HashTable (ie from 2087 // the backing is found in any other way than through its HashTable (ie from
2088 // an iterator) then the mark bit will be set and the pointers will be 2088 // an iterator) then the mark bit will be set and the pointers will be
2089 // marked strongly, avoiding problems with iterating over things that 2089 // marked strongly, avoiding problems with iterating over things that
2090 // disappear due to weak processing while we are iterating over them. We 2090 // disappear due to weak processing while we are iterating over them. We
2091 // register the backing store pointer for delayed marking which will take 2091 // register the backing store pointer for delayed marking which will take
2092 // place after we know if the backing is reachable from elsewhere. We also 2092 // place after we know if the backing is reachable from elsewhere. We also
2093 // register a weakProcessing callback which will perform weak processing if 2093 // register a weakProcessing callback which will perform weak processing if
2094 // needed. 2094 // needed.
2095
2095 if (Traits::weakHandlingFlag == NoWeakHandlingInCollections) { 2096 if (Traits::weakHandlingFlag == NoWeakHandlingInCollections) {
2096 Allocator::markNoTracing(visitor, m_table); 2097 Allocator::markNoTracing(visitor, m_table);
2097 } else { 2098 } else {
2098 Allocator::registerDelayedMarkNoTracing(visitor, m_table); 2099 Allocator::registerDelayedMarkNoTracing(visitor, m_table);
2099 // Since we're delaying marking this HashTable, it is possible that the 2100 // Since we're delaying marking this HashTable, it is possible that the
2100 // registerWeakMembers is called multiple times (in rare 2101 // registerWeakMembers is called multiple times (in rare
2101 // cases). However, it shouldn't cause any issue. 2102 // cases). However, it shouldn't cause any issue.
2102 Allocator::registerWeakMembers( 2103 Allocator::registerWeakMembers(
2103 visitor, this, m_table, 2104 visitor, this, m_table,
2104 WeakProcessingHashTableHelper<Traits::weakHandlingFlag, Key, Value, 2105 WeakProcessingHashTableHelper<Traits::weakHandlingFlag, Key, Value,
2105 Extractor, HashFunctions, Traits, 2106 Extractor, HashFunctions, Traits,
2106 KeyTraits, Allocator>::process); 2107 KeyTraits, Allocator>::process);
2107 } 2108 }
2109 // If the backing store will be moved by sweep compaction, register the
2110 // table reference pointing to the backing store object, so that the
2111 // reference is updated upon object relocation.
2112 Allocator::registerBackingStoreReference(visitor, &m_table);
2108 if (!IsTraceableInCollectionTrait<Traits>::value) 2113 if (!IsTraceableInCollectionTrait<Traits>::value)
2109 return; 2114 return;
2110 if (Traits::weakHandlingFlag == WeakHandlingInCollections) { 2115 if (Traits::weakHandlingFlag == WeakHandlingInCollections) {
2111 // If we have both strong and weak pointers in the collection then 2116 // If we have both strong and weak pointers in the collection then
2112 // we queue up the collection for fixed point iteration a la 2117 // we queue up the collection for fixed point iteration a la
2113 // Ephemerons: 2118 // Ephemerons:
2114 // http://dl.acm.org/citation.cfm?doid=263698.263733 - see also 2119 // http://dl.acm.org/citation.cfm?doid=263698.263733 - see also
2115 // http://www.jucs.org/jucs_14_21/eliminating_cycles_in_weak 2120 // http://www.jucs.org/jucs_14_21/eliminating_cycles_in_weak
2116 ASSERT(!enqueued() || Allocator::weakTableRegistered(visitor, this)); 2121 ASSERT(!enqueued() || Allocator::weakTableRegistered(visitor, this));
2117 if (!enqueued()) { 2122 if (!enqueued()) {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
2273 CollectionIterator end(toBeRemoved.end()); 2278 CollectionIterator end(toBeRemoved.end());
2274 for (CollectionIterator it(toBeRemoved.begin()); it != end; ++it) 2279 for (CollectionIterator it(toBeRemoved.begin()); it != end; ++it)
2275 collection.remove(*it); 2280 collection.remove(*it);
2276 } 2281 }
2277 2282
2278 } // namespace WTF 2283 } // namespace WTF
2279 2284
2280 #include "wtf/HashIterators.h" 2285 #include "wtf/HashIterators.h"
2281 2286
2282 #endif // WTF_HashTable_h 2287 #endif // WTF_HashTable_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698