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

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

Issue 1804863002: Refactor RegionTree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed Created 4 years, 9 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
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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 { 418 {
419 getThreadState()->shouldFlushHeapDoesNotContainCache(); 419 getThreadState()->shouldFlushHeapDoesNotContainCache();
420 PageMemory* pageMemory = Heap::getFreePagePool()->takeFreePage(arenaIndex()) ; 420 PageMemory* pageMemory = Heap::getFreePagePool()->takeFreePage(arenaIndex()) ;
421 421
422 if (!pageMemory) { 422 if (!pageMemory) {
423 // Allocate a memory region for blinkPagesPerRegion pages that 423 // Allocate a memory region for blinkPagesPerRegion pages that
424 // will each have the following layout. 424 // will each have the following layout.
425 // 425 //
426 // [ guard os page | ... payload ... | guard os page ] 426 // [ guard os page | ... payload ... | guard os page ]
427 // ^---{ aligned to blink page size } 427 // ^---{ aligned to blink page size }
428 PageMemoryRegion* region = PageMemoryRegion::allocateNormalPages(); 428 PageMemoryRegion* region = PageMemoryRegion::allocateNormalPages(Heap::g etRegionTree());
429 429
430 // Setup the PageMemory object for each of the pages in the region. 430 // Setup the PageMemory object for each of the pages in the region.
431 for (size_t i = 0; i < blinkPagesPerRegion; ++i) { 431 for (size_t i = 0; i < blinkPagesPerRegion; ++i) {
432 PageMemory* memory = PageMemory::setupPageMemoryInRegion(region, i * blinkPageSize, blinkPagePayloadSize()); 432 PageMemory* memory = PageMemory::setupPageMemoryInRegion(region, i * blinkPageSize, blinkPagePayloadSize());
433 // Take the first possible page ensuring that this thread actually 433 // Take the first possible page ensuring that this thread actually
434 // gets a page and add the rest to the page pool. 434 // gets a page and add the rest to the page pool.
435 if (!pageMemory) { 435 if (!pageMemory) {
436 bool result = memory->commit(); 436 bool result = memory->commit();
437 // If you hit the ASSERT, it will mean that you're hitting 437 // If you hit the ASSERT, it will mean that you're hitting
438 // the limit of the number of mmapped regions OS can support 438 // the limit of the number of mmapped regions OS can support
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 Address LargeObjectArena::doAllocateLargeObjectPage(size_t allocationSize, size_ t gcInfoIndex) 808 Address LargeObjectArena::doAllocateLargeObjectPage(size_t allocationSize, size_ t gcInfoIndex)
809 { 809 {
810 size_t largeObjectSize = LargeObjectPage::pageHeaderSize() + allocationSize; 810 size_t largeObjectSize = LargeObjectPage::pageHeaderSize() + allocationSize;
811 // If ASan is supported we add allocationGranularity bytes to the allocated 811 // If ASan is supported we add allocationGranularity bytes to the allocated
812 // space and poison that to detect overflows 812 // space and poison that to detect overflows
813 #if defined(ADDRESS_SANITIZER) 813 #if defined(ADDRESS_SANITIZER)
814 largeObjectSize += allocationGranularity; 814 largeObjectSize += allocationGranularity;
815 #endif 815 #endif
816 816
817 getThreadState()->shouldFlushHeapDoesNotContainCache(); 817 getThreadState()->shouldFlushHeapDoesNotContainCache();
818 PageMemory* pageMemory = PageMemory::allocate(largeObjectSize); 818 PageMemory* pageMemory = PageMemory::allocate(largeObjectSize, Heap::getRegi onTree());
819 Address largeObjectAddress = pageMemory->writableStart(); 819 Address largeObjectAddress = pageMemory->writableStart();
820 Address headerAddress = largeObjectAddress + LargeObjectPage::pageHeaderSize (); 820 Address headerAddress = largeObjectAddress + LargeObjectPage::pageHeaderSize ();
821 #if ENABLE(ASSERT) 821 #if ENABLE(ASSERT)
822 // Verify that the allocated PageMemory is expectedly zeroed. 822 // Verify that the allocated PageMemory is expectedly zeroed.
823 for (size_t i = 0; i < largeObjectSize; ++i) 823 for (size_t i = 0; i < largeObjectSize; ++i)
824 ASSERT(!largeObjectAddress[i]); 824 ASSERT(!largeObjectAddress[i]);
825 #endif 825 #endif
826 ASSERT(gcInfoIndex > 0); 826 ASSERT(gcInfoIndex > 0);
827 HeapObjectHeader* header = new (NotNull, headerAddress) HeapObjectHeader(lar geObjectSizeInHeader, gcInfoIndex); 827 HeapObjectHeader* header = new (NotNull, headerAddress) HeapObjectHeader(lar geObjectSizeInHeader, gcInfoIndex);
828 Address result = headerAddress + sizeof(*header); 828 Address result = headerAddress + sizeof(*header);
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
1588 1588
1589 m_hasEntries = true; 1589 m_hasEntries = true;
1590 size_t index = hash(address); 1590 size_t index = hash(address);
1591 ASSERT(!(index & 1)); 1591 ASSERT(!(index & 1));
1592 Address cachePage = roundToBlinkPageStart(address); 1592 Address cachePage = roundToBlinkPageStart(address);
1593 m_entries[index + 1] = m_entries[index]; 1593 m_entries[index + 1] = m_entries[index];
1594 m_entries[index] = cachePage; 1594 m_entries[index] = cachePage;
1595 } 1595 }
1596 1596
1597 } // namespace blink 1597 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/Heap.cpp ('k') | third_party/WebKit/Source/platform/heap/PageMemory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698