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 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
558 | 558 |
559 ptr = partitionCookieFreePointerAdjust(ptr); | 559 ptr = partitionCookieFreePointerAdjust(ptr); |
560 ASSERT(partitionPointerIsValid(ptr)); | 560 ASSERT(partitionPointerIsValid(ptr)); |
561 PartitionPage* page = partitionPointerToPage(ptr); | 561 PartitionPage* page = partitionPointerToPage(ptr); |
562 spinLockLock(&root->lock); | 562 spinLockLock(&root->lock); |
563 partitionFreeWithPage(ptr, page); | 563 partitionFreeWithPage(ptr, page); |
564 spinLockUnlock(&root->lock); | 564 spinLockUnlock(&root->lock); |
565 #endif | 565 #endif |
566 } | 566 } |
567 | 567 |
568 ALWAYS_INLINE size_t partitionDirectMapSize(size_t size) | |
569 { | |
Chris Evans
2014/02/21 22:33:37
Can we have a comment such as "caller must handle
Jens Widell
2014/02/22 09:23:30
Assuming (which I hear is a good idea in general)
| |
570 return (size + kSystemPageOffsetMask) & kSystemPageBaseMask; | |
571 } | |
572 | |
573 ALWAYS_INLINE size_t partitionAllocPredictSize(PartitionRootGeneric* root, size_ t size) | |
Chris Evans
2014/02/21 22:33:37
I think we're doing a more accurate job than predi
Jens Widell
2014/02/22 09:23:30
Renamed it.
| |
574 { | |
575 #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) | |
576 return size; | |
577 #else | |
578 ASSERT(root->initialized); | |
579 size = partitionCookieSizeAdjustAdd(size); | |
580 PartitionBucket* bucket = partitionGenericSizeToBucket(root, size); | |
581 if (LIKELY(bucket->numSystemPagesPerSlotSpan)) { | |
Chris Evans
2014/02/21 22:33:37
Can we make this into a small function? This check
Chris Evans
2014/02/21 22:33:37
Can we abstract this to a simple function, partiti
Jens Widell
2014/02/22 09:23:30
Added such a helper. Also made a constant out of "
| |
582 size = bucket->slotSize; | |
583 } else { | |
584 ASSERT(bucket == &PartitionRootGeneric::gPagedBucket); | |
585 if (size > INT_MAX - kSystemPageSize) { | |
586 // Too large to allocate => return the size unchanged. | |
587 } else { | |
588 size = partitionDirectMapSize(size); | |
589 } | |
590 } | |
591 return partitionCookieSizeAdjustSubtract(size); | |
592 #endif | |
593 } | |
594 | |
568 ALWAYS_INLINE bool partitionAllocSupportsGetSize() | 595 ALWAYS_INLINE bool partitionAllocSupportsGetSize() |
569 { | 596 { |
570 #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) | 597 #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) |
571 return false; | 598 return false; |
572 #else | 599 #else |
573 return true; | 600 return true; |
574 #endif | 601 #endif |
575 } | 602 } |
576 | 603 |
577 ALWAYS_INLINE size_t partitionAllocGetSize(void* ptr) | 604 ALWAYS_INLINE size_t partitionAllocGetSize(void* ptr) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
616 using WTF::SizeSpecificPartitionAllocator; | 643 using WTF::SizeSpecificPartitionAllocator; |
617 using WTF::PartitionAllocatorGeneric; | 644 using WTF::PartitionAllocatorGeneric; |
618 using WTF::PartitionRoot; | 645 using WTF::PartitionRoot; |
619 using WTF::partitionAllocInit; | 646 using WTF::partitionAllocInit; |
620 using WTF::partitionAllocShutdown; | 647 using WTF::partitionAllocShutdown; |
621 using WTF::partitionAlloc; | 648 using WTF::partitionAlloc; |
622 using WTF::partitionFree; | 649 using WTF::partitionFree; |
623 using WTF::partitionAllocGeneric; | 650 using WTF::partitionAllocGeneric; |
624 using WTF::partitionFreeGeneric; | 651 using WTF::partitionFreeGeneric; |
625 using WTF::partitionReallocGeneric; | 652 using WTF::partitionReallocGeneric; |
653 using WTF::partitionAllocPredictSize; | |
626 using WTF::partitionAllocSupportsGetSize; | 654 using WTF::partitionAllocSupportsGetSize; |
627 using WTF::partitionAllocGetSize; | 655 using WTF::partitionAllocGetSize; |
628 | 656 |
629 #endif // WTF_PartitionAlloc_h | 657 #endif // WTF_PartitionAlloc_h |
OLD | NEW |