| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/heap/HeapAllocator.h" | 5 #include "platform/heap/HeapAllocator.h" |
| 6 | 6 |
| 7 namespace blink { | 7 namespace blink { |
| 8 | 8 |
| 9 void HeapAllocator::backingFree(void* address) | 9 void HeapAllocator::backingFree(void* address) |
| 10 { | 10 { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 bool HeapAllocator::backingExpand(void* address, size_t newSize) | 47 bool HeapAllocator::backingExpand(void* address, size_t newSize) |
| 48 { | 48 { |
| 49 if (!address) | 49 if (!address) |
| 50 return false; | 50 return false; |
| 51 | 51 |
| 52 ThreadState* state = ThreadState::current(); | 52 ThreadState* state = ThreadState::current(); |
| 53 if (state->sweepForbidden()) | 53 if (state->sweepForbidden()) |
| 54 return false; | 54 return false; |
| 55 ASSERT(!state->isInGC()); | 55 ASSERT(!state->isInGC()); |
| 56 ASSERT(state->isAllocationAllowed()); | 56 ASSERT(state->isAllocationAllowed()); |
| 57 DCHECK_EQ(&state->heap(), &ThreadState::fromObject(address)->heap()); |
| 57 | 58 |
| 58 // FIXME: Support expand for large objects. | 59 // FIXME: Support expand for large objects. |
| 59 // Don't expand backings allocated on other threads. | 60 // Don't expand backings allocated on other threads. |
| 60 BasePage* page = pageFromObject(address); | 61 BasePage* page = pageFromObject(address); |
| 61 if (page->isLargeObjectPage() || page->arena()->getThreadState() != state) | 62 if (page->isLargeObjectPage() || page->arena()->getThreadState() != state) |
| 62 return false; | 63 return false; |
| 63 | 64 |
| 64 HeapObjectHeader* header = HeapObjectHeader::fromPayload(address); | 65 HeapObjectHeader* header = HeapObjectHeader::fromPayload(address); |
| 65 ASSERT(header->checkHeader()); | 66 ASSERT(header->checkHeader()); |
| 66 NormalPageArena* arena = static_cast<NormalPage*>(page)->arenaForNormalPage(
); | 67 NormalPageArena* arena = static_cast<NormalPage*>(page)->arenaForNormalPage(
); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 90 if (!address || quantizedShrunkSize == quantizedCurrentSize) | 91 if (!address || quantizedShrunkSize == quantizedCurrentSize) |
| 91 return true; | 92 return true; |
| 92 | 93 |
| 93 ASSERT(quantizedShrunkSize < quantizedCurrentSize); | 94 ASSERT(quantizedShrunkSize < quantizedCurrentSize); |
| 94 | 95 |
| 95 ThreadState* state = ThreadState::current(); | 96 ThreadState* state = ThreadState::current(); |
| 96 if (state->sweepForbidden()) | 97 if (state->sweepForbidden()) |
| 97 return false; | 98 return false; |
| 98 ASSERT(!state->isInGC()); | 99 ASSERT(!state->isInGC()); |
| 99 ASSERT(state->isAllocationAllowed()); | 100 ASSERT(state->isAllocationAllowed()); |
| 101 DCHECK_EQ(&state->heap(), &ThreadState::fromObject(address)->heap()); |
| 100 | 102 |
| 101 // FIXME: Support shrink for large objects. | 103 // FIXME: Support shrink for large objects. |
| 102 // Don't shrink backings allocated on other threads. | 104 // Don't shrink backings allocated on other threads. |
| 103 BasePage* page = pageFromObject(address); | 105 BasePage* page = pageFromObject(address); |
| 104 if (page->isLargeObjectPage() || page->arena()->getThreadState() != state) | 106 if (page->isLargeObjectPage() || page->arena()->getThreadState() != state) |
| 105 return false; | 107 return false; |
| 106 | 108 |
| 107 HeapObjectHeader* header = HeapObjectHeader::fromPayload(address); | 109 HeapObjectHeader* header = HeapObjectHeader::fromPayload(address); |
| 108 ASSERT(header->checkHeader()); | 110 ASSERT(header->checkHeader()); |
| 109 NormalPageArena* arena = static_cast<NormalPage*>(page)->arenaForNormalPage(
); | 111 NormalPageArena* arena = static_cast<NormalPage*>(page)->arenaForNormalPage(
); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 123 { | 125 { |
| 124 return backingShrink(address, quantizedCurrentSize, quantizedShrunkSize); | 126 return backingShrink(address, quantizedCurrentSize, quantizedShrunkSize); |
| 125 } | 127 } |
| 126 | 128 |
| 127 bool HeapAllocator::shrinkInlineVectorBacking(void* address, size_t quantizedCur
rentSize, size_t quantizedShrunkSize) | 129 bool HeapAllocator::shrinkInlineVectorBacking(void* address, size_t quantizedCur
rentSize, size_t quantizedShrunkSize) |
| 128 { | 130 { |
| 129 return backingShrink(address, quantizedCurrentSize, quantizedShrunkSize); | 131 return backingShrink(address, quantizedCurrentSize, quantizedShrunkSize); |
| 130 } | 132 } |
| 131 | 133 |
| 132 } // namespace blink | 134 } // namespace blink |
| OLD | NEW |