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 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 538 if (startOfGap != headerAddress) | 538 if (startOfGap != headerAddress) |
| 539 addToFreeList(startOfGap, headerAddress - startOfGap); | 539 addToFreeList(startOfGap, headerAddress - startOfGap); |
| 540 | 540 |
| 541 headerAddress += size; | 541 headerAddress += size; |
| 542 startOfGap = headerAddress; | 542 startOfGap = headerAddress; |
| 543 } | 543 } |
| 544 | 544 |
| 545 if (startOfGap != page->payloadEnd()) | 545 if (startOfGap != page->payloadEnd()) |
| 546 addToFreeList(startOfGap, page->payloadEnd() - startOfGap); | 546 addToFreeList(startOfGap, page->payloadEnd() - startOfGap); |
| 547 } | 547 } |
| 548 Heap::decreaseAllocatedObjectSize(freedSize); | 548 threadState()->decreaseAllocatedObjectSize(freedSize); |
| 549 ASSERT(m_promptlyFreedSize == freedSize); | 549 ASSERT(m_promptlyFreedSize == freedSize); |
| 550 m_promptlyFreedSize = 0; | 550 m_promptlyFreedSize = 0; |
| 551 return true; | 551 return true; |
| 552 } | 552 } |
| 553 | 553 |
| 554 void NormalPageHeap::promptlyFreeObject(HeapObjectHeader* header) | 554 void NormalPageHeap::promptlyFreeObject(HeapObjectHeader* header) |
| 555 { | 555 { |
| 556 ASSERT(!threadState()->sweepForbidden()); | 556 ASSERT(!threadState()->sweepForbidden()); |
| 557 ASSERT(header->checkHeader()); | 557 ASSERT(header->checkHeader()); |
| 558 Address address = reinterpret_cast<Address>(header); | 558 Address address = reinterpret_cast<Address>(header); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 656 } | 656 } |
| 657 | 657 |
| 658 void NormalPageHeap::setRemainingAllocationSize(size_t newRemainingAllocationSiz e) | 658 void NormalPageHeap::setRemainingAllocationSize(size_t newRemainingAllocationSiz e) |
| 659 { | 659 { |
| 660 m_remainingAllocationSize = newRemainingAllocationSize; | 660 m_remainingAllocationSize = newRemainingAllocationSize; |
| 661 | 661 |
| 662 // Sync recorded allocated-object size: | 662 // Sync recorded allocated-object size: |
| 663 // - if previous alloc checkpoint is larger, allocation size has increased. | 663 // - if previous alloc checkpoint is larger, allocation size has increased. |
| 664 // - if smaller, a net reduction in size since last call to updateRemaining AllocationSize(). | 664 // - if smaller, a net reduction in size since last call to updateRemaining AllocationSize(). |
| 665 if (m_lastRemainingAllocationSize > m_remainingAllocationSize) | 665 if (m_lastRemainingAllocationSize > m_remainingAllocationSize) |
| 666 Heap::increaseAllocatedObjectSize(m_lastRemainingAllocationSize - m_rema iningAllocationSize); | 666 threadState()->increaseAllocatedObjectSize(m_lastRemainingAllocationSize - m_remainingAllocationSize); |
| 667 else if (m_lastRemainingAllocationSize != m_remainingAllocationSize) | 667 else if (m_lastRemainingAllocationSize != m_remainingAllocationSize) |
| 668 Heap::decreaseAllocatedObjectSize(m_remainingAllocationSize - m_lastRema iningAllocationSize); | 668 threadState()->decreaseAllocatedObjectSize(m_remainingAllocationSize - m _lastRemainingAllocationSize); |
| 669 m_lastRemainingAllocationSize = m_remainingAllocationSize; | 669 m_lastRemainingAllocationSize = m_remainingAllocationSize; |
| 670 } | 670 } |
| 671 | 671 |
| 672 void NormalPageHeap::updateRemainingAllocationSize() | 672 void NormalPageHeap::updateRemainingAllocationSize() |
| 673 { | 673 { |
| 674 if (m_lastRemainingAllocationSize > remainingAllocationSize()) { | 674 if (m_lastRemainingAllocationSize > remainingAllocationSize()) { |
| 675 Heap::increaseAllocatedObjectSize(m_lastRemainingAllocationSize - remain ingAllocationSize()); | 675 threadState()->increaseAllocatedObjectSize(m_lastRemainingAllocationSize - remainingAllocationSize()); |
| 676 m_lastRemainingAllocationSize = remainingAllocationSize(); | 676 m_lastRemainingAllocationSize = remainingAllocationSize(); |
| 677 } | 677 } |
| 678 ASSERT(m_lastRemainingAllocationSize == remainingAllocationSize()); | 678 ASSERT(m_lastRemainingAllocationSize == remainingAllocationSize()); |
| 679 } | 679 } |
| 680 | 680 |
| 681 void NormalPageHeap::setAllocationPoint(Address point, size_t size) | 681 void NormalPageHeap::setAllocationPoint(Address point, size_t size) |
| 682 { | 682 { |
| 683 #if ENABLE(ASSERT) | 683 #if ENABLE(ASSERT) |
| 684 if (point) { | 684 if (point) { |
| 685 ASSERT(size); | 685 ASSERT(size); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 832 LargeObjectPage* largeObject = new (largeObjectAddress) LargeObjectPage(page Memory, this, allocationSize); | 832 LargeObjectPage* largeObject = new (largeObjectAddress) LargeObjectPage(page Memory, this, allocationSize); |
| 833 ASSERT(header->checkHeader()); | 833 ASSERT(header->checkHeader()); |
| 834 | 834 |
| 835 // Poison the object header and allocationGranularity bytes after the object | 835 // Poison the object header and allocationGranularity bytes after the object |
| 836 ASAN_POISON_MEMORY_REGION(header, sizeof(*header)); | 836 ASAN_POISON_MEMORY_REGION(header, sizeof(*header)); |
| 837 ASAN_POISON_MEMORY_REGION(largeObject->address() + largeObject->size(), allo cationGranularity); | 837 ASAN_POISON_MEMORY_REGION(largeObject->address() + largeObject->size(), allo cationGranularity); |
| 838 | 838 |
| 839 largeObject->link(&m_firstPage); | 839 largeObject->link(&m_firstPage); |
| 840 | 840 |
| 841 Heap::increaseAllocatedSpace(largeObject->size()); | 841 Heap::increaseAllocatedSpace(largeObject->size()); |
| 842 Heap::increaseAllocatedObjectSize(largeObject->size()); | 842 threadState()->increaseAllocatedObjectSize(largeObject->size()); |
| 843 return result; | 843 return result; |
| 844 } | 844 } |
| 845 | 845 |
| 846 void LargeObjectHeap::freeLargeObjectPage(LargeObjectPage* object) | 846 void LargeObjectHeap::freeLargeObjectPage(LargeObjectPage* object) |
| 847 { | 847 { |
| 848 ASAN_UNPOISON_MEMORY_REGION(object->payload(), object->payloadSize()); | 848 ASAN_UNPOISON_MEMORY_REGION(object->payload(), object->payloadSize()); |
| 849 object->heapObjectHeader()->finalize(object->payload(), object->payloadSize( )); | 849 object->heapObjectHeader()->finalize(object->payload(), object->payloadSize( )); |
| 850 Heap::decreaseAllocatedSpace(object->size()); | 850 Heap::decreaseAllocatedSpace(object->size()); |
| 851 | 851 |
| 852 // Unpoison the object header and allocationGranularity bytes after the | 852 // Unpoison the object header and allocationGranularity bytes after the |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1150 heapForNormalPage()->addToFreeList(startOfGap, headerAddress - start OfGap); | 1150 heapForNormalPage()->addToFreeList(startOfGap, headerAddress - start OfGap); |
| 1151 header->unmark(); | 1151 header->unmark(); |
| 1152 headerAddress += header->size(); | 1152 headerAddress += header->size(); |
| 1153 markedObjectSize += header->size(); | 1153 markedObjectSize += header->size(); |
| 1154 startOfGap = headerAddress; | 1154 startOfGap = headerAddress; |
| 1155 } | 1155 } |
| 1156 if (startOfGap != payloadEnd()) | 1156 if (startOfGap != payloadEnd()) |
| 1157 heapForNormalPage()->addToFreeList(startOfGap, payloadEnd() - startOfGap ); | 1157 heapForNormalPage()->addToFreeList(startOfGap, payloadEnd() - startOfGap ); |
| 1158 | 1158 |
| 1159 if (markedObjectSize) | 1159 if (markedObjectSize) |
| 1160 Heap::increaseMarkedObjectSize(markedObjectSize); | 1160 ThreadState::current()->increaseMarkedObjectSize(markedObjectSize); |
|
haraken
2016/02/12 09:30:54
heapForNormalPage()->threadState()->
peria
2016/02/15 04:16:59
Done.
| |
| 1161 } | 1161 } |
| 1162 | 1162 |
| 1163 void NormalPage::makeConsistentForGC() | 1163 void NormalPage::makeConsistentForGC() |
| 1164 { | 1164 { |
| 1165 size_t markedObjectSize = 0; | 1165 size_t markedObjectSize = 0; |
| 1166 for (Address headerAddress = payload(); headerAddress < payloadEnd();) { | 1166 for (Address headerAddress = payload(); headerAddress < payloadEnd();) { |
| 1167 HeapObjectHeader* header = reinterpret_cast<HeapObjectHeader*>(headerAdd ress); | 1167 HeapObjectHeader* header = reinterpret_cast<HeapObjectHeader*>(headerAdd ress); |
| 1168 ASSERT(header->size() < blinkPagePayloadSize()); | 1168 ASSERT(header->size() < blinkPagePayloadSize()); |
| 1169 // Check if a free list entry first since we cannot call | 1169 // Check if a free list entry first since we cannot call |
| 1170 // isMarked on a free list entry. | 1170 // isMarked on a free list entry. |
| 1171 if (header->isFree()) { | 1171 if (header->isFree()) { |
| 1172 headerAddress += header->size(); | 1172 headerAddress += header->size(); |
| 1173 continue; | 1173 continue; |
| 1174 } | 1174 } |
| 1175 ASSERT(header->checkHeader()); | 1175 ASSERT(header->checkHeader()); |
| 1176 if (header->isMarked()) { | 1176 if (header->isMarked()) { |
| 1177 header->unmark(); | 1177 header->unmark(); |
| 1178 markedObjectSize += header->size(); | 1178 markedObjectSize += header->size(); |
| 1179 } else { | 1179 } else { |
| 1180 header->markDead(); | 1180 header->markDead(); |
| 1181 } | 1181 } |
| 1182 headerAddress += header->size(); | 1182 headerAddress += header->size(); |
| 1183 } | 1183 } |
| 1184 if (markedObjectSize) | 1184 if (markedObjectSize) |
| 1185 Heap::increaseMarkedObjectSize(markedObjectSize); | 1185 ThreadState::current()->increaseMarkedObjectSize(markedObjectSize); |
|
haraken
2016/02/12 09:30:54
heapForNormalPage()->threadState()->
peria
2016/02/15 04:16:59
Done.
| |
| 1186 } | 1186 } |
| 1187 | 1187 |
| 1188 void NormalPage::makeConsistentForMutator() | 1188 void NormalPage::makeConsistentForMutator() |
| 1189 { | 1189 { |
| 1190 Address startOfGap = payload(); | 1190 Address startOfGap = payload(); |
| 1191 for (Address headerAddress = payload(); headerAddress < payloadEnd();) { | 1191 for (Address headerAddress = payload(); headerAddress < payloadEnd();) { |
| 1192 HeapObjectHeader* header = reinterpret_cast<HeapObjectHeader*>(headerAdd ress); | 1192 HeapObjectHeader* header = reinterpret_cast<HeapObjectHeader*>(headerAdd ress); |
| 1193 size_t size = header->size(); | 1193 size_t size = header->size(); |
| 1194 ASSERT(size < blinkPagePayloadSize()); | 1194 ASSERT(size < blinkPagePayloadSize()); |
| 1195 if (header->isPromptlyFreed()) | 1195 if (header->isPromptlyFreed()) |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1442 } | 1442 } |
| 1443 | 1443 |
| 1444 void LargeObjectPage::removeFromHeap() | 1444 void LargeObjectPage::removeFromHeap() |
| 1445 { | 1445 { |
| 1446 static_cast<LargeObjectHeap*>(heap())->freeLargeObjectPage(this); | 1446 static_cast<LargeObjectHeap*>(heap())->freeLargeObjectPage(this); |
| 1447 } | 1447 } |
| 1448 | 1448 |
| 1449 void LargeObjectPage::sweep() | 1449 void LargeObjectPage::sweep() |
| 1450 { | 1450 { |
| 1451 heapObjectHeader()->unmark(); | 1451 heapObjectHeader()->unmark(); |
| 1452 Heap::increaseMarkedObjectSize(size()); | 1452 ThreadState::current()->increaseMarkedObjectSize(size()); |
|
haraken
2016/02/12 09:30:54
heap()->threadState()->
peria
2016/02/15 04:16:59
Done.
| |
| 1453 } | 1453 } |
| 1454 | 1454 |
| 1455 void LargeObjectPage::makeConsistentForGC() | 1455 void LargeObjectPage::makeConsistentForGC() |
| 1456 { | 1456 { |
| 1457 HeapObjectHeader* header = heapObjectHeader(); | 1457 HeapObjectHeader* header = heapObjectHeader(); |
| 1458 if (header->isMarked()) { | 1458 if (header->isMarked()) { |
| 1459 header->unmark(); | 1459 header->unmark(); |
| 1460 Heap::increaseMarkedObjectSize(size()); | 1460 ThreadState::current()->increaseMarkedObjectSize(size()); |
|
haraken
2016/02/12 09:30:54
heap()->threadState()->
peria
2016/02/15 04:16:59
Done.
| |
| 1461 } else { | 1461 } else { |
| 1462 header->markDead(); | 1462 header->markDead(); |
| 1463 } | 1463 } |
| 1464 } | 1464 } |
| 1465 | 1465 |
| 1466 void LargeObjectPage::makeConsistentForMutator() | 1466 void LargeObjectPage::makeConsistentForMutator() |
| 1467 { | 1467 { |
| 1468 HeapObjectHeader* header = heapObjectHeader(); | 1468 HeapObjectHeader* header = heapObjectHeader(); |
| 1469 if (header->isMarked()) | 1469 if (header->isMarked()) |
| 1470 header->unmark(); | 1470 header->unmark(); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1574 | 1574 |
| 1575 m_hasEntries = true; | 1575 m_hasEntries = true; |
| 1576 size_t index = hash(address); | 1576 size_t index = hash(address); |
| 1577 ASSERT(!(index & 1)); | 1577 ASSERT(!(index & 1)); |
| 1578 Address cachePage = roundToBlinkPageStart(address); | 1578 Address cachePage = roundToBlinkPageStart(address); |
| 1579 m_entries[index + 1] = m_entries[index]; | 1579 m_entries[index + 1] = m_entries[index]; |
| 1580 m_entries[index] = cachePage; | 1580 m_entries[index] = cachePage; |
| 1581 } | 1581 } |
| 1582 | 1582 |
| 1583 } // namespace blink | 1583 } // namespace blink |
| OLD | NEW |