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

Side by Side Diff: Source/platform/heap/Heap.h

Issue 1297873002: Oilpan: Don't use guard pages in NaCl (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/platform/heap/Heap.cpp » ('j') | 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 const size_t blinkPageSize = 1 << blinkPageSizeLog2; 50 const size_t blinkPageSize = 1 << blinkPageSizeLog2;
51 const size_t blinkPageOffsetMask = blinkPageSize - 1; 51 const size_t blinkPageOffsetMask = blinkPageSize - 1;
52 const size_t blinkPageBaseMask = ~blinkPageOffsetMask; 52 const size_t blinkPageBaseMask = ~blinkPageOffsetMask;
53 53
54 // We allocate pages at random addresses but in groups of 54 // We allocate pages at random addresses but in groups of
55 // blinkPagesPerRegion at a given random address. We group pages to 55 // blinkPagesPerRegion at a given random address. We group pages to
56 // not spread out too much over the address space which would blow 56 // not spread out too much over the address space which would blow
57 // away the page tables and lead to bad performance. 57 // away the page tables and lead to bad performance.
58 const size_t blinkPagesPerRegion = 10; 58 const size_t blinkPagesPerRegion = 10;
59 59
60 // TODO(nya): Replace this with something like #if ENABLE_NACL.
61 #if 0
62 // NaCl's system page size is 64 KB. This causes a problem in Oilpan's heap
63 // layout because Oilpan allocates two guard pages for each blink page
64 // (whose size is 128 KB). So we don't use guard pages in NaCl.
65 const size_t blinkGuardPageSize = 0;
66 #else
67 const size_t blinkGuardPageSize = WTF::kSystemPageSize;
68 #endif
69
60 // Double precision floats are more efficient when 8 byte aligned, so we 8 byte 70 // Double precision floats are more efficient when 8 byte aligned, so we 8 byte
61 // align all allocations even on 32 bit. 71 // align all allocations even on 32 bit.
62 const size_t allocationGranularity = 8; 72 const size_t allocationGranularity = 8;
63 const size_t allocationMask = allocationGranularity - 1; 73 const size_t allocationMask = allocationGranularity - 1;
64 const size_t objectStartBitMapSize = (blinkPageSize + ((8 * allocationGranularit y) - 1)) / (8 * allocationGranularity); 74 const size_t objectStartBitMapSize = (blinkPageSize + ((8 * allocationGranularit y) - 1)) / (8 * allocationGranularity);
65 const size_t reservedForObjectBitMap = ((objectStartBitMapSize + allocationMask) & ~allocationMask); 75 const size_t reservedForObjectBitMap = ((objectStartBitMapSize + allocationMask) & ~allocationMask);
66 const size_t maxHeapObjectSizeLog2 = 27; 76 const size_t maxHeapObjectSizeLog2 = 27;
67 const size_t maxHeapObjectSize = 1 << maxHeapObjectSizeLog2; 77 const size_t maxHeapObjectSize = 1 << maxHeapObjectSizeLog2;
68 const size_t largeObjectSizeThreshold = blinkPageSize / 2; 78 const size_t largeObjectSizeThreshold = blinkPageSize / 2;
69 79
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 m_next = next; 301 m_next = next;
292 } 302 }
293 303
294 private: 304 private:
295 FreeListEntry* m_next; 305 FreeListEntry* m_next;
296 }; 306 };
297 307
298 // Blink heap pages are set up with a guard page before and after the payload. 308 // Blink heap pages are set up with a guard page before and after the payload.
299 inline size_t blinkPagePayloadSize() 309 inline size_t blinkPagePayloadSize()
300 { 310 {
301 return blinkPageSize - 2 * WTF::kSystemPageSize; 311 return blinkPageSize - 2 * blinkGuardPageSize;
302 } 312 }
303 313
304 // Blink heap pages are aligned to the Blink heap page size. 314 // Blink heap pages are aligned to the Blink heap page size.
305 // Therefore, the start of a Blink page can be obtained by 315 // Therefore, the start of a Blink page can be obtained by
306 // rounding down to the Blink page size. 316 // rounding down to the Blink page size.
307 inline Address roundToBlinkPageStart(Address address) 317 inline Address roundToBlinkPageStart(Address address)
308 { 318 {
309 return reinterpret_cast<Address>(reinterpret_cast<uintptr_t>(address) & blin kPageBaseMask); 319 return reinterpret_cast<Address>(reinterpret_cast<uintptr_t>(address) & blin kPageBaseMask);
310 } 320 }
311 321
(...skipping 12 matching lines...) Expand all
324 { 334 {
325 return !!(*reinterpret_cast<Address*>(objectPointer)); 335 return !!(*reinterpret_cast<Address*>(objectPointer));
326 } 336 }
327 337
328 #if ENABLE(ASSERT) 338 #if ENABLE(ASSERT)
329 // Sanity check for a page header address: the address of the page 339 // Sanity check for a page header address: the address of the page
330 // header should be OS page size away from being Blink page size 340 // header should be OS page size away from being Blink page size
331 // aligned. 341 // aligned.
332 inline bool isPageHeaderAddress(Address address) 342 inline bool isPageHeaderAddress(Address address)
333 { 343 {
334 return !((reinterpret_cast<uintptr_t>(address) & blinkPageOffsetMask) - WTF: :kSystemPageSize); 344 return !((reinterpret_cast<uintptr_t>(address) & blinkPageOffsetMask) - blin kGuardPageSize);
335 } 345 }
336 #endif 346 #endif
337 347
338 // BasePage is a base class for NormalPage and LargeObjectPage. 348 // BasePage is a base class for NormalPage and LargeObjectPage.
339 // 349 //
340 // - NormalPage is a page whose size is |blinkPageSize|. NormalPage can contain 350 // - NormalPage is a page whose size is |blinkPageSize|. NormalPage can contain
341 // multiple objects in the page. An object whose size is smaller than 351 // multiple objects in the page. An object whose size is smaller than
342 // |largeObjectSizeThreshold| is stored in NormalPage. 352 // |largeObjectSizeThreshold| is stored in NormalPage.
343 // 353 //
344 // - LargeObjectPage is a page that contains only one object. The object size 354 // - LargeObjectPage is a page that contains only one object. The object size
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 void freeLargeObjectPage(LargeObjectPage*); 803 void freeLargeObjectPage(LargeObjectPage*);
794 #if ENABLE(ASSERT) 804 #if ENABLE(ASSERT)
795 bool isConsistentForGC() override { return true; } 805 bool isConsistentForGC() override { return true; }
796 #endif 806 #endif
797 private: 807 private:
798 Address doAllocateLargeObjectPage(size_t, size_t gcInfoIndex); 808 Address doAllocateLargeObjectPage(size_t, size_t gcInfoIndex);
799 Address lazySweepPages(size_t, size_t gcInfoIndex) override; 809 Address lazySweepPages(size_t, size_t gcInfoIndex) override;
800 }; 810 };
801 811
802 // Mask an address down to the enclosing oilpan heap base page. All oilpan heap 812 // Mask an address down to the enclosing oilpan heap base page. All oilpan heap
803 // pages are aligned at blinkPageBase plus an OS page size. 813 // pages are aligned at blinkPageBase plus the size of a guard size.
804 // FIXME: Remove PLATFORM_EXPORT once we get a proper public interface to our 814 // FIXME: Remove PLATFORM_EXPORT once we get a proper public interface to our
805 // typed heaps. This is only exported to enable tests in HeapTest.cpp. 815 // typed heaps. This is only exported to enable tests in HeapTest.cpp.
806 PLATFORM_EXPORT inline BasePage* pageFromObject(const void* object) 816 PLATFORM_EXPORT inline BasePage* pageFromObject(const void* object)
807 { 817 {
808 Address address = reinterpret_cast<Address>(const_cast<void*>(object)); 818 Address address = reinterpret_cast<Address>(const_cast<void*>(object));
809 BasePage* page = reinterpret_cast<BasePage*>(blinkPageAddress(address) + WTF ::kSystemPageSize); 819 BasePage* page = reinterpret_cast<BasePage*>(blinkPageAddress(address) + bli nkGuardPageSize);
810 ASSERT(page->contains(address)); 820 ASSERT(page->contains(address));
811 return page; 821 return page;
812 } 822 }
813 823
814 template<typename T, bool = NeedsAdjustAndMark<T>::value> class ObjectAliveTrait ; 824 template<typename T, bool = NeedsAdjustAndMark<T>::value> class ObjectAliveTrait ;
815 825
816 template<typename T> 826 template<typename T>
817 class ObjectAliveTrait<T, false> { 827 class ObjectAliveTrait<T, false> {
818 public: 828 public:
819 static bool isHeapObjectAlive(T* object) 829 static bool isHeapObjectAlive(T* object)
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
1392 size_t copySize = previousHeader->payloadSize(); 1402 size_t copySize = previousHeader->payloadSize();
1393 if (copySize > size) 1403 if (copySize > size)
1394 copySize = size; 1404 copySize = size;
1395 memcpy(address, previous, copySize); 1405 memcpy(address, previous, copySize);
1396 return address; 1406 return address;
1397 } 1407 }
1398 1408
1399 } // namespace blink 1409 } // namespace blink
1400 1410
1401 #endif // Heap_h 1411 #endif // Heap_h
OLDNEW
« no previous file with comments | « no previous file | Source/platform/heap/Heap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698