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 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 660 } | 660 } |
| 661 | 661 |
| 662 // N (or more accurately, N - sizeof(void*)) represents the largest size in | 662 // N (or more accurately, N - sizeof(void*)) represents the largest size in |
| 663 // bytes that will be handled by a SizeSpecificPartitionAllocator. | 663 // bytes that will be handled by a SizeSpecificPartitionAllocator. |
| 664 // Attempts to partitionAlloc() more than this amount will fail. | 664 // Attempts to partitionAlloc() more than this amount will fail. |
| 665 template <size_t N> | 665 template <size_t N> |
| 666 class SizeSpecificPartitionAllocator { | 666 class SizeSpecificPartitionAllocator { |
| 667 public: | 667 public: |
| 668 static const size_t kMaxAllocation = N - kAllocationGranularity; | 668 static const size_t kMaxAllocation = N - kAllocationGranularity; |
| 669 static const size_t kNumBuckets = N / kAllocationGranularity; | 669 static const size_t kNumBuckets = N / kAllocationGranularity; |
| 670 void init() { partitionAllocInit(&m_partitionRoot, kNumBuckets, kMaxAllocati on); } | 670 void init() |
| 671 { | |
| 672 partitionAllocInit(&m_partitionRoot, kNumBuckets, kMaxAllocation); | |
|
Chris Evans
2015/04/07 00:50:36
Nit: we no longer need this whitespace-only chance
| |
| 673 } | |
| 671 bool shutdown() { return partitionAllocShutdown(&m_partitionRoot); } | 674 bool shutdown() { return partitionAllocShutdown(&m_partitionRoot); } |
| 672 ALWAYS_INLINE PartitionRoot* root() { return &m_partitionRoot; } | 675 ALWAYS_INLINE PartitionRoot* root() { return &m_partitionRoot; } |
| 673 private: | 676 private: |
| 674 PartitionRoot m_partitionRoot; | 677 PartitionRoot m_partitionRoot; |
| 675 PartitionBucket m_actualBuckets[kNumBuckets]; | 678 PartitionBucket m_actualBuckets[kNumBuckets]; |
| 676 }; | 679 }; |
| 677 | 680 |
| 678 class PartitionAllocatorGeneric { | 681 class PartitionAllocatorGeneric { |
| 679 public: | 682 public: |
| 680 void init() { partitionAllocGenericInit(&m_partitionRoot); } | 683 void init() |
| 684 { | |
| 685 partitionAllocGenericInit(&m_partitionRoot); | |
|
Chris Evans
2015/04/07 00:50:36
Same nit.
| |
| 686 } | |
| 681 bool shutdown() { return partitionAllocGenericShutdown(&m_partitionRoot); } | 687 bool shutdown() { return partitionAllocGenericShutdown(&m_partitionRoot); } |
| 682 ALWAYS_INLINE PartitionRootGeneric* root() { return &m_partitionRoot; } | 688 ALWAYS_INLINE PartitionRootGeneric* root() { return &m_partitionRoot; } |
| 683 private: | 689 private: |
| 684 PartitionRootGeneric m_partitionRoot; | 690 PartitionRootGeneric m_partitionRoot; |
| 685 }; | 691 }; |
| 686 | 692 |
| 687 } // namespace WTF | 693 } // namespace WTF |
| 688 | 694 |
| 689 using WTF::SizeSpecificPartitionAllocator; | 695 using WTF::SizeSpecificPartitionAllocator; |
| 690 using WTF::PartitionAllocatorGeneric; | 696 using WTF::PartitionAllocatorGeneric; |
| 691 using WTF::PartitionRoot; | 697 using WTF::PartitionRoot; |
| 692 using WTF::partitionAllocInit; | 698 using WTF::partitionAllocInit; |
| 693 using WTF::partitionAllocShutdown; | 699 using WTF::partitionAllocShutdown; |
| 694 using WTF::partitionAlloc; | 700 using WTF::partitionAlloc; |
| 695 using WTF::partitionFree; | 701 using WTF::partitionFree; |
| 696 using WTF::partitionAllocGeneric; | 702 using WTF::partitionAllocGeneric; |
| 697 using WTF::partitionFreeGeneric; | 703 using WTF::partitionFreeGeneric; |
| 698 using WTF::partitionReallocGeneric; | 704 using WTF::partitionReallocGeneric; |
| 699 using WTF::partitionAllocActualSize; | 705 using WTF::partitionAllocActualSize; |
| 700 using WTF::partitionAllocSupportsGetSize; | 706 using WTF::partitionAllocSupportsGetSize; |
| 701 using WTF::partitionAllocGetSize; | 707 using WTF::partitionAllocGetSize; |
| 702 | 708 |
| 703 #endif // WTF_PartitionAlloc_h | 709 #endif // WTF_PartitionAlloc_h |
| OLD | NEW |