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 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 for (size_t i = 0; i < blinkPageSizeLog2; ++i) | 514 for (size_t i = 0; i < blinkPageSizeLog2; ++i) |
515 json.pushInteger(bucketStats[i].freeSize); | 515 json.pushInteger(bucketStats[i].freeSize); |
516 json.endArray(); | 516 json.endArray(); |
517 } | 517 } |
518 #endif | 518 #endif |
519 | 519 |
520 void NormalPageHeap::allocatePage() | 520 void NormalPageHeap::allocatePage() |
521 { | 521 { |
522 threadState()->shouldFlushHeapDoesNotContainCache(); | 522 threadState()->shouldFlushHeapDoesNotContainCache(); |
523 PageMemory* pageMemory = Heap::freePagePool()->takeFreePage(heapIndex()); | 523 PageMemory* pageMemory = Heap::freePagePool()->takeFreePage(heapIndex()); |
524 // We continue allocating page memory until we succeed in committing one. | 524 |
525 size_t numberOfTrials = 0; | 525 if (!pageMemory) { |
526 while (!pageMemory) { | |
527 // Allocate a memory region for blinkPagesPerRegion pages that | 526 // Allocate a memory region for blinkPagesPerRegion pages that |
528 // will each have the following layout. | 527 // will each have the following layout. |
529 // | 528 // |
530 // [ guard os page | ... payload ... | guard os page ] | 529 // [ guard os page | ... payload ... | guard os page ] |
531 // ^---{ aligned to blink page size } | 530 // ^---{ aligned to blink page size } |
532 PageMemoryRegion* region = PageMemoryRegion::allocateNormalPages(); | 531 PageMemoryRegion* region = PageMemoryRegion::allocateNormalPages(); |
533 | 532 |
534 // Setup the PageMemory object for each of the pages in the region. | 533 // Setup the PageMemory object for each of the pages in the region. |
535 for (size_t i = 0; i < blinkPagesPerRegion; ++i) { | 534 for (size_t i = 0; i < blinkPagesPerRegion; ++i) { |
536 PageMemory* memory = PageMemory::setupPageMemoryInRegion(region, i *
blinkPageSize, blinkPagePayloadSize()); | 535 PageMemory* memory = PageMemory::setupPageMemoryInRegion(region, i *
blinkPageSize, blinkPagePayloadSize()); |
537 // Take the first possible page ensuring that this thread actually | 536 // Take the first possible page ensuring that this thread actually |
538 // gets a page and add the rest to the page pool. | 537 // gets a page and add the rest to the page pool. |
539 if (!pageMemory) { | 538 if (!pageMemory) { |
540 if (memory->commit()) | 539 bool result = memory->commit(); |
541 pageMemory = memory; | 540 // If you hit the ASSERT, it will mean that you're hitting |
542 else | 541 // the limit of the number of mmapped regions OS can support |
543 delete memory; | 542 // (e.g., /proc/sys/vm/max_map_count in Linux). |
| 543 RELEASE_ASSERT(result); |
| 544 pageMemory = memory; |
544 } else { | 545 } else { |
545 Heap::freePagePool()->addFreePage(heapIndex(), memory); | 546 Heap::freePagePool()->addFreePage(heapIndex(), memory); |
546 } | 547 } |
547 } | 548 } |
548 ++numberOfTrials; | |
549 // If you hit the ASSERT, it means that you're hitting the limit of | |
550 // the number of mmapped regions OS can support | |
551 // (e.g., /proc/sys/vm/max_map_count in Linux). | |
552 RELEASE_ASSERT(numberOfTrials < 64); | |
553 } | 549 } |
| 550 |
554 NormalPage* page = new (pageMemory->writableStart()) NormalPage(pageMemory,
this); | 551 NormalPage* page = new (pageMemory->writableStart()) NormalPage(pageMemory,
this); |
555 page->link(&m_firstPage); | 552 page->link(&m_firstPage); |
556 | 553 |
557 Heap::increaseAllocatedSpace(page->size()); | 554 Heap::increaseAllocatedSpace(page->size()); |
558 #if ENABLE(ASSERT) || defined(LEAK_SANITIZER) || defined(ADDRESS_SANITIZER) | 555 #if ENABLE(ASSERT) || defined(LEAK_SANITIZER) || defined(ADDRESS_SANITIZER) |
559 // Allow the following addToFreeList() to add the newly allocated memory | 556 // Allow the following addToFreeList() to add the newly allocated memory |
560 // to the free list. | 557 // to the free list. |
561 ASAN_UNPOISON_MEMORY_REGION(page->payload(), page->payloadSize()); | 558 ASAN_UNPOISON_MEMORY_REGION(page->payload(), page->payloadSize()); |
562 Address address = page->payload(); | 559 Address address = page->payload(); |
563 for (size_t i = 0; i < page->payloadSize(); i++) | 560 for (size_t i = 0; i < page->payloadSize(); i++) |
(...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1822 | 1819 |
1823 m_hasEntries = true; | 1820 m_hasEntries = true; |
1824 size_t index = hash(address); | 1821 size_t index = hash(address); |
1825 ASSERT(!(index & 1)); | 1822 ASSERT(!(index & 1)); |
1826 Address cachePage = roundToBlinkPageStart(address); | 1823 Address cachePage = roundToBlinkPageStart(address); |
1827 m_entries[index + 1] = m_entries[index]; | 1824 m_entries[index + 1] = m_entries[index]; |
1828 m_entries[index] = cachePage; | 1825 m_entries[index] = cachePage; |
1829 } | 1826 } |
1830 | 1827 |
1831 } // namespace blink | 1828 } // namespace blink |
OLD | NEW |