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

Side by Side Diff: Source/heap/Heap.h

Issue 216723002: Make sure all destructors are called in HeapHashMap and HeapHashSet (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: CR feedback Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « Source/heap/Handle.h ('k') | Source/heap/HeapTest.cpp » ('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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 // typedef ensures that the allocation is done with the correct templated 1305 // typedef ensures that the allocation is done with the correct templated
1306 // instantiation of the allocation function. This ensures the correct GC 1306 // instantiation of the allocation function. This ensures the correct GC
1307 // map is written when backing allocations take place. 1307 // map is written when backing allocations take place.
1308 template<typename T, typename Traits> 1308 template<typename T, typename Traits>
1309 struct VectorBackingHelper { 1309 struct VectorBackingHelper {
1310 typedef HeapVectorBacking<T, Traits> Type; 1310 typedef HeapVectorBacking<T, Traits> Type;
1311 }; 1311 };
1312 1312
1313 // Like the VectorBackingHelper, but this type is used for HashSet and 1313 // Like the VectorBackingHelper, but this type is used for HashSet and
1314 // HashMap, both of which are implemented using HashTable. 1314 // HashMap, both of which are implemented using HashTable.
1315 template<typename T, typename U, typename V, typename W, typename X> 1315 template<typename Table>
1316 struct HashTableBackingHelper { 1316 struct HashTableBackingHelper {
1317 typedef HeapHashTableBacking<T, U, V, W, X> Type; 1317 typedef HeapHashTableBacking<Table> Type;
1318 }; 1318 };
1319 1319
1320 template<typename T> 1320 template<typename T>
1321 struct OtherType { 1321 struct OtherType {
1322 typedef T* Type; 1322 typedef T* Type;
1323 }; 1323 };
1324 1324
1325 template<typename T> 1325 template<typename T>
1326 static T& getOther(T* other) 1326 static T& getOther(T* other)
1327 { 1327 {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1392 struct ThreadingTrait<Member<T> > { 1392 struct ThreadingTrait<Member<T> > {
1393 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; 1393 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
1394 }; 1394 };
1395 1395
1396 template<typename T> 1396 template<typename T>
1397 struct ThreadingTrait<WeakMember<T> > { 1397 struct ThreadingTrait<WeakMember<T> > {
1398 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; 1398 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
1399 }; 1399 };
1400 1400
1401 template<typename Key, typename Value, typename T, typename U, typename V> 1401 template<typename Key, typename Value, typename T, typename U, typename V>
1402 struct ThreadingTrait<HashMap<Key, Value, HeapAllocator, T, U, V> > { 1402 struct ThreadingTrait<HashMap<Key, Value, T, U, V, HeapAllocator> > {
1403 static const ThreadAffinity Affinity = 1403 static const ThreadAffinity Affinity =
1404 (ThreadingTrait<Key>::Affinity == MainThreadOnly) 1404 (ThreadingTrait<Key>::Affinity == MainThreadOnly)
1405 && (ThreadingTrait<Value>::Affinity == MainThreadOnly) ? MainThreadOnly : AnyThread; 1405 && (ThreadingTrait<Value>::Affinity == MainThreadOnly) ? MainThreadOnly : AnyThread;
1406 }; 1406 };
1407 1407
1408 template<typename First, typename Second> 1408 template<typename First, typename Second>
1409 struct ThreadingTrait<WTF::KeyValuePair<First, Second> > { 1409 struct ThreadingTrait<WTF::KeyValuePair<First, Second> > {
1410 static const ThreadAffinity Affinity = 1410 static const ThreadAffinity Affinity =
1411 (ThreadingTrait<First>::Affinity == MainThreadOnly) 1411 (ThreadingTrait<First>::Affinity == MainThreadOnly)
1412 && (ThreadingTrait<Second>::Affinity == MainThreadOnly) ? MainThreadOnly : AnyThread; 1412 && (ThreadingTrait<Second>::Affinity == MainThreadOnly) ? MainThreadOnly : AnyThread;
1413 }; 1413 };
1414 1414
1415 template<typename T, typename U, typename V> 1415 template<typename T, typename U, typename V>
1416 struct ThreadingTrait<HashSet<T, HeapAllocator, U, V> > { 1416 struct ThreadingTrait<HashSet<T, U, V, HeapAllocator> > {
1417 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; 1417 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
1418 }; 1418 };
1419 1419
1420 1420
1421 template<typename T, size_t inlineCapacity> 1421 template<typename T, size_t inlineCapacity>
1422 struct ThreadingTrait<Vector<T, inlineCapacity, HeapAllocator> > { 1422 struct ThreadingTrait<Vector<T, inlineCapacity, HeapAllocator> > {
1423 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; 1423 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
1424 }; 1424 };
1425 1425
1426 template<typename T, typename Traits> 1426 template<typename T, typename Traits>
1427 struct ThreadingTrait<HeapVectorBacking<T, Traits> > { 1427 struct ThreadingTrait<HeapVectorBacking<T, Traits> > {
1428 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; 1428 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
1429 }; 1429 };
1430 1430
1431 template<typename Key, typename Value, typename Extractor, typename Traits, type name KeyTraits> 1431 template<typename Table>
1432 struct ThreadingTrait<HeapHashTableBacking<Key, Value, Extractor, Traits, KeyTra its> > { 1432 struct ThreadingTrait<HeapHashTableBacking<Table> > {
1433 typedef typename Table::KeyType Key;
1434 typedef typename Table::ValueType Value;
1433 static const ThreadAffinity Affinity = 1435 static const ThreadAffinity Affinity =
1434 (ThreadingTrait<Key>::Affinity == MainThreadOnly) 1436 (ThreadingTrait<Key>::Affinity == MainThreadOnly)
1435 && (ThreadingTrait<Value>::Affinity == MainThreadOnly) ? MainThreadOnly : AnyThread; 1437 && (ThreadingTrait<Value>::Affinity == MainThreadOnly) ? MainThreadOnly : AnyThread;
1436 }; 1438 };
1437 1439
1438 template<typename Key, typename Value> 1440 template<typename T, typename U, typename V, typename W, typename X>
1439 struct ThreadingTrait<HeapHashMap<Key, Value> > : public ThreadingTrait<HashMap< Key, Value, HeapAllocator> > { }; 1441 struct ThreadingTrait<HeapHashMap<T, U, V, W, X> > : public ThreadingTrait<HashM ap<T, U, V, W, X, HeapAllocator> > { };
1440 template<typename Value> 1442
1441 struct ThreadingTrait<HeapHashSet<Value> > : public ThreadingTrait<HashSet<Value , HeapAllocator> > { }; 1443 template<typename T, typename U, typename V>
1444 struct ThreadingTrait<HeapHashSet<T, U, V> > : public ThreadingTrait<HashSet<T, U, V, HeapAllocator> > { };
1445
1442 template<typename T, size_t inlineCapacity> 1446 template<typename T, size_t inlineCapacity>
1443 struct ThreadingTrait<HeapVector<T, inlineCapacity> > : public ThreadingTrait<Ve ctor<T, inlineCapacity, HeapAllocator> > { }; 1447 struct ThreadingTrait<HeapVector<T, inlineCapacity> > : public ThreadingTrait<Ve ctor<T, inlineCapacity, HeapAllocator> > { };
1444 1448
1445 // The standard implementation of GCInfoTrait<T>::get() just returns a static 1449 // The standard implementation of GCInfoTrait<T>::get() just returns a static
1446 // from the class T, but we can't do that for HashMap, HashSet and Vector 1450 // from the class T, but we can't do that for HashMap, HashSet and Vector
1447 // because they are in WTF and know nothing of GCInfos. Instead we have a 1451 // because they are in WTF and know nothing of GCInfos. Instead we have a
1448 // specialization of GCInfoTrait for these three classes here. 1452 // specialization of GCInfoTrait for these three classes here.
1449 1453
1450 template<typename Key, typename Value, typename T, typename U, typename V> 1454 template<typename Key, typename Value, typename T, typename U, typename V>
1451 struct GCInfoTrait<HashMap<Key, Value, T, U, V, HeapAllocator> > { 1455 struct GCInfoTrait<HashMap<Key, Value, T, U, V, HeapAllocator> > {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1509 static const GCInfo info; 1513 static const GCInfo info;
1510 }; 1514 };
1511 1515
1512 template<typename T, typename Traits> 1516 template<typename T, typename Traits>
1513 const GCInfo GCInfoTrait<HeapVectorBacking<T, Traits> >::info = { 1517 const GCInfo GCInfoTrait<HeapVectorBacking<T, Traits> >::info = {
1514 TraceTrait<HeapVectorBacking<T, Traits> >::trace, 1518 TraceTrait<HeapVectorBacking<T, Traits> >::trace,
1515 FinalizerTrait<HeapVectorBacking<T, Traits> >::finalize, 1519 FinalizerTrait<HeapVectorBacking<T, Traits> >::finalize,
1516 Traits::needsDestruction, 1520 Traits::needsDestruction,
1517 }; 1521 };
1518 1522
1519 template<typename T, typename U, typename V, typename W, typename X> 1523 template<typename Table>
1520 struct GCInfoTrait<HeapHashTableBacking<T, U, V, W, X> > { 1524 struct GCInfoTrait<HeapHashTableBacking<Table> > {
1521 static const GCInfo* get() { return &info; } 1525 static const GCInfo* get() { return &info; }
1522 static const GCInfo info; 1526 static const GCInfo info;
1523 }; 1527 };
1524 1528
1525 template<typename T, typename U, typename V, typename Traits, typename W> 1529 template<typename Table>
1526 const GCInfo GCInfoTrait<HeapHashTableBacking<T, U, V, Traits, W> >::info = { 1530 const GCInfo GCInfoTrait<HeapHashTableBacking<Table> >::info = {
1527 TraceTrait<HeapHashTableBacking<T, U, V, Traits, W> >::trace, 1531 TraceTrait<HeapHashTableBacking<Table> >::trace,
1528 FinalizerTrait<HeapHashTableBacking<T, U, V, Traits, W> >::finalize, 1532 HeapHashTableBacking<Table>::finalize,
1529 Traits::needsDestruction, 1533 Table::ValueTraits::needsDestruction,
1530 }; 1534 };
1531 1535
1532 template<bool markWeakMembersStrongly, typename T, typename Traits> 1536 template<bool markWeakMembersStrongly, typename T, typename Traits>
1533 struct BaseVisitVectorBackingTrait { 1537 struct BaseVisitVectorBackingTrait {
1534 static void mark(WebCore::Visitor* visitor, void* self) 1538 static void mark(WebCore::Visitor* visitor, void* self)
1535 { 1539 {
1536 // The allocator can oversize the allocation a little, according to 1540 // The allocator can oversize the allocation a little, according to
1537 // the allocation granularity. The extra size is included in the 1541 // the allocation granularity. The extra size is included in the
1538 // payloadSize call below, since there is nowhere to store the 1542 // payloadSize call below, since there is nowhere to store the
1539 // originally allocated memory. This assert ensures that visiting the 1543 // originally allocated memory. This assert ensures that visiting the
1540 // last bit of memory can't cause trouble. 1544 // last bit of memory can't cause trouble.
1541 COMPILE_ASSERT(!WTF::ShouldBeTraced<Traits>::value || sizeof(T) > alloca tionGranularity || Traits::canInitializeWithMemset, HeapOverallocationCanCauseSp uriousVisits); 1545 COMPILE_ASSERT(!WTF::ShouldBeTraced<Traits>::value || sizeof(T) > alloca tionGranularity || Traits::canInitializeWithMemset, HeapOverallocationCanCauseSp uriousVisits);
1542 1546
1543 T* array = reinterpret_cast<T*>(self); 1547 T* array = reinterpret_cast<T*>(self);
1544 WebCore::FinalizedHeapObjectHeader* header = WebCore::FinalizedHeapObjec tHeader::fromPayload(self); 1548 WebCore::FinalizedHeapObjectHeader* header = WebCore::FinalizedHeapObjec tHeader::fromPayload(self);
1545 // Use the payload size as recorded by the heap to determine how many 1549 // Use the payload size as recorded by the heap to determine how many
1546 // elements to mark. 1550 // elements to mark.
1547 size_t length = header->payloadSize() / sizeof(T); 1551 size_t length = header->payloadSize() / sizeof(T);
1548 for (size_t i = 0; i < length; i++) 1552 for (size_t i = 0; i < length; i++)
1549 CollectionBackingTraceTrait<WTF::ShouldBeTraced<Traits>::value, Trai ts::isWeak, markWeakMembersStrongly, T, Traits>::mark(visitor, array[i]); 1553 CollectionBackingTraceTrait<WTF::ShouldBeTraced<Traits>::value, Trai ts::isWeak, markWeakMembersStrongly, T, Traits>::mark(visitor, array[i]);
1550 } 1554 }
1551 }; 1555 };
1552 1556
1553 template<bool markWeakMembersStrongly, typename Key, typename Value, typename Ex tractor, typename Traits, typename KeyTraits> 1557 template<bool markWeakMembersStrongly, typename Table>
1554 struct BaseVisitHashTableBackingTrait { 1558 struct BaseVisitHashTableBackingTrait {
1559 typedef typename Table::ValueType Value;
1560 typedef typename Table::ValueTraits Traits;
1555 static void mark(WebCore::Visitor* visitor, void* self) 1561 static void mark(WebCore::Visitor* visitor, void* self)
1556 { 1562 {
1557 Value* array = reinterpret_cast<Value*>(self); 1563 Value* array = reinterpret_cast<Value*>(self);
1558 WebCore::FinalizedHeapObjectHeader* header = WebCore::FinalizedHeapObjec tHeader::fromPayload(self); 1564 WebCore::FinalizedHeapObjectHeader* header = WebCore::FinalizedHeapObjec tHeader::fromPayload(self);
1559 size_t length = header->payloadSize() / sizeof(Value); 1565 size_t length = header->payloadSize() / sizeof(Value);
1560 for (size_t i = 0; i < length; i++) { 1566 for (size_t i = 0; i < length; i++) {
1561 if (!WTF::HashTableHelper<Value, Extractor, KeyTraits>::isEmptyOrDel etedBucket(array[i])) 1567 if (!WTF::HashTableHelper<Value, typename Table::ExtractorType, type name Table::KeyTraitsType>::isEmptyOrDeletedBucket(array[i]))
1562 CollectionBackingTraceTrait<WTF::ShouldBeTraced<Traits>::value, Traits::isWeak, markWeakMembersStrongly, Value, Traits>::mark(visitor, array[i]) ; 1568 CollectionBackingTraceTrait<WTF::ShouldBeTraced<Traits>::value, Traits::isWeak, markWeakMembersStrongly, Value, Traits>::mark(visitor, array[i]) ;
1563 } 1569 }
1564 } 1570 }
1565 }; 1571 };
1566 1572
1567 template<bool markWeakMembersStrongly, typename Key, typename Value, typename Tr aits> 1573 template<bool markWeakMembersStrongly, typename Key, typename Value, typename Tr aits>
1568 struct BaseVisitKeyValuePairTrait { 1574 struct BaseVisitKeyValuePairTrait {
1569 static void mark(WebCore::Visitor* visitor, WTF::KeyValuePair<Key, Value>& s elf) 1575 static void mark(WebCore::Visitor* visitor, WTF::KeyValuePair<Key, Value>& s elf)
1570 { 1576 {
1571 ASSERT(WTF::ShouldBeTraced<Traits>::value || (Traits::isWeak && markWeak MembersStrongly)); 1577 ASSERT(WTF::ShouldBeTraced<Traits>::value || (Traits::isWeak && markWeak MembersStrongly));
(...skipping 26 matching lines...) Expand all
1598 template<typename T, typename Traits> 1604 template<typename T, typename Traits>
1599 struct CollectionBackingTraceTrait<false, true, true, HeapVectorBacking<T, Trait s>, void> : public BaseVisitVectorBackingTrait<true, T, Traits> { 1605 struct CollectionBackingTraceTrait<false, true, true, HeapVectorBacking<T, Trait s>, void> : public BaseVisitVectorBackingTrait<true, T, Traits> {
1600 }; 1606 };
1601 1607
1602 // TXX (vector) 1608 // TXX (vector)
1603 template<bool isWeak, bool markWeakMembersStrongly, typename T, typename Traits> 1609 template<bool isWeak, bool markWeakMembersStrongly, typename T, typename Traits>
1604 struct CollectionBackingTraceTrait<true, isWeak, markWeakMembersStrongly, HeapVe ctorBacking<T, Traits>, void> : public BaseVisitVectorBackingTrait<markWeakMembe rsStrongly, T, Traits> { 1610 struct CollectionBackingTraceTrait<true, isWeak, markWeakMembersStrongly, HeapVe ctorBacking<T, Traits>, void> : public BaseVisitVectorBackingTrait<markWeakMembe rsStrongly, T, Traits> {
1605 }; 1611 };
1606 1612
1607 // FTT (hash table) 1613 // FTT (hash table)
1608 template<typename Key, typename Value, typename Extractor, typename Traits, type name KeyTraits> 1614 template<typename Table>
1609 struct CollectionBackingTraceTrait<false, true, true, HeapHashTableBacking<Key, Value, Extractor, Traits, KeyTraits>, void> : public BaseVisitHashTableBackingTr ait<true, Key, Value, Extractor, Traits, KeyTraits> { 1615 struct CollectionBackingTraceTrait<false, true, true, HeapHashTableBacking<Table >, void> : public BaseVisitHashTableBackingTrait<true, Table> {
1610 }; 1616 };
1611 1617
1612 // TXX (hash table) 1618 // TXX (hash table)
1613 template<bool isWeak, bool markWeakMembersStrongly, typename Key, typename Value , typename Extractor, typename Traits, typename KeyTraits> 1619 template<bool isWeak, bool markWeakMembersStrongly, typename Table>
1614 struct CollectionBackingTraceTrait<true, isWeak, markWeakMembersStrongly, HeapHa shTableBacking<Key, Value, Extractor, Traits, KeyTraits>, void> : public BaseVis itHashTableBackingTrait<markWeakMembersStrongly, Key, Value, Extractor, Traits, KeyTraits> { 1620 struct CollectionBackingTraceTrait<true, isWeak, markWeakMembersStrongly, HeapHa shTableBacking<Table>, void> : public BaseVisitHashTableBackingTrait<markWeakMem bersStrongly, Table> {
1615 }; 1621 };
1616 1622
1617 // FTT (key value pair) 1623 // FTT (key value pair)
1618 template<typename Key, typename Value, typename Traits> 1624 template<typename Key, typename Value, typename Traits>
1619 struct CollectionBackingTraceTrait<false, true, true, WTF::KeyValuePair<Key, Val ue>, Traits> : public BaseVisitKeyValuePairTrait<true, Key, Value, Traits> { 1625 struct CollectionBackingTraceTrait<false, true, true, WTF::KeyValuePair<Key, Val ue>, Traits> : public BaseVisitKeyValuePairTrait<true, Key, Value, Traits> {
1620 }; 1626 };
1621 1627
1622 // TXX (key value pair) 1628 // TXX (key value pair)
1623 template<bool isWeak, bool markWeakMembersStrongly, typename Key, typename Value , typename Traits> 1629 template<bool isWeak, bool markWeakMembersStrongly, typename Key, typename Value , typename Traits>
1624 struct CollectionBackingTraceTrait<true, isWeak, markWeakMembersStrongly, WTF::K eyValuePair<Key, Value>, Traits> : public BaseVisitKeyValuePairTrait<markWeakMem bersStrongly, Key, Value, Traits> { 1630 struct CollectionBackingTraceTrait<true, isWeak, markWeakMembersStrongly, WTF::K eyValuePair<Key, Value>, Traits> : public BaseVisitKeyValuePairTrait<markWeakMem bersStrongly, Key, Value, Traits> {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1678 #endif 1684 #endif
1679 } 1685 }
1680 }; 1686 };
1681 1687
1682 // The trace trait for the heap hashtable backing is used when we find a 1688 // The trace trait for the heap hashtable backing is used when we find a
1683 // direct pointer to the backing from the conservative stack scanner. This 1689 // direct pointer to the backing from the conservative stack scanner. This
1684 // normally indicates that there is an ongoing iteration over the table, and so 1690 // normally indicates that there is an ongoing iteration over the table, and so
1685 // we disable weak processing of table entries. When the backing is found 1691 // we disable weak processing of table entries. When the backing is found
1686 // through the owning hash table we mark differently, in order to do weak 1692 // through the owning hash table we mark differently, in order to do weak
1687 // processing. 1693 // processing.
1688 template<typename Key, typename Value, typename Extractor, typename Traits, type name KeyTraits> 1694 template<typename Table>
1689 struct TraceTrait<HeapHashTableBacking<Key, Value, Extractor, Traits, KeyTraits> > { 1695 struct TraceTrait<HeapHashTableBacking<Table> > {
1690 typedef HeapHashTableBacking<Key, Value, Extractor, Traits, KeyTraits> Backi ng; 1696 typedef HeapHashTableBacking<Table> Backing;
1697 typedef typename Table::ValueTraits Traits;
1691 static void trace(WebCore::Visitor* visitor, void* self) 1698 static void trace(WebCore::Visitor* visitor, void* self)
1692 { 1699 {
1693 if (WTF::ShouldBeTraced<Traits>::value || Traits::isWeak) 1700 if (WTF::ShouldBeTraced<Traits>::value || Traits::isWeak)
1694 CollectionBackingTraceTrait<WTF::ShouldBeTraced<Traits>::value, Trai ts::isWeak, true, HeapHashTableBacking<Key, Value, Extractor, Traits, KeyTraits> , void>::mark(visitor, self); 1701 CollectionBackingTraceTrait<WTF::ShouldBeTraced<Traits>::value, Trai ts::isWeak, true, Backing, void>::mark(visitor, self);
1695 } 1702 }
1696 static void mark(Visitor* visitor, const Backing* backing) 1703 static void mark(Visitor* visitor, const Backing* backing)
1697 { 1704 {
1698 if (WTF::ShouldBeTraced<Traits>::value || Traits::isWeak) 1705 if (WTF::ShouldBeTraced<Traits>::value || Traits::isWeak)
1699 visitor->mark(backing, &trace); 1706 visitor->mark(backing, &trace);
1700 else 1707 else
1701 visitor->mark(backing, 0); 1708 visitor->mark(backing, 0);
1702 } 1709 }
1703 static void checkGCInfo(Visitor* visitor, const Backing* backing) 1710 static void checkGCInfo(Visitor* visitor, const Backing* backing)
1704 { 1711 {
1705 #ifndef NDEBUG 1712 #ifndef NDEBUG
1706 visitor->checkGCInfo(const_cast<Backing*>(backing), GCInfoTrait<Backing> ::get()); 1713 visitor->checkGCInfo(const_cast<Backing*>(backing), GCInfoTrait<Backing> ::get());
1707 #endif 1714 #endif
1708 } 1715 }
1709 }; 1716 };
1710 1717
1718 template<typename Table>
1719 void HeapHashTableBacking<Table>::finalize(void* pointer)
1720 {
1721 typedef typename Table::ValueType Value;
1722 ASSERT(Table::ValueTraits::needsDestruction);
1723 FinalizedHeapObjectHeader* header = FinalizedHeapObjectHeader::fromPayload(p ointer);
1724 // Use the payload size as recorded by the heap to determine how many
1725 // elements to finalize.
1726 size_t length = header->payloadSize() / sizeof(Value);
1727 Value* table = reinterpret_cast<Value*>(pointer);
1728 for (unsigned i = 0; i < length; i++) {
1729 if (!Table::isEmptyOrDeletedBucket(table[i]))
1730 table[i].~Value();
1731 }
1732 }
1733
1711 template<typename T, typename U, typename V, typename W, typename X> 1734 template<typename T, typename U, typename V, typename W, typename X>
1712 struct GCInfoTrait<HeapHashMap<T, U, V, W, X> > : public GCInfoTrait<HashMap<T, U, V, W, X, HeapAllocator> > { }; 1735 struct GCInfoTrait<HeapHashMap<T, U, V, W, X> > : public GCInfoTrait<HashMap<T, U, V, W, X, HeapAllocator> > { };
1713 template<typename T, typename U, typename V> 1736 template<typename T, typename U, typename V>
1714 struct GCInfoTrait<HeapHashSet<T, U, V> > : public GCInfoTrait<HashSet<T, U, V, HeapAllocator> > { }; 1737 struct GCInfoTrait<HeapHashSet<T, U, V> > : public GCInfoTrait<HashSet<T, U, V, HeapAllocator> > { };
1715 template<typename T, size_t inlineCapacity> 1738 template<typename T, size_t inlineCapacity>
1716 struct GCInfoTrait<HeapVector<T, inlineCapacity> > : public GCInfoTrait<Vector<T , inlineCapacity, HeapAllocator> > { }; 1739 struct GCInfoTrait<HeapVector<T, inlineCapacity> > : public GCInfoTrait<Vector<T , inlineCapacity, HeapAllocator> > { };
1717 1740
1718 template<typename T> 1741 template<typename T>
1719 struct IfWeakMember; 1742 struct IfWeakMember;
1720 1743
(...skipping 13 matching lines...) Expand all
1734 // to export. This forces it to export all the methods from ThreadHeap. 1757 // to export. This forces it to export all the methods from ThreadHeap.
1735 template<> void ThreadHeap<FinalizedHeapObjectHeader>::addPageToHeap(const GCInf o*); 1758 template<> void ThreadHeap<FinalizedHeapObjectHeader>::addPageToHeap(const GCInf o*);
1736 template<> void ThreadHeap<HeapObjectHeader>::addPageToHeap(const GCInfo*); 1759 template<> void ThreadHeap<HeapObjectHeader>::addPageToHeap(const GCInfo*);
1737 extern template class HEAP_EXPORT ThreadHeap<FinalizedHeapObjectHeader>; 1760 extern template class HEAP_EXPORT ThreadHeap<FinalizedHeapObjectHeader>;
1738 extern template class HEAP_EXPORT ThreadHeap<HeapObjectHeader>; 1761 extern template class HEAP_EXPORT ThreadHeap<HeapObjectHeader>;
1739 #endif 1762 #endif
1740 1763
1741 } 1764 }
1742 1765
1743 #endif // Heap_h 1766 #endif // Heap_h
OLDNEW
« no previous file with comments | « Source/heap/Handle.h ('k') | Source/heap/HeapTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698