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

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

Issue 1330593002: Clean up round and align in PartitionAlloc (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@cleanup-partalloc
Patch Set: Address review issues Created 5 years, 3 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
« no previous file with comments | « no previous file | Source/wtf/PartitionAlloc.cpp » ('j') | 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 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 partitionRoundUpToSystemPage(size_t size)
730 {
731 return (size + kSystemPageOffsetMask) & kSystemPageBaseMask;
732 }
733
729 ALWAYS_INLINE size_t partitionDirectMapSize(size_t size) 734 ALWAYS_INLINE size_t partitionDirectMapSize(size_t size)
730 { 735 {
731 // Caller must check that the size is not above the kGenericMaxDirectMapped 736 // Caller must check that the size is not above the kGenericMaxDirectMapped
732 // limit before calling. This also guards against integer overflow in the 737 // limit before calling. This also guards against integer overflow in the
733 // calculation here. 738 // calculation here.
734 ASSERT(size <= kGenericMaxDirectMapped); 739 ASSERT(size <= kGenericMaxDirectMapped);
735 return (size + kSystemPageOffsetMask) & kSystemPageBaseMask; 740 return partitionRoundUpToSystemPage(size);
736 } 741 }
737 742
738 ALWAYS_INLINE size_t partitionAllocActualSize(PartitionRootGeneric* root, size_t size) 743 ALWAYS_INLINE size_t partitionAllocActualSize(PartitionRootGeneric* root, size_t size)
739 { 744 {
740 #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) 745 #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
741 return size; 746 return size;
742 #else 747 #else
743 ASSERT(root->initialized); 748 ASSERT(root->initialized);
744 size = partitionCookieSizeAdjustAdd(size); 749 size = partitionCookieSizeAdjustAdd(size);
745 PartitionBucket* bucket = partitionGenericSizeToBucket(root, size); 750 PartitionBucket* bucket = partitionGenericSizeToBucket(root, size);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 using WTF::partitionAlloc; 816 using WTF::partitionAlloc;
812 using WTF::partitionFree; 817 using WTF::partitionFree;
813 using WTF::partitionAllocGeneric; 818 using WTF::partitionAllocGeneric;
814 using WTF::partitionFreeGeneric; 819 using WTF::partitionFreeGeneric;
815 using WTF::partitionReallocGeneric; 820 using WTF::partitionReallocGeneric;
816 using WTF::partitionAllocActualSize; 821 using WTF::partitionAllocActualSize;
817 using WTF::partitionAllocSupportsGetSize; 822 using WTF::partitionAllocSupportsGetSize;
818 using WTF::partitionAllocGetSize; 823 using WTF::partitionAllocGetSize;
819 824
820 #endif // WTF_PartitionAlloc_h 825 #endif // WTF_PartitionAlloc_h
OLDNEW
« no previous file with comments | « no previous file | Source/wtf/PartitionAlloc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698