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

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

Issue 941073002: Oilpan: improve handling of ASan contiguous container annotations. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Support large page vector backings Created 5 years, 10 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
« no previous file with comments | « no previous file | Source/platform/heap/Heap.cpp » ('j') | Source/platform/heap/Heap.cpp » ('J')
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 20 matching lines...) Expand all
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 #if defined(ADDRESS_SANITIZER)
inferno 2015/02/20 21:07:41 can you remove the if defined here. no need of thi
sof 2015/02/20 21:13:37 I could, but I don't want to incur another #includ
sof 2015/02/21 08:52:34 Done.
42 #include "wtf/ContainerAnnotations.h"
43 #endif
41 #include "wtf/HashCountedSet.h" 44 #include "wtf/HashCountedSet.h"
42 #include "wtf/LinkedHashSet.h" 45 #include "wtf/LinkedHashSet.h"
43 #include "wtf/ListHashSet.h" 46 #include "wtf/ListHashSet.h"
44 #include "wtf/OwnPtr.h" 47 #include "wtf/OwnPtr.h"
45 #include "wtf/PageAllocator.h" 48 #include "wtf/PageAllocator.h"
46 #include "wtf/PassRefPtr.h" 49 #include "wtf/PassRefPtr.h"
47 #include "wtf/ThreadSafeRefCounted.h" 50 #include "wtf/ThreadSafeRefCounted.h"
48 #include <stdint.h> 51 #include <stdint.h>
49 52
50 namespace blink { 53 namespace blink {
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 return sizeof(LargeObjectPage) + paddingSize; 563 return sizeof(LargeObjectPage) + paddingSize;
561 } 564 }
562 virtual bool isLargeObjectPage() override { return true; } 565 virtual bool isLargeObjectPage() override { return true; }
563 566
564 HeapObjectHeader* heapObjectHeader() 567 HeapObjectHeader* heapObjectHeader()
565 { 568 {
566 Address headerAddress = address() + pageHeaderSize(); 569 Address headerAddress = address() + pageHeaderSize();
567 return reinterpret_cast<HeapObjectHeader*>(headerAddress); 570 return reinterpret_cast<HeapObjectHeader*>(headerAddress);
568 } 571 }
569 572
573 #ifdef ANNOTATE_CONTIGUOUS_CONTAINER
574 void setIsVectorBackingPage() { m_isVectorBackingPage = true; }
575 bool isVectorBackingPage() const { return m_isVectorBackingPage; }
576 #endif
577
570 private: 578 private:
571 579
572 size_t m_payloadSize; 580 size_t m_payloadSize;
581 #ifdef ANNOTATE_CONTIGUOUS_CONTAINER
582 bool m_isVectorBackingPage;
583 #endif
573 }; 584 };
574 585
575 // A HeapDoesNotContainCache provides a fast way of taking an arbitrary 586 // A HeapDoesNotContainCache provides a fast way of taking an arbitrary
576 // pointer-sized word, and determining whether it cannot be interpreted as a 587 // 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 588 // 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 589 // 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 590 // 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 591 // 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 592 // 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 593 // 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
2133 // payloadSize call below, since there is nowhere to store the 2144 // payloadSize call below, since there is nowhere to store the
2134 // originally allocated memory. This assert ensures that visiting the 2145 // originally allocated memory. This assert ensures that visiting the
2135 // last bit of memory can't cause trouble. 2146 // 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"); 2147 static_assert(!ShouldBeTraced<Traits>::value || sizeof(T) > blink::alloc ationGranularity || Traits::canInitializeWithMemset, "heap overallocation can ca use spurious visits");
2137 2148
2138 T* array = reinterpret_cast<T*>(self); 2149 T* array = reinterpret_cast<T*>(self);
2139 blink::HeapObjectHeader* header = blink::HeapObjectHeader::fromPayload(s elf); 2150 blink::HeapObjectHeader* header = blink::HeapObjectHeader::fromPayload(s elf);
2140 // Use the payload size as recorded by the heap to determine how many 2151 // Use the payload size as recorded by the heap to determine how many
2141 // elements to mark. 2152 // elements to mark.
2142 size_t length = header->payloadSize() / sizeof(T); 2153 size_t length = header->payloadSize() / sizeof(T);
2154 #ifdef ANNOTATE_CONTIGUOUS_CONTAINER
2155 // Have no option but to mark the whole container as accessible, but
2156 // this trace() is only used for backing stores that are identified
2157 // as roots independent from a vector.
2158 ANNOTATE_CHANGE_SIZE(array, length, 0, length);
2159 #endif
2143 for (size_t i = 0; i < length; ++i) 2160 for (size_t i = 0; i < length; ++i)
2144 blink::CollectionBackingTraceTrait<ShouldBeTraced<Traits>::value, Tr aits::weakHandlingFlag, WeakPointersActStrong, T, Traits>::trace(visitor, array[ i]); 2161 blink::CollectionBackingTraceTrait<ShouldBeTraced<Traits>::value, Tr aits::weakHandlingFlag, WeakPointersActStrong, T, Traits>::trace(visitor, array[ i]);
2145 return false; 2162 return false;
2146 } 2163 }
2147 }; 2164 };
2148 2165
2149 // Almost all hash table backings are visited with this specialization. 2166 // Almost all hash table backings are visited with this specialization.
2150 template<ShouldWeakPointersBeMarkedStrongly strongify, typename Table> 2167 template<ShouldWeakPointersBeMarkedStrongly strongify, typename Table>
2151 struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, blink::Hea pHashTableBacking<Table>, void> { 2168 struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, blink::Hea pHashTableBacking<Table>, void> {
2152 using Value = typename Table::ValueType; 2169 using Value = typename Table::ValueType;
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
2442 template<typename T, size_t inlineCapacity> 2459 template<typename T, size_t inlineCapacity>
2443 struct GCInfoTrait<HeapVector<T, inlineCapacity>> : public GCInfoTrait<Vector<T, inlineCapacity, HeapAllocator>> { }; 2460 struct GCInfoTrait<HeapVector<T, inlineCapacity>> : public GCInfoTrait<Vector<T, inlineCapacity, HeapAllocator>> { };
2444 template<typename T, size_t inlineCapacity> 2461 template<typename T, size_t inlineCapacity>
2445 struct GCInfoTrait<HeapDeque<T, inlineCapacity>> : public GCInfoTrait<Deque<T, i nlineCapacity, HeapAllocator>> { }; 2462 struct GCInfoTrait<HeapDeque<T, inlineCapacity>> : public GCInfoTrait<Deque<T, i nlineCapacity, HeapAllocator>> { };
2446 template<typename T, typename U, typename V> 2463 template<typename T, typename U, typename V>
2447 struct GCInfoTrait<HeapHashCountedSet<T, U, V>> : public GCInfoTrait<HashCounted Set<T, U, V, HeapAllocator>> { }; 2464 struct GCInfoTrait<HeapHashCountedSet<T, U, V>> : public GCInfoTrait<HashCounted Set<T, U, V, HeapAllocator>> { };
2448 2465
2449 } // namespace blink 2466 } // namespace blink
2450 2467
2451 #endif // Heap_h 2468 #endif // Heap_h
OLDNEW
« no previous file with comments | « no previous file | Source/platform/heap/Heap.cpp » ('j') | Source/platform/heap/Heap.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698