| 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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 }; | 368 }; |
| 369 | 369 |
| 370 WTF_EXPORT void partitionAllocInit(PartitionRoot*, size_t numBuckets, size_t max
Allocation); | 370 WTF_EXPORT void partitionAllocInit(PartitionRoot*, size_t numBuckets, size_t max
Allocation); |
| 371 WTF_EXPORT bool partitionAllocShutdown(PartitionRoot*); | 371 WTF_EXPORT bool partitionAllocShutdown(PartitionRoot*); |
| 372 WTF_EXPORT void partitionAllocGenericInit(PartitionRootGeneric*); | 372 WTF_EXPORT void partitionAllocGenericInit(PartitionRootGeneric*); |
| 373 WTF_EXPORT bool partitionAllocGenericShutdown(PartitionRootGeneric*); | 373 WTF_EXPORT bool partitionAllocGenericShutdown(PartitionRootGeneric*); |
| 374 | 374 |
| 375 enum PartitionPurgeFlags { | 375 enum PartitionPurgeFlags { |
| 376 // Decommitting the ring list of empty pages is reasonably fast. | 376 // Decommitting the ring list of empty pages is reasonably fast. |
| 377 PartitionPurgeDecommitEmptyPages = 1 << 0, | 377 PartitionPurgeDecommitEmptyPages = 1 << 0, |
| 378 // Discarding unused system pages is slower, because it involves walking all |
| 379 // freelists in all active partition pages of all buckets >= system page |
| 380 // size. It often frees a similar amount of memory to decommitting the empty |
| 381 // pages, though. |
| 382 PartitionPurgeDiscardUnusedSystemPages = 1 << 1, |
| 378 }; | 383 }; |
| 379 | 384 |
| 380 WTF_EXPORT void partitionPurgeMemory(PartitionRoot*, int); | 385 WTF_EXPORT void partitionPurgeMemory(PartitionRoot*, int); |
| 381 WTF_EXPORT void partitionPurgeMemoryGeneric(PartitionRootGeneric*, int); | 386 WTF_EXPORT void partitionPurgeMemoryGeneric(PartitionRootGeneric*, int); |
| 382 | 387 |
| 383 WTF_EXPORT NEVER_INLINE void* partitionAllocSlowPath(PartitionRootBase*, int, si
ze_t, PartitionBucket*); | 388 WTF_EXPORT NEVER_INLINE void* partitionAllocSlowPath(PartitionRootBase*, int, si
ze_t, PartitionBucket*); |
| 384 WTF_EXPORT NEVER_INLINE void partitionFreeSlowPath(PartitionPage*); | 389 WTF_EXPORT NEVER_INLINE void partitionFreeSlowPath(PartitionPage*); |
| 385 WTF_EXPORT NEVER_INLINE void* partitionReallocGeneric(PartitionRootGeneric*, voi
d*, size_t); | 390 WTF_EXPORT NEVER_INLINE void* partitionReallocGeneric(PartitionRootGeneric*, voi
d*, size_t); |
| 386 | 391 |
| 387 WTF_EXPORT void partitionDumpStats(PartitionRoot*, const char* partitionName, Pa
rtitionStatsDumper*); | 392 WTF_EXPORT void partitionDumpStats(PartitionRoot*, const char* partitionName, Pa
rtitionStatsDumper*); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 // the last index is invalid because it is a guard page. | 475 // the last index is invalid because it is a guard page. |
| 471 ASSERT(partitionPageIndex); | 476 ASSERT(partitionPageIndex); |
| 472 ASSERT(partitionPageIndex < kNumPartitionPagesPerSuperPage - 1); | 477 ASSERT(partitionPageIndex < kNumPartitionPagesPerSuperPage - 1); |
| 473 PartitionPage* page = reinterpret_cast<PartitionPage*>(partitionSuperPageToM
etadataArea(superPagePtr) + (partitionPageIndex << kPageMetadataShift)); | 478 PartitionPage* page = reinterpret_cast<PartitionPage*>(partitionSuperPageToM
etadataArea(superPagePtr) + (partitionPageIndex << kPageMetadataShift)); |
| 474 // Partition pages in the same slot span can share the same page object. Adj
ust for that. | 479 // Partition pages in the same slot span can share the same page object. Adj
ust for that. |
| 475 size_t delta = page->pageOffset << kPageMetadataShift; | 480 size_t delta = page->pageOffset << kPageMetadataShift; |
| 476 page = reinterpret_cast<PartitionPage*>(reinterpret_cast<char*>(page) - delt
a); | 481 page = reinterpret_cast<PartitionPage*>(reinterpret_cast<char*>(page) - delt
a); |
| 477 return page; | 482 return page; |
| 478 } | 483 } |
| 479 | 484 |
| 480 ALWAYS_INLINE void* partitionPageToPointer(PartitionPage* page) | 485 ALWAYS_INLINE void* partitionPageToPointer(const PartitionPage* page) |
| 481 { | 486 { |
| 482 uintptr_t pointerAsUint = reinterpret_cast<uintptr_t>(page); | 487 uintptr_t pointerAsUint = reinterpret_cast<uintptr_t>(page); |
| 483 uintptr_t superPageOffset = (pointerAsUint & kSuperPageOffsetMask); | 488 uintptr_t superPageOffset = (pointerAsUint & kSuperPageOffsetMask); |
| 484 ASSERT(superPageOffset > kSystemPageSize); | 489 ASSERT(superPageOffset > kSystemPageSize); |
| 485 ASSERT(superPageOffset < kSystemPageSize + (kNumPartitionPagesPerSuperPage *
kPageMetadataSize)); | 490 ASSERT(superPageOffset < kSystemPageSize + (kNumPartitionPagesPerSuperPage *
kPageMetadataSize)); |
| 486 uintptr_t partitionPageIndex = (superPageOffset - kSystemPageSize) >> kPageM
etadataShift; | 491 uintptr_t partitionPageIndex = (superPageOffset - kSystemPageSize) >> kPageM
etadataShift; |
| 487 // Index 0 is invalid because it is the metadata area and the last index is
invalid because it is a guard page. | 492 // Index 0 is invalid because it is the metadata area and the last index is
invalid because it is a guard page. |
| 488 ASSERT(partitionPageIndex); | 493 ASSERT(partitionPageIndex); |
| 489 ASSERT(partitionPageIndex < kNumPartitionPagesPerSuperPage - 1); | 494 ASSERT(partitionPageIndex < kNumPartitionPagesPerSuperPage - 1); |
| 490 uintptr_t superPageBase = (pointerAsUint & kSuperPageBaseMask); | 495 uintptr_t superPageBase = (pointerAsUint & kSuperPageBaseMask); |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 using WTF::partitionAlloc; | 789 using WTF::partitionAlloc; |
| 785 using WTF::partitionFree; | 790 using WTF::partitionFree; |
| 786 using WTF::partitionAllocGeneric; | 791 using WTF::partitionAllocGeneric; |
| 787 using WTF::partitionFreeGeneric; | 792 using WTF::partitionFreeGeneric; |
| 788 using WTF::partitionReallocGeneric; | 793 using WTF::partitionReallocGeneric; |
| 789 using WTF::partitionAllocActualSize; | 794 using WTF::partitionAllocActualSize; |
| 790 using WTF::partitionAllocSupportsGetSize; | 795 using WTF::partitionAllocSupportsGetSize; |
| 791 using WTF::partitionAllocGetSize; | 796 using WTF::partitionAllocGetSize; |
| 792 | 797 |
| 793 #endif // WTF_PartitionAlloc_h | 798 #endif // WTF_PartitionAlloc_h |
| OLD | NEW |