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 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 size_t pageSize = availablePages->size(); | 556 size_t pageSize = availablePages->size(); |
557 #if DEBUG_HEAP_COMPACTION | 557 #if DEBUG_HEAP_COMPACTION |
558 if (!freedPageCount) | 558 if (!freedPageCount) |
559 LOG_HEAP_COMPACTION("Releasing:"); | 559 LOG_HEAP_COMPACTION("Releasing:"); |
560 LOG_HEAP_COMPACTION(" [%p, %p]", availablePages, availablePages + pageSize); | 560 LOG_HEAP_COMPACTION(" [%p, %p]", availablePages, availablePages + pageSize); |
561 #endif | 561 #endif |
562 freedSize += pageSize; | 562 freedSize += pageSize; |
563 freedPageCount++; | 563 freedPageCount++; |
564 BasePage* nextPage; | 564 BasePage* nextPage; |
565 availablePages->unlink(&nextPage); | 565 availablePages->unlink(&nextPage); |
| 566 // Clear out the page before adding it to the free page pool, which |
| 567 // decommits it. Recommitting the page must find a zeroed page later. |
| 568 // We cannot assume that the OS will hand back a zeroed page across |
| 569 // its "decommit" operation. |
| 570 DCHECK(!availablePages->isLargeObjectPage()); |
| 571 NormalPage* unusedPage = reinterpret_cast<NormalPage*>(availablePages); |
| 572 memset(unusedPage->payload(), 0, unusedPage->payloadSize()); |
566 availablePages->removeFromHeap(); | 573 availablePages->removeFromHeap(); |
567 availablePages = static_cast<NormalPage*>(nextPage); | 574 availablePages = static_cast<NormalPage*>(nextPage); |
568 } | 575 } |
569 if (freedPageCount) | 576 if (freedPageCount) |
570 LOG_HEAP_COMPACTION("\n"); | 577 LOG_HEAP_COMPACTION("\n"); |
571 heap.compaction()->finishedArenaCompaction(this, freedPageCount, freedSize); | 578 heap.compaction()->finishedArenaCompaction(this, freedPageCount, freedSize); |
572 } | 579 } |
573 | 580 |
574 #if ENABLE(ASSERT) | 581 #if ENABLE(ASSERT) |
575 bool NormalPageArena::isConsistentForGC() { | 582 bool NormalPageArena::isConsistentForGC() { |
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1497 headerAddress += size; | 1504 headerAddress += size; |
1498 markedObjectSize += size; | 1505 markedObjectSize += size; |
1499 allocationPoint += size; | 1506 allocationPoint += size; |
1500 DCHECK(allocationPoint <= currentPage->payloadSize()); | 1507 DCHECK(allocationPoint <= currentPage->payloadSize()); |
1501 } | 1508 } |
1502 if (markedObjectSize) | 1509 if (markedObjectSize) |
1503 pageArena->getThreadState()->increaseMarkedObjectSize(markedObjectSize); | 1510 pageArena->getThreadState()->increaseMarkedObjectSize(markedObjectSize); |
1504 | 1511 |
1505 #if ENABLE(ASSERT) || defined(LEAK_SANITIZER) || defined(ADDRESS_SANITIZER) || \ | 1512 #if ENABLE(ASSERT) || defined(LEAK_SANITIZER) || defined(ADDRESS_SANITIZER) || \ |
1506 defined(MEMORY_SANITIZER) | 1513 defined(MEMORY_SANITIZER) |
1507 // Zap the page, which is now available and will either be compacted into | 1514 // Zap the unused portion, until it is either compacted into or freed. |
1508 // or freed. | |
1509 if (currentPage != this) { | 1515 if (currentPage != this) { |
1510 FreeList::zapFreedMemory(payload(), payloadSize()); | 1516 FreeList::zapFreedMemory(payload(), payloadSize()); |
1511 } else { | 1517 } else { |
1512 FreeList::zapFreedMemory(payload() + allocationPoint, | 1518 FreeList::zapFreedMemory(payload() + allocationPoint, |
1513 payloadSize() - allocationPoint); | 1519 payloadSize() - allocationPoint); |
1514 } | 1520 } |
1515 #endif | 1521 #endif |
1516 } | 1522 } |
1517 | 1523 |
1518 void NormalPage::makeConsistentForGC() { | 1524 void NormalPage::makeConsistentForGC() { |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1900 | 1906 |
1901 m_hasEntries = true; | 1907 m_hasEntries = true; |
1902 size_t index = hash(address); | 1908 size_t index = hash(address); |
1903 ASSERT(!(index & 1)); | 1909 ASSERT(!(index & 1)); |
1904 Address cachePage = roundToBlinkPageStart(address); | 1910 Address cachePage = roundToBlinkPageStart(address); |
1905 m_entries[index + 1] = m_entries[index]; | 1911 m_entries[index + 1] = m_entries[index]; |
1906 m_entries[index] = cachePage; | 1912 m_entries[index] = cachePage; |
1907 } | 1913 } |
1908 | 1914 |
1909 } // namespace blink | 1915 } // namespace blink |
OLD | NEW |