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

Side by Side Diff: Source/wtf/PartitionAlloc.h

Issue 657113006: Add retry logic to partition alloc (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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
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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 static const size_t kCookieSize = 16; // Handles alignment up to XMM instruction s on Intel. 192 static const size_t kCookieSize = 16; // Handles alignment up to XMM instruction s on Intel.
193 #endif 193 #endif
194 194
195 struct PartitionBucket; 195 struct PartitionBucket;
196 struct PartitionRootBase; 196 struct PartitionRootBase;
197 197
198 struct PartitionFreelistEntry { 198 struct PartitionFreelistEntry {
199 PartitionFreelistEntry* next; 199 PartitionFreelistEntry* next;
200 }; 200 };
201 201
202
Chris Evans 2014/11/06 21:43:51 Nit: looks like a double newline here?
203 typedef void (*PartitionFreeUpMemoryCallback)(void);
204
202 // Some notes on page states. A page can be in one of three major states: 205 // Some notes on page states. A page can be in one of three major states:
203 // 1) Active. 206 // 1) Active.
204 // 2) Full. 207 // 2) Full.
205 // 3) Free. 208 // 3) Free.
206 // An active page has available free slots. A full page has no free slots. A 209 // An active page has available free slots. A full page has no free slots. A
207 // free page has had its backing memory released back to the system. 210 // free page has had its backing memory released back to the system.
208 // There are two linked lists tracking the pages. The "active page" list is an 211 // There are two linked lists tracking the pages. The "active page" list is an
209 // approximation of a list of active pages. It is an approximation because both 212 // approximation of a list of active pages. It is an approximation because both
210 // free and full pages may briefly be present in the list until we next do a 213 // free and full pages may briefly be present in the list until we next do a
211 // scan over it. The "free page" list is an accurate list of pages which have 214 // scan over it. The "free page" list is an accurate list of pages which have
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 // The trailing +1 caters for the overflow case for very large allocation si zes. 288 // The trailing +1 caters for the overflow case for very large allocation si zes.
286 // It is one flat array instead of a 2D array because in the 2D world, we'd 289 // It is one flat array instead of a 2D array because in the 2D world, we'd
287 // need to index array[blah][max+1] which risks undefined behavior. 290 // need to index array[blah][max+1] which risks undefined behavior.
288 PartitionBucket* bucketLookups[((kBitsPerSizet + 1) * kGenericNumBucketsPerO rder) + 1]; 291 PartitionBucket* bucketLookups[((kBitsPerSizet + 1) * kGenericNumBucketsPerO rder) + 1];
289 PartitionBucket buckets[kGenericNumBucketedOrders * kGenericNumBucketsPerOrd er]; 292 PartitionBucket buckets[kGenericNumBucketedOrders * kGenericNumBucketsPerOrd er];
290 }; 293 };
291 294
292 // Flags for partitionAllocGenericFlags. 295 // Flags for partitionAllocGenericFlags.
293 enum PartitionAllocFlags { 296 enum PartitionAllocFlags {
294 PartitionAllocReturnNull = 1 << 0, 297 PartitionAllocReturnNull = 1 << 0,
298 // If you add a flag here, also update PartitionAllocFlagsInternal.
295 }; 299 };
296 300
301 WTF_EXPORT void partitionSetFreeUpMemoryCallback(PartitionFreeUpMemoryCallback);
302
297 WTF_EXPORT void partitionAllocInit(PartitionRoot*, size_t numBuckets, size_t max Allocation); 303 WTF_EXPORT void partitionAllocInit(PartitionRoot*, size_t numBuckets, size_t max Allocation);
298 WTF_EXPORT bool partitionAllocShutdown(PartitionRoot*); 304 WTF_EXPORT bool partitionAllocShutdown(PartitionRoot*);
299 WTF_EXPORT void partitionAllocGenericInit(PartitionRootGeneric*); 305 WTF_EXPORT void partitionAllocGenericInit(PartitionRootGeneric*);
300 WTF_EXPORT bool partitionAllocGenericShutdown(PartitionRootGeneric*); 306 WTF_EXPORT bool partitionAllocGenericShutdown(PartitionRootGeneric*);
301 307
302 WTF_EXPORT NEVER_INLINE void* partitionAllocSlowPath(PartitionRootBase*, int, si ze_t, PartitionBucket*); 308 WTF_EXPORT NEVER_INLINE void* partitionAllocSlowPath(PartitionRootBase*, int, si ze_t, PartitionBucket*);
303 WTF_EXPORT NEVER_INLINE void partitionFreeSlowPath(PartitionPage*); 309 WTF_EXPORT NEVER_INLINE void partitionFreeSlowPath(PartitionPage*);
304 WTF_EXPORT NEVER_INLINE void* partitionReallocGeneric(PartitionRootGeneric*, voi d*, size_t); 310 WTF_EXPORT NEVER_INLINE void* partitionReallocGeneric(PartitionRootGeneric*, voi d*, size_t);
305 311
306 #ifndef NDEBUG 312 #ifndef NDEBUG
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 ALWAYS_INLINE PartitionRootGeneric* root() { return &m_partitionRoot; } 651 ALWAYS_INLINE PartitionRootGeneric* root() { return &m_partitionRoot; }
646 private: 652 private:
647 PartitionRootGeneric m_partitionRoot; 653 PartitionRootGeneric m_partitionRoot;
648 }; 654 };
649 655
650 } // namespace WTF 656 } // namespace WTF
651 657
652 using WTF::SizeSpecificPartitionAllocator; 658 using WTF::SizeSpecificPartitionAllocator;
653 using WTF::PartitionAllocatorGeneric; 659 using WTF::PartitionAllocatorGeneric;
654 using WTF::PartitionRoot; 660 using WTF::PartitionRoot;
661 using WTF::partitionSetFreeUpMemoryCallback;
655 using WTF::partitionAllocInit; 662 using WTF::partitionAllocInit;
656 using WTF::partitionAllocShutdown; 663 using WTF::partitionAllocShutdown;
657 using WTF::partitionAlloc; 664 using WTF::partitionAlloc;
658 using WTF::partitionFree; 665 using WTF::partitionFree;
659 using WTF::partitionAllocGeneric; 666 using WTF::partitionAllocGeneric;
660 using WTF::partitionFreeGeneric; 667 using WTF::partitionFreeGeneric;
661 using WTF::partitionReallocGeneric; 668 using WTF::partitionReallocGeneric;
662 using WTF::partitionAllocActualSize; 669 using WTF::partitionAllocActualSize;
663 using WTF::partitionAllocSupportsGetSize; 670 using WTF::partitionAllocSupportsGetSize;
664 using WTF::partitionAllocGetSize; 671 using WTF::partitionAllocGetSize;
665 672
666 #endif // WTF_PartitionAlloc_h 673 #endif // WTF_PartitionAlloc_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698