OLD | NEW |
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 20 matching lines...) Expand all Loading... |
31 #ifndef Heap_h | 31 #ifndef Heap_h |
32 #define Heap_h | 32 #define Heap_h |
33 | 33 |
34 #include "platform/PlatformExport.h" | 34 #include "platform/PlatformExport.h" |
35 #include "platform/heap/AddressSanitizer.h" | 35 #include "platform/heap/AddressSanitizer.h" |
36 #include "platform/heap/ThreadState.h" | 36 #include "platform/heap/ThreadState.h" |
37 #include "platform/heap/Visitor.h" | 37 #include "platform/heap/Visitor.h" |
38 #include "public/platform/WebThread.h" | 38 #include "public/platform/WebThread.h" |
39 #include "wtf/Assertions.h" | 39 #include "wtf/Assertions.h" |
40 #include "wtf/Atomics.h" | 40 #include "wtf/Atomics.h" |
| 41 #include "wtf/ContainerAnnotations.h" |
41 #include "wtf/HashCountedSet.h" | 42 #include "wtf/HashCountedSet.h" |
42 #include "wtf/LinkedHashSet.h" | 43 #include "wtf/LinkedHashSet.h" |
43 #include "wtf/ListHashSet.h" | 44 #include "wtf/ListHashSet.h" |
44 #include "wtf/OwnPtr.h" | 45 #include "wtf/OwnPtr.h" |
45 #include "wtf/PageAllocator.h" | 46 #include "wtf/PageAllocator.h" |
46 #include "wtf/PassRefPtr.h" | 47 #include "wtf/PassRefPtr.h" |
47 #include "wtf/ThreadSafeRefCounted.h" | 48 #include "wtf/ThreadSafeRefCounted.h" |
48 #include <stdint.h> | 49 #include <stdint.h> |
49 | 50 |
50 namespace blink { | 51 namespace blink { |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 return sizeof(LargeObjectPage) + paddingSize; | 561 return sizeof(LargeObjectPage) + paddingSize; |
561 } | 562 } |
562 virtual bool isLargeObjectPage() override { return true; } | 563 virtual bool isLargeObjectPage() override { return true; } |
563 | 564 |
564 HeapObjectHeader* heapObjectHeader() | 565 HeapObjectHeader* heapObjectHeader() |
565 { | 566 { |
566 Address headerAddress = address() + pageHeaderSize(); | 567 Address headerAddress = address() + pageHeaderSize(); |
567 return reinterpret_cast<HeapObjectHeader*>(headerAddress); | 568 return reinterpret_cast<HeapObjectHeader*>(headerAddress); |
568 } | 569 } |
569 | 570 |
| 571 #ifdef ANNOTATE_CONTIGUOUS_CONTAINER |
| 572 void setIsVectorBackingPage() { m_isVectorBackingPage = true; } |
| 573 bool isVectorBackingPage() const { return m_isVectorBackingPage; } |
| 574 #endif |
| 575 |
570 private: | 576 private: |
571 | 577 |
572 size_t m_payloadSize; | 578 size_t m_payloadSize; |
| 579 #ifdef ANNOTATE_CONTIGUOUS_CONTAINER |
| 580 bool m_isVectorBackingPage; |
| 581 #endif |
573 }; | 582 }; |
574 | 583 |
575 // A HeapDoesNotContainCache provides a fast way of taking an arbitrary | 584 // A HeapDoesNotContainCache provides a fast way of taking an arbitrary |
576 // pointer-sized word, and determining whether it cannot be interpreted as a | 585 // pointer-sized word, and determining whether it cannot be interpreted as a |
577 // pointer to an area that is managed by the garbage collected Blink heap. This | 586 // pointer to an area that is managed by the garbage collected Blink heap. This |
578 // is a cache of 'pages' that have previously been determined to be wholly | 587 // is a cache of 'pages' that have previously been determined to be wholly |
579 // outside of the heap. The size of these pages must be smaller than the | 588 // outside of the heap. The size of these pages must be smaller than the |
580 // allocation alignment of the heap pages. We determine off-heap-ness by | 589 // allocation alignment of the heap pages. We determine off-heap-ness by |
581 // rounding down the pointer to the nearest page and looking up the page in the | 590 // rounding down the pointer to the nearest page and looking up the page in the |
582 // cache. If there is a miss in the cache we can determine the status of the | 591 // cache. If there is a miss in the cache we can determine the status of the |
(...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2133 // payloadSize call below, since there is nowhere to store the | 2142 // payloadSize call below, since there is nowhere to store the |
2134 // originally allocated memory. This assert ensures that visiting the | 2143 // originally allocated memory. This assert ensures that visiting the |
2135 // last bit of memory can't cause trouble. | 2144 // last bit of memory can't cause trouble. |
2136 static_assert(!ShouldBeTraced<Traits>::value || sizeof(T) > blink::alloc
ationGranularity || Traits::canInitializeWithMemset, "heap overallocation can ca
use spurious visits"); | 2145 static_assert(!ShouldBeTraced<Traits>::value || sizeof(T) > blink::alloc
ationGranularity || Traits::canInitializeWithMemset, "heap overallocation can ca
use spurious visits"); |
2137 | 2146 |
2138 T* array = reinterpret_cast<T*>(self); | 2147 T* array = reinterpret_cast<T*>(self); |
2139 blink::HeapObjectHeader* header = blink::HeapObjectHeader::fromPayload(s
elf); | 2148 blink::HeapObjectHeader* header = blink::HeapObjectHeader::fromPayload(s
elf); |
2140 // Use the payload size as recorded by the heap to determine how many | 2149 // Use the payload size as recorded by the heap to determine how many |
2141 // elements to mark. | 2150 // elements to mark. |
2142 size_t length = header->payloadSize() / sizeof(T); | 2151 size_t length = header->payloadSize() / sizeof(T); |
| 2152 #ifdef ANNOTATE_CONTIGUOUS_CONTAINER |
| 2153 // Have no option but to mark the whole container as accessible, but |
| 2154 // this trace() is only used for backing stores that are identified |
| 2155 // as roots independent from a vector. |
| 2156 ANNOTATE_CHANGE_SIZE(array, length, 0, length); |
| 2157 #endif |
2143 for (size_t i = 0; i < length; ++i) | 2158 for (size_t i = 0; i < length; ++i) |
2144 blink::CollectionBackingTraceTrait<ShouldBeTraced<Traits>::value, Tr
aits::weakHandlingFlag, WeakPointersActStrong, T, Traits>::trace(visitor, array[
i]); | 2159 blink::CollectionBackingTraceTrait<ShouldBeTraced<Traits>::value, Tr
aits::weakHandlingFlag, WeakPointersActStrong, T, Traits>::trace(visitor, array[
i]); |
2145 return false; | 2160 return false; |
2146 } | 2161 } |
2147 }; | 2162 }; |
2148 | 2163 |
2149 // Almost all hash table backings are visited with this specialization. | 2164 // Almost all hash table backings are visited with this specialization. |
2150 template<ShouldWeakPointersBeMarkedStrongly strongify, typename Table> | 2165 template<ShouldWeakPointersBeMarkedStrongly strongify, typename Table> |
2151 struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, blink::Hea
pHashTableBacking<Table>, void> { | 2166 struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, blink::Hea
pHashTableBacking<Table>, void> { |
2152 using Value = typename Table::ValueType; | 2167 using Value = typename Table::ValueType; |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2442 template<typename T, size_t inlineCapacity> | 2457 template<typename T, size_t inlineCapacity> |
2443 struct GCInfoTrait<HeapVector<T, inlineCapacity>> : public GCInfoTrait<Vector<T,
inlineCapacity, HeapAllocator>> { }; | 2458 struct GCInfoTrait<HeapVector<T, inlineCapacity>> : public GCInfoTrait<Vector<T,
inlineCapacity, HeapAllocator>> { }; |
2444 template<typename T, size_t inlineCapacity> | 2459 template<typename T, size_t inlineCapacity> |
2445 struct GCInfoTrait<HeapDeque<T, inlineCapacity>> : public GCInfoTrait<Deque<T, i
nlineCapacity, HeapAllocator>> { }; | 2460 struct GCInfoTrait<HeapDeque<T, inlineCapacity>> : public GCInfoTrait<Deque<T, i
nlineCapacity, HeapAllocator>> { }; |
2446 template<typename T, typename U, typename V> | 2461 template<typename T, typename U, typename V> |
2447 struct GCInfoTrait<HeapHashCountedSet<T, U, V>> : public GCInfoTrait<HashCounted
Set<T, U, V, HeapAllocator>> { }; | 2462 struct GCInfoTrait<HeapHashCountedSet<T, U, V>> : public GCInfoTrait<HashCounted
Set<T, U, V, HeapAllocator>> { }; |
2448 | 2463 |
2449 } // namespace blink | 2464 } // namespace blink |
2450 | 2465 |
2451 #endif // Heap_h | 2466 #endif // Heap_h |
OLD | NEW |