Chromium Code Reviews| 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 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 719 | 719 |
| 720 ptr = partitionCookieFreePointerAdjust(ptr); | 720 ptr = partitionCookieFreePointerAdjust(ptr); |
| 721 ASSERT(partitionPointerIsValid(ptr)); | 721 ASSERT(partitionPointerIsValid(ptr)); |
| 722 PartitionPage* page = partitionPointerToPage(ptr); | 722 PartitionPage* page = partitionPointerToPage(ptr); |
| 723 spinLockLock(&root->lock); | 723 spinLockLock(&root->lock); |
| 724 partitionFreeWithPage(ptr, page); | 724 partitionFreeWithPage(ptr, page); |
| 725 spinLockUnlock(&root->lock); | 725 spinLockUnlock(&root->lock); |
| 726 #endif | 726 #endif |
| 727 } | 727 } |
| 728 | 728 |
| 729 ALWAYS_INLINE size_t partitionDirectMapSize(size_t size) | 729 ALWAYS_INLINE size_t partitionRoundUpToSystemPage(size_t size) |
|
Primiano Tucci (use gerrit)
2015/09/03 11:24:53
I think this should stay as it is (as the assert i
Ruud van Asseldonk
2015/09/03 13:44:47
Done.
| |
| 730 { | 730 { |
| 731 // Caller must check that the size is not above the kGenericMaxDirectMapped | 731 // Caller must check that the size is not above the kGenericMaxDirectMapped |
| 732 // limit before calling. This also guards against integer overflow in the | 732 // limit before calling. This also guards against integer overflow in the |
| 733 // calculation here. | 733 // calculation here. |
| 734 ASSERT(size <= kGenericMaxDirectMapped); | 734 ASSERT(size <= kGenericMaxDirectMapped); |
| 735 return (size + kSystemPageOffsetMask) & kSystemPageBaseMask; | 735 return (size + kSystemPageOffsetMask) & kSystemPageBaseMask; |
| 736 } | 736 } |
| 737 | 737 |
| 738 ALWAYS_INLINE size_t partitionAllocActualSize(PartitionRootGeneric* root, size_t size) | 738 ALWAYS_INLINE size_t partitionAllocActualSize(PartitionRootGeneric* root, size_t size) |
| 739 { | 739 { |
| 740 #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) | 740 #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) |
| 741 return size; | 741 return size; |
| 742 #else | 742 #else |
| 743 ASSERT(root->initialized); | 743 ASSERT(root->initialized); |
| 744 size = partitionCookieSizeAdjustAdd(size); | 744 size = partitionCookieSizeAdjustAdd(size); |
| 745 PartitionBucket* bucket = partitionGenericSizeToBucket(root, size); | 745 PartitionBucket* bucket = partitionGenericSizeToBucket(root, size); |
| 746 if (LIKELY(!partitionBucketIsDirectMapped(bucket))) { | 746 if (LIKELY(!partitionBucketIsDirectMapped(bucket))) { |
| 747 size = bucket->slotSize; | 747 size = bucket->slotSize; |
| 748 } else if (size > kGenericMaxDirectMapped) { | 748 } else if (size > kGenericMaxDirectMapped) { |
| 749 // Too large to allocate => return the size unchanged. | 749 // Too large to allocate => return the size unchanged. |
| 750 } else { | 750 } else { |
| 751 ASSERT(bucket == &PartitionRootBase::gPagedBucket); | 751 ASSERT(bucket == &PartitionRootBase::gPagedBucket); |
| 752 size = partitionDirectMapSize(size); | 752 size = partitionRoundUpToSystemPage(size); |
|
Primiano Tucci (use gerrit)
2015/09/03 11:24:53
ditto
| |
| 753 } | 753 } |
| 754 return partitionCookieSizeAdjustSubtract(size); | 754 return partitionCookieSizeAdjustSubtract(size); |
| 755 #endif | 755 #endif |
| 756 } | 756 } |
| 757 | 757 |
| 758 ALWAYS_INLINE bool partitionAllocSupportsGetSize() | 758 ALWAYS_INLINE bool partitionAllocSupportsGetSize() |
| 759 { | 759 { |
| 760 #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) | 760 #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) |
| 761 return false; | 761 return false; |
| 762 #else | 762 #else |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 811 using WTF::partitionAlloc; | 811 using WTF::partitionAlloc; |
| 812 using WTF::partitionFree; | 812 using WTF::partitionFree; |
| 813 using WTF::partitionAllocGeneric; | 813 using WTF::partitionAllocGeneric; |
| 814 using WTF::partitionFreeGeneric; | 814 using WTF::partitionFreeGeneric; |
| 815 using WTF::partitionReallocGeneric; | 815 using WTF::partitionReallocGeneric; |
| 816 using WTF::partitionAllocActualSize; | 816 using WTF::partitionAllocActualSize; |
| 817 using WTF::partitionAllocSupportsGetSize; | 817 using WTF::partitionAllocSupportsGetSize; |
| 818 using WTF::partitionAllocGetSize; | 818 using WTF::partitionAllocGetSize; |
| 819 | 819 |
| 820 #endif // WTF_PartitionAlloc_h | 820 #endif // WTF_PartitionAlloc_h |
| OLD | NEW |