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 partitionAllocGetSize(PartitionRootGeneric* root, void* ptr ) | |
569 { | |
570 #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) | |
571 ASSERT_NOT_REACHED(); | |
Chris Evans
2014/02/18 22:19:59
I think this definitely will be reached. We want t
| |
572 #else | |
573 ASSERT(root->initialized); | |
574 if (UNLIKELY(!ptr)) | |
575 return 0; | |
Chris Evans
2014/02/18 22:19:59
For simplicity, maybe try not supporting passing i
| |
576 ptr = partitionCookieFreePointerAdjust(ptr); | |
577 ASSERT(partitionPointerIsValid(ptr)); | |
578 PartitionPage* page = partitionPointerToPage(ptr); | |
579 spinLockLock(&root->lock); | |
Chris Evans
2014/02/18 22:19:59
No need for locking, as covered separately. But de
| |
580 size_t size = page->bucket->slotSize; | |
581 spinLockUnlock(&root->lock); | |
582 return partitionCookieSizeAdjustSubtract(size); | |
583 #endif | |
584 } | |
585 | |
568 // N (or more accurately, N - sizeof(void*)) represents the largest size in | 586 // N (or more accurately, N - sizeof(void*)) represents the largest size in |
569 // bytes that will be handled by a SizeSpecificPartitionAllocator. | 587 // bytes that will be handled by a SizeSpecificPartitionAllocator. |
570 // Attempts to partitionAlloc() more than this amount will fail. | 588 // Attempts to partitionAlloc() more than this amount will fail. |
571 template <size_t N> | 589 template <size_t N> |
572 class SizeSpecificPartitionAllocator { | 590 class SizeSpecificPartitionAllocator { |
573 public: | 591 public: |
574 static const size_t kMaxAllocation = N - kAllocationGranularity; | 592 static const size_t kMaxAllocation = N - kAllocationGranularity; |
575 static const size_t kNumBuckets = N / kAllocationGranularity; | 593 static const size_t kNumBuckets = N / kAllocationGranularity; |
576 void init() { partitionAllocInit(&m_partitionRoot, kNumBuckets, kMaxAllocati on); } | 594 void init() { partitionAllocInit(&m_partitionRoot, kNumBuckets, kMaxAllocati on); } |
577 bool shutdown() { return partitionAllocShutdown(&m_partitionRoot); } | 595 bool shutdown() { return partitionAllocShutdown(&m_partitionRoot); } |
(...skipping 19 matching lines...) Expand all Loading... | |
597 using WTF::PartitionRoot; | 615 using WTF::PartitionRoot; |
598 using WTF::partitionAllocInit; | 616 using WTF::partitionAllocInit; |
599 using WTF::partitionAllocShutdown; | 617 using WTF::partitionAllocShutdown; |
600 using WTF::partitionAlloc; | 618 using WTF::partitionAlloc; |
601 using WTF::partitionFree; | 619 using WTF::partitionFree; |
602 using WTF::partitionAllocGeneric; | 620 using WTF::partitionAllocGeneric; |
603 using WTF::partitionFreeGeneric; | 621 using WTF::partitionFreeGeneric; |
604 using WTF::partitionReallocGeneric; | 622 using WTF::partitionReallocGeneric; |
605 | 623 |
606 #endif // WTF_PartitionAlloc_h | 624 #endif // WTF_PartitionAlloc_h |
OLD | NEW |