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

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

Issue 1088973006: Oilpan: Correct static_asserts about VectorTraits::canInitializeWithMemset (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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/core/html/canvas/WebGLVertexArrayObjectOES.h ('k') | no next file » | 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 1904 matching lines...) Expand 10 before | Expand all | Expand 10 after
1915 return Traits::traceInCollection(visitor, t, strongify); 1915 return Traits::traceInCollection(visitor, t, strongify);
1916 } 1916 }
1917 }; 1917 };
1918 1918
1919 // Vector backing that needs marking. We don't support weak members in vectors. 1919 // Vector backing that needs marking. We don't support weak members in vectors.
1920 template<ShouldWeakPointersBeMarkedStrongly strongify, typename T, typename Trai ts> 1920 template<ShouldWeakPointersBeMarkedStrongly strongify, typename T, typename Trai ts>
1921 struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, blink::Hea pVectorBacking<T, Traits>, void> { 1921 struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, blink::Hea pVectorBacking<T, Traits>, void> {
1922 template<typename VisitorDispatcher> 1922 template<typename VisitorDispatcher>
1923 static bool trace(VisitorDispatcher visitor, void* self) 1923 static bool trace(VisitorDispatcher visitor, void* self)
1924 { 1924 {
1925 // The allocator can oversize the allocation a little, according to 1925 static_assert(!ShouldBeTraced<Traits>::value || Traits::canInitializeWit hMemset, "HeapVector doesn't support objects that cannot be initialized with mem set.");
1926 // the allocation granularity. The extra size is included in the
1927 // payloadSize call below, since there is nowhere to store the
1928 // originally allocated memory. This assert ensures that visiting the
1929 // last bit of memory can't cause trouble.
1930 static_assert(!ShouldBeTraced<Traits>::value || sizeof(T) > blink::alloc ationGranularity || Traits::canInitializeWithMemset, "heap overallocation can ca use spurious visits");
1931 1926
1932 T* array = reinterpret_cast<T*>(self); 1927 T* array = reinterpret_cast<T*>(self);
1933 blink::HeapObjectHeader* header = blink::HeapObjectHeader::fromPayload(s elf); 1928 blink::HeapObjectHeader* header = blink::HeapObjectHeader::fromPayload(s elf);
1934 // Use the payload size as recorded by the heap to determine how many 1929 // Use the payload size as recorded by the heap to determine how many
1935 // elements to mark. 1930 // elements to mark.
1936 size_t length = header->payloadSize() / sizeof(T); 1931 size_t length = header->payloadSize() / sizeof(T);
1937 #ifdef ANNOTATE_CONTIGUOUS_CONTAINER 1932 #ifdef ANNOTATE_CONTIGUOUS_CONTAINER
1938 // Have no option but to mark the whole container as accessible, but 1933 // Have no option but to mark the whole container as accessible, but
1939 // this trace() is only used for backing stores that are identified 1934 // this trace() is only used for backing stores that are identified
1940 // as roots independent from a vector. 1935 // as roots independent from a vector.
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
2211 { 2206 {
2212 #if ENABLE(ASSERT) 2207 #if ENABLE(ASSERT)
2213 assertObjectHasGCInfo(const_cast<Backing*>(backing), GCInfoTrait<Backing >::index()); 2208 assertObjectHasGCInfo(const_cast<Backing*>(backing), GCInfoTrait<Backing >::index());
2214 #endif 2209 #endif
2215 } 2210 }
2216 }; 2211 };
2217 2212
2218 template<typename T, typename Traits> 2213 template<typename T, typename Traits>
2219 void HeapVectorBacking<T, Traits>::finalize(void* pointer) 2214 void HeapVectorBacking<T, Traits>::finalize(void* pointer)
2220 { 2215 {
2216 static_assert(Traits::needsDestruction, "HeapVectors that don't require dest ructors should not reach here.");
sof 2015/04/24 12:26:09 "Only vector buffers with items requiring destruct
2217 static_assert(Traits::canInitializeWithMemset, "HeapVector doesn't support o bjects that cannot be initialized with memset.");
2218
2221 ASSERT(!WTF::IsTriviallyDestructible<T>::value); 2219 ASSERT(!WTF::IsTriviallyDestructible<T>::value);
2222 HeapObjectHeader* header = HeapObjectHeader::fromPayload(pointer); 2220 HeapObjectHeader* header = HeapObjectHeader::fromPayload(pointer);
2223 // Use the payload size as recorded by the heap to determine how many 2221 // Use the payload size as recorded by the heap to determine how many
2224 // elements to finalize. 2222 // elements to finalize.
2225 size_t length = header->payloadSize() / sizeof(T); 2223 size_t length = header->payloadSize() / sizeof(T);
2226 T* array = reinterpret_cast<T*>(pointer); 2224 T* array = reinterpret_cast<T*>(pointer);
2227 for (unsigned i = 0; i < length; ++i) { 2225 for (unsigned i = 0; i < length; ++i) {
2228 array[i].~T(); 2226 array[i].~T();
2229 } 2227 }
2230 } 2228 }
(...skipping 10 matching lines...) Expand all
2241 Value* table = reinterpret_cast<Value*>(pointer); 2239 Value* table = reinterpret_cast<Value*>(pointer);
2242 for (unsigned i = 0; i < length; ++i) { 2240 for (unsigned i = 0; i < length; ++i) {
2243 if (!Table::isEmptyOrDeletedBucket(table[i])) 2241 if (!Table::isEmptyOrDeletedBucket(table[i]))
2244 table[i].~Value(); 2242 table[i].~Value();
2245 } 2243 }
2246 } 2244 }
2247 2245
2248 } // namespace blink 2246 } // namespace blink
2249 2247
2250 #endif // Heap_h 2248 #endif // Heap_h
OLDNEW
« no previous file with comments | « Source/core/html/canvas/WebGLVertexArrayObjectOES.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698