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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 uintptr_t invertedSelf; | 309 uintptr_t invertedSelf; |
310 | 310 |
311 static int gInitializedLock; | 311 static int gInitializedLock; |
312 static bool gInitialized; | 312 static bool gInitialized; |
313 // gSeedPage is used as a sentinel to indicate that there is no page | 313 // gSeedPage is used as a sentinel to indicate that there is no page |
314 // in the active page list. We can use nullptr, but in that case we need | 314 // in the active page list. We can use nullptr, but in that case we need |
315 // to add a null-check branch to the hot allocation path. We want to avoid | 315 // to add a null-check branch to the hot allocation path. We want to avoid |
316 // that. | 316 // that. |
317 static PartitionPage gSeedPage; | 317 static PartitionPage gSeedPage; |
318 static PartitionBucket gPagedBucket; | 318 static PartitionBucket gPagedBucket; |
| 319 // gOomHandlingFunction is invoked when ParitionAlloc hits OutOfMemory. |
| 320 static void (*gOomHandlingFunction)(); |
319 }; | 321 }; |
320 | 322 |
321 // Never instantiate a PartitionRoot directly, instead use PartitionAlloc. | 323 // Never instantiate a PartitionRoot directly, instead use PartitionAlloc. |
322 struct PartitionRoot : public PartitionRootBase { | 324 struct PartitionRoot : public PartitionRootBase { |
323 // The PartitionAlloc templated class ensures the following is correct. | 325 // The PartitionAlloc templated class ensures the following is correct. |
324 ALWAYS_INLINE PartitionBucket* buckets() { return reinterpret_cast<Partition
Bucket*>(this + 1); } | 326 ALWAYS_INLINE PartitionBucket* buckets() { return reinterpret_cast<Partition
Bucket*>(this + 1); } |
325 ALWAYS_INLINE const PartitionBucket* buckets() const { return reinterpret_ca
st<const PartitionBucket*>(this + 1); } | 327 ALWAYS_INLINE const PartitionBucket* buckets() const { return reinterpret_ca
st<const PartitionBucket*>(this + 1); } |
326 }; | 328 }; |
327 | 329 |
328 // Never instantiate a PartitionRootGeneric directly, instead use PartitionAlloc
atorGeneric. | 330 // Never instantiate a PartitionRootGeneric directly, instead use PartitionAlloc
atorGeneric. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 // partitionDumpStatsGeneric for using the memory statistics. | 378 // partitionDumpStatsGeneric for using the memory statistics. |
377 class WTF_EXPORT PartitionStatsDumper { | 379 class WTF_EXPORT PartitionStatsDumper { |
378 public: | 380 public: |
379 // Called to dump total memory used by partition, once per partition. | 381 // Called to dump total memory used by partition, once per partition. |
380 virtual void partitionDumpTotals(const char* partitionName, const PartitionM
emoryStats*) = 0; | 382 virtual void partitionDumpTotals(const char* partitionName, const PartitionM
emoryStats*) = 0; |
381 | 383 |
382 // Called to dump stats about buckets, for each bucket. | 384 // Called to dump stats about buckets, for each bucket. |
383 virtual void partitionsDumpBucketStats(const char* partitionName, const Part
itionBucketMemoryStats*) = 0; | 385 virtual void partitionsDumpBucketStats(const char* partitionName, const Part
itionBucketMemoryStats*) = 0; |
384 }; | 386 }; |
385 | 387 |
| 388 WTF_EXPORT void partitionAllocGlobalInit(void (*oomHandlingFunction)()); |
386 WTF_EXPORT void partitionAllocInit(PartitionRoot*, size_t numBuckets, size_t max
Allocation); | 389 WTF_EXPORT void partitionAllocInit(PartitionRoot*, size_t numBuckets, size_t max
Allocation); |
387 WTF_EXPORT bool partitionAllocShutdown(PartitionRoot*); | 390 WTF_EXPORT bool partitionAllocShutdown(PartitionRoot*); |
388 WTF_EXPORT void partitionAllocGenericInit(PartitionRootGeneric*); | 391 WTF_EXPORT void partitionAllocGenericInit(PartitionRootGeneric*); |
389 WTF_EXPORT bool partitionAllocGenericShutdown(PartitionRootGeneric*); | 392 WTF_EXPORT bool partitionAllocGenericShutdown(PartitionRootGeneric*); |
390 | 393 |
391 enum PartitionPurgeFlags { | 394 enum PartitionPurgeFlags { |
392 // Decommitting the ring list of empty pages is reasonably fast. | 395 // Decommitting the ring list of empty pages is reasonably fast. |
393 PartitionPurgeDecommitEmptyPages = 1 << 0, | 396 PartitionPurgeDecommitEmptyPages = 1 << 0, |
394 // Discarding unused system pages is slower, because it involves walking all | 397 // Discarding unused system pages is slower, because it involves walking all |
395 // freelists in all active partition pages of all buckets >= system page | 398 // freelists in all active partition pages of all buckets >= system page |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 using WTF::partitionAlloc; | 814 using WTF::partitionAlloc; |
812 using WTF::partitionFree; | 815 using WTF::partitionFree; |
813 using WTF::partitionAllocGeneric; | 816 using WTF::partitionAllocGeneric; |
814 using WTF::partitionFreeGeneric; | 817 using WTF::partitionFreeGeneric; |
815 using WTF::partitionReallocGeneric; | 818 using WTF::partitionReallocGeneric; |
816 using WTF::partitionAllocActualSize; | 819 using WTF::partitionAllocActualSize; |
817 using WTF::partitionAllocSupportsGetSize; | 820 using WTF::partitionAllocSupportsGetSize; |
818 using WTF::partitionAllocGetSize; | 821 using WTF::partitionAllocGetSize; |
819 | 822 |
820 #endif // WTF_PartitionAlloc_h | 823 #endif // WTF_PartitionAlloc_h |
OLD | NEW |