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

Side by Side Diff: third_party/WebKit/Source/platform/heap/HeapAllocator.h

Issue 1411603007: [Oilpan] Add use-after-free detector in Member<> Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef HeapAllocator_h 5 #ifndef HeapAllocator_h
6 #define HeapAllocator_h 6 #define HeapAllocator_h
7 7
8 #include "platform/heap/Heap.h" 8 #include "platform/heap/Heap.h"
9 #include "platform/heap/TraceTraits.h" 9 #include "platform/heap/TraceTraits.h"
10 #include "wtf/Assertions.h" 10 #include "wtf/Assertions.h"
(...skipping 23 matching lines...) Expand all
34 RELEASE_ASSERT(count <= maxHeapObjectSize / sizeof(T)); 34 RELEASE_ASSERT(count <= maxHeapObjectSize / sizeof(T));
35 return Heap::allocationSizeFromSize(count * sizeof(T)) - sizeof(HeapObje ctHeader); 35 return Heap::allocationSizeFromSize(count * sizeof(T)) - sizeof(HeapObje ctHeader);
36 } 36 }
37 template <typename T> 37 template <typename T>
38 static T* allocateVectorBacking(size_t size) 38 static T* allocateVectorBacking(size_t size)
39 { 39 {
40 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state( ); 40 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state( );
41 ASSERT(state->isAllocationAllowed()); 41 ASSERT(state->isAllocationAllowed());
42 size_t gcInfoIndex = GCInfoTrait<HeapVectorBacking<T, VectorTraits<T>>>: :index(); 42 size_t gcInfoIndex = GCInfoTrait<HeapVectorBacking<T, VectorTraits<T>>>: :index();
43 NormalPageHeap* heap = static_cast<NormalPageHeap*>(state->vectorBacking Heap(gcInfoIndex)); 43 NormalPageHeap* heap = static_cast<NormalPageHeap*>(state->vectorBacking Heap(gcInfoIndex));
44 return reinterpret_cast<T*>(heap->allocateObject(Heap::allocationSizeFro mSize(size), gcInfoIndex)); 44 return reinterpret_cast<T*>(heap->allocateObject(Heap::allocationSizeFro mSize(size), gcInfoIndex, Heap::gcGeneration()));
45 } 45 }
46 template <typename T> 46 template <typename T>
47 static T* allocateExpandedVectorBacking(size_t size) 47 static T* allocateExpandedVectorBacking(size_t size)
48 { 48 {
49 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state( ); 49 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state( );
50 ASSERT(state->isAllocationAllowed()); 50 ASSERT(state->isAllocationAllowed());
51 size_t gcInfoIndex = GCInfoTrait<HeapVectorBacking<T, VectorTraits<T>>>: :index(); 51 size_t gcInfoIndex = GCInfoTrait<HeapVectorBacking<T, VectorTraits<T>>>: :index();
52 NormalPageHeap* heap = static_cast<NormalPageHeap*>(state->expandedVecto rBackingHeap(gcInfoIndex)); 52 NormalPageHeap* heap = static_cast<NormalPageHeap*>(state->expandedVecto rBackingHeap(gcInfoIndex));
53 return reinterpret_cast<T*>(heap->allocateObject(Heap::allocationSizeFro mSize(size), gcInfoIndex)); 53 return reinterpret_cast<T*>(heap->allocateObject(Heap::allocationSizeFro mSize(size), gcInfoIndex, Heap::gcGeneration()));
54 } 54 }
55 static void freeVectorBacking(void*); 55 static void freeVectorBacking(void*);
56 static bool expandVectorBacking(void*, size_t); 56 static bool expandVectorBacking(void*, size_t);
57 static bool shrinkVectorBacking(void* address, size_t quantizedCurrentSize, size_t quantizedShrunkSize); 57 static bool shrinkVectorBacking(void* address, size_t quantizedCurrentSize, size_t quantizedShrunkSize);
58 template <typename T> 58 template <typename T>
59 static T* allocateInlineVectorBacking(size_t size) 59 static T* allocateInlineVectorBacking(size_t size)
60 { 60 {
61 size_t gcInfoIndex = GCInfoTrait<HeapVectorBacking<T, VectorTraits<T>>>: :index(); 61 size_t gcInfoIndex = GCInfoTrait<HeapVectorBacking<T, VectorTraits<T>>>: :index();
62 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state( ); 62 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state( );
63 return reinterpret_cast<T*>(Heap::allocateOnHeapIndex(state, size, Blink GC::InlineVectorHeapIndex, gcInfoIndex)); 63 return reinterpret_cast<T*>(Heap::allocateOnHeapIndex(state, size, Blink GC::InlineVectorHeapIndex, gcInfoIndex));
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 template<size_t otherCapacity> 387 template<size_t otherCapacity>
388 HeapDeque(const HeapDeque<T, otherCapacity>& other) 388 HeapDeque(const HeapDeque<T, otherCapacity>& other)
389 : Deque<T, inlineCapacity, HeapAllocator>(other) 389 : Deque<T, inlineCapacity, HeapAllocator>(other)
390 { 390 {
391 } 391 }
392 }; 392 };
393 393
394 } // namespace blink 394 } // namespace blink
395 395
396 #endif 396 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698