Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: third_party/WebKit/Source/platform/heap/HeapPage.cpp

Issue 1393863004: Oilpan: always shrink tail-allocated backing storage (reland.) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/heap/HeapPage.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 { 692 {
693 // It's possible that Vector requests a smaller expanded size because 693 // It's possible that Vector requests a smaller expanded size because
694 // Vector::shrinkCapacity can set a capacity smaller than the actual payload 694 // Vector::shrinkCapacity can set a capacity smaller than the actual payload
695 // size. 695 // size.
696 ASSERT(header->checkHeader()); 696 ASSERT(header->checkHeader());
697 if (header->payloadSize() >= newSize) 697 if (header->payloadSize() >= newSize)
698 return true; 698 return true;
699 size_t allocationSize = Heap::allocationSizeFromSize(newSize); 699 size_t allocationSize = Heap::allocationSizeFromSize(newSize);
700 ASSERT(allocationSize > header->size()); 700 ASSERT(allocationSize > header->size());
701 size_t expandSize = allocationSize - header->size(); 701 size_t expandSize = allocationSize - header->size();
702 if (header->payloadEnd() == m_currentAllocationPoint && expandSize <= m_rema iningAllocationSize) { 702 if (isObjectAllocatedLast(header) && expandSize <= m_remainingAllocationSize ) {
haraken 2015/10/09 14:21:41 isObjectAllocatedAtAllocationPoint ?
sof 2015/10/09 14:26:40 A bit long, but why not; done.
703 m_currentAllocationPoint += expandSize; 703 m_currentAllocationPoint += expandSize;
704 m_remainingAllocationSize -= expandSize; 704 m_remainingAllocationSize -= expandSize;
705 705
706 // Unpoison the memory used for the object (payload). 706 // Unpoison the memory used for the object (payload).
707 SET_MEMORY_ACCESSIBLE(header->payloadEnd(), expandSize); 707 SET_MEMORY_ACCESSIBLE(header->payloadEnd(), expandSize);
708 header->setSize(allocationSize); 708 header->setSize(allocationSize);
709 ASSERT(findPageFromAddress(header->payloadEnd() - 1)); 709 ASSERT(findPageFromAddress(header->payloadEnd() - 1));
710 return true; 710 return true;
711 } 711 }
712 return false; 712 return false;
713 } 713 }
714 714
715 bool NormalPageHeap::shrinkObject(HeapObjectHeader* header, size_t newSize) 715 bool NormalPageHeap::shrinkObject(HeapObjectHeader* header, size_t newSize)
716 { 716 {
717 ASSERT(header->checkHeader()); 717 ASSERT(header->checkHeader());
718 ASSERT(header->payloadSize() > newSize); 718 ASSERT(header->payloadSize() > newSize);
719 size_t allocationSize = Heap::allocationSizeFromSize(newSize); 719 size_t allocationSize = Heap::allocationSizeFromSize(newSize);
720 ASSERT(header->size() > allocationSize); 720 ASSERT(header->size() > allocationSize);
721 size_t shrinkSize = header->size() - allocationSize; 721 size_t shrinkSize = header->size() - allocationSize;
722 if (header->payloadEnd() == m_currentAllocationPoint) { 722 if (isObjectAllocatedLast(header)) {
723 m_currentAllocationPoint -= shrinkSize; 723 m_currentAllocationPoint -= shrinkSize;
724 m_remainingAllocationSize += shrinkSize; 724 m_remainingAllocationSize += shrinkSize;
725 SET_MEMORY_INACCESSIBLE(m_currentAllocationPoint, shrinkSize); 725 SET_MEMORY_INACCESSIBLE(m_currentAllocationPoint, shrinkSize);
726 header->setSize(allocationSize); 726 header->setSize(allocationSize);
727 return true; 727 return true;
728 } 728 }
729 ASSERT(shrinkSize >= sizeof(HeapObjectHeader)); 729 ASSERT(shrinkSize >= sizeof(HeapObjectHeader));
730 ASSERT(header->gcInfoIndex() > 0); 730 ASSERT(header->gcInfoIndex() > 0);
731 Address shrinkAddress = header->payloadEnd() - shrinkSize; 731 Address shrinkAddress = header->payloadEnd() - shrinkSize;
732 HeapObjectHeader* freedHeader = new (NotNull, shrinkAddress) HeapObjectHeade r(shrinkSize, header->gcInfoIndex()); 732 HeapObjectHeader* freedHeader = new (NotNull, shrinkAddress) HeapObjectHeade r(shrinkSize, header->gcInfoIndex());
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 1840
1841 m_hasEntries = true; 1841 m_hasEntries = true;
1842 size_t index = hash(address); 1842 size_t index = hash(address);
1843 ASSERT(!(index & 1)); 1843 ASSERT(!(index & 1));
1844 Address cachePage = roundToBlinkPageStart(address); 1844 Address cachePage = roundToBlinkPageStart(address);
1845 m_entries[index + 1] = m_entries[index]; 1845 m_entries[index + 1] = m_entries[index];
1846 m_entries[index] = cachePage; 1846 m_entries[index] = cachePage;
1847 } 1847 }
1848 1848
1849 } // namespace blink 1849 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/HeapPage.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698