| 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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 ->createMemoryAllocatorDumpForCurrentGC(dumpName + "/pages"); | 591 ->createMemoryAllocatorDumpForCurrentGC(dumpName + "/pages"); |
| 592 BlinkGCMemoryDumpProvider::instance() | 592 BlinkGCMemoryDumpProvider::instance() |
| 593 ->currentProcessMemoryDump() | 593 ->currentProcessMemoryDump() |
| 594 ->AddOwnershipEdge(pagesDump->guid(), bucketsDump->guid()); | 594 ->AddOwnershipEdge(pagesDump->guid(), bucketsDump->guid()); |
| 595 } | 595 } |
| 596 } | 596 } |
| 597 | 597 |
| 598 void NormalPageArena::allocatePage() { | 598 void NormalPageArena::allocatePage() { |
| 599 getThreadState()->shouldFlushHeapDoesNotContainCache(); | 599 getThreadState()->shouldFlushHeapDoesNotContainCache(); |
| 600 PageMemory* pageMemory = | 600 PageMemory* pageMemory = |
| 601 getThreadState()->heap().getFreePagePool()->takeFreePage(arenaIndex()); | 601 getThreadState()->heap().getFreePagePool()->take(arenaIndex()); |
| 602 | 602 |
| 603 if (!pageMemory) { | 603 if (!pageMemory) { |
| 604 // Allocate a memory region for blinkPagesPerRegion pages that | 604 // Allocate a memory region for blinkPagesPerRegion pages that |
| 605 // will each have the following layout. | 605 // will each have the following layout. |
| 606 // | 606 // |
| 607 // [ guard os page | ... payload ... | guard os page ] | 607 // [ guard os page | ... payload ... | guard os page ] |
| 608 // ^---{ aligned to blink page size } | 608 // ^---{ aligned to blink page size } |
| 609 PageMemoryRegion* region = PageMemoryRegion::allocateNormalPages( | 609 PageMemoryRegion* region = PageMemoryRegion::allocateNormalPages( |
| 610 getThreadState()->heap().getRegionTree()); | 610 getThreadState()->heap().getRegionTree()); |
| 611 | 611 |
| 612 // Setup the PageMemory object for each of the pages in the region. | 612 // Setup the PageMemory object for each of the pages in the region. |
| 613 for (size_t i = 0; i < blinkPagesPerRegion; ++i) { | 613 for (size_t i = 0; i < blinkPagesPerRegion; ++i) { |
| 614 PageMemory* memory = PageMemory::setupPageMemoryInRegion( | 614 PageMemory* memory = PageMemory::setupPageMemoryInRegion( |
| 615 region, i * blinkPageSize, blinkPagePayloadSize()); | 615 region, i * blinkPageSize, blinkPagePayloadSize()); |
| 616 // Take the first possible page ensuring that this thread actually | 616 // Take the first possible page ensuring that this thread actually |
| 617 // gets a page and add the rest to the page pool. | 617 // gets a page and add the rest to the page pool. |
| 618 if (!pageMemory) { | 618 if (!pageMemory) { |
| 619 bool result = memory->commit(); | 619 bool result = memory->commit(); |
| 620 // If you hit the ASSERT, it will mean that you're hitting | 620 // If you hit the ASSERT, it will mean that you're hitting |
| 621 // the limit of the number of mmapped regions OS can support | 621 // the limit of the number of mmapped regions OS can support |
| 622 // (e.g., /proc/sys/vm/max_map_count in Linux). | 622 // (e.g., /proc/sys/vm/max_map_count in Linux). |
| 623 RELEASE_ASSERT(result); | 623 RELEASE_ASSERT(result); |
| 624 pageMemory = memory; | 624 pageMemory = memory; |
| 625 } else { | 625 } else { |
| 626 getThreadState()->heap().getFreePagePool()->addFreePage(arenaIndex(), | 626 getThreadState()->heap().getFreePagePool()->add(arenaIndex(), memory); |
| 627 memory); | |
| 628 } | 627 } |
| 629 } | 628 } |
| 630 } | 629 } |
| 631 NormalPage* page = | 630 NormalPage* page = |
| 632 new (pageMemory->writableStart()) NormalPage(pageMemory, this); | 631 new (pageMemory->writableStart()) NormalPage(pageMemory, this); |
| 633 page->link(&m_firstPage); | 632 page->link(&m_firstPage); |
| 634 | 633 |
| 635 getThreadState()->heap().heapStats().increaseAllocatedSpace(page->size()); | 634 getThreadState()->heap().heapStats().increaseAllocatedSpace(page->size()); |
| 636 #if DCHECK_IS_ON() || defined(LEAK_SANITIZER) || defined(ADDRESS_SANITIZER) | 635 #if DCHECK_IS_ON() || defined(LEAK_SANITIZER) || defined(ADDRESS_SANITIZER) |
| 637 // Allow the following addToFreeList() to add the newly allocated memory | 636 // Allow the following addToFreeList() to add the newly allocated memory |
| 638 // to the free list. | 637 // to the free list. |
| 639 ASAN_UNPOISON_MEMORY_REGION(page->payload(), page->payloadSize()); | 638 ASAN_UNPOISON_MEMORY_REGION(page->payload(), page->payloadSize()); |
| 640 Address address = page->payload(); | 639 Address address = page->payload(); |
| 641 for (size_t i = 0; i < page->payloadSize(); i++) | 640 for (size_t i = 0; i < page->payloadSize(); i++) |
| 642 address[i] = reuseAllowedZapValue; | 641 address[i] = reuseAllowedZapValue; |
| 643 ASAN_POISON_MEMORY_REGION(page->payload(), page->payloadSize()); | 642 ASAN_POISON_MEMORY_REGION(page->payload(), page->payloadSize()); |
| 644 #endif | 643 #endif |
| 645 addToFreeList(page->payload(), page->payloadSize()); | 644 addToFreeList(page->payload(), page->payloadSize()); |
| 646 } | 645 } |
| 647 | 646 |
| 648 void NormalPageArena::freePage(NormalPage* page) { | 647 void NormalPageArena::freePage(NormalPage* page) { |
| 649 getThreadState()->heap().heapStats().decreaseAllocatedSpace(page->size()); | 648 getThreadState()->heap().heapStats().decreaseAllocatedSpace(page->size()); |
| 650 | 649 |
| 651 PageMemory* memory = page->storage(); | 650 PageMemory* memory = page->storage(); |
| 652 page->~NormalPage(); | 651 page->~NormalPage(); |
| 653 getThreadState()->heap().getFreePagePool()->addFreePage(arenaIndex(), memory); | 652 getThreadState()->heap().getFreePagePool()->add(arenaIndex(), memory); |
| 654 } | 653 } |
| 655 | 654 |
| 656 bool NormalPageArena::coalesce() { | 655 bool NormalPageArena::coalesce() { |
| 657 // Don't coalesce arenas if there are not enough promptly freed entries | 656 // Don't coalesce arenas if there are not enough promptly freed entries |
| 658 // to be coalesced. | 657 // to be coalesced. |
| 659 // | 658 // |
| 660 // FIXME: This threshold is determined just to optimize blink_perf | 659 // FIXME: This threshold is determined just to optimize blink_perf |
| 661 // benchmarks. Coalescing is very sensitive to the threashold and | 660 // benchmarks. Coalescing is very sensitive to the threashold and |
| 662 // we need further investigations on the coalescing scheme. | 661 // we need further investigations on the coalescing scheme. |
| 663 if (m_promptlyFreedSize < 1024 * 1024) | 662 if (m_promptlyFreedSize < 1024 * 1024) |
| (...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1818 | 1817 |
| 1819 m_hasEntries = true; | 1818 m_hasEntries = true; |
| 1820 size_t index = hash(address); | 1819 size_t index = hash(address); |
| 1821 ASSERT(!(index & 1)); | 1820 ASSERT(!(index & 1)); |
| 1822 Address cachePage = roundToBlinkPageStart(address); | 1821 Address cachePage = roundToBlinkPageStart(address); |
| 1823 m_entries[index + 1] = m_entries[index]; | 1822 m_entries[index + 1] = m_entries[index]; |
| 1824 m_entries[index] = cachePage; | 1823 m_entries[index] = cachePage; |
| 1825 } | 1824 } |
| 1826 | 1825 |
| 1827 } // namespace blink | 1826 } // namespace blink |
| OLD | NEW |