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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 // We continue allocating page memory until we succeed in committing one. |
525 size_t numberOfTrials = 0; | |
525 while (!pageMemory) { | 526 while (!pageMemory) { |
526 // Allocate a memory region for blinkPagesPerRegion pages that | 527 // Allocate a memory region for blinkPagesPerRegion pages that |
527 // will each have the following layout. | 528 // will each have the following layout. |
528 // | 529 // |
529 // [ guard os page | ... payload ... | guard os page ] | 530 // [ guard os page | ... payload ... | guard os page ] |
530 // ^---{ aligned to blink page size } | 531 // ^---{ aligned to blink page size } |
531 PageMemoryRegion* region = PageMemoryRegion::allocateNormalPages(); | 532 PageMemoryRegion* region = PageMemoryRegion::allocateNormalPages(); |
532 | 533 |
533 // Setup the PageMemory object for each of the pages in the region. | 534 // Setup the PageMemory object for each of the pages in the region. |
534 size_t offset = 0; | |
535 for (size_t i = 0; i < blinkPagesPerRegion; ++i) { | 535 for (size_t i = 0; i < blinkPagesPerRegion; ++i) { |
536 PageMemory* memory = PageMemory::setupPageMemoryInRegion(region, off set, blinkPagePayloadSize()); | 536 PageMemory* memory = PageMemory::setupPageMemoryInRegion(region, i * blinkPageSize, blinkPagePayloadSize()); |
537 // Take the first possible page ensuring that this thread actually | 537 // Take the first possible page ensuring that this thread actually |
538 // gets a page and add the rest to the page pool. | 538 // gets a page and add the rest to the page pool. |
539 if (!pageMemory) { | 539 if (!pageMemory) { |
540 if (memory->commit()) | 540 if (memory->commit()) |
541 pageMemory = memory; | 541 pageMemory = memory; |
542 else | 542 else |
543 delete memory; | 543 delete memory; |
544 } else { | 544 } else { |
545 Heap::freePagePool()->addFreePage(heapIndex(), memory); | 545 Heap::freePagePool()->addFreePage(heapIndex(), memory); |
546 } | 546 } |
547 offset += blinkPageSize; | |
548 } | 547 } |
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); | |
sof
2015/09/08 05:30:34
Could you explain a bit more what you were seeing?
haraken
2015/09/08 05:35:19
The above memory->commit() starts failing (because
sof
2015/09/08 06:25:57
And once it does & that OS' limit is reached, the
haraken
2015/09/08 06:33:14
Right.
BTW, do you have any idea on why we have a
sof
2015/09/08 06:59:17
Yes, it looks out of place to have a loop there no
| |
549 } | 553 } |
550 NormalPage* page = new (pageMemory->writableStart()) NormalPage(pageMemory, this); | 554 NormalPage* page = new (pageMemory->writableStart()) NormalPage(pageMemory, this); |
551 page->link(&m_firstPage); | 555 page->link(&m_firstPage); |
552 | 556 |
553 Heap::increaseAllocatedSpace(page->size()); | 557 Heap::increaseAllocatedSpace(page->size()); |
554 #if ENABLE(ASSERT) || defined(LEAK_SANITIZER) || defined(ADDRESS_SANITIZER) | 558 #if ENABLE(ASSERT) || defined(LEAK_SANITIZER) || defined(ADDRESS_SANITIZER) |
555 // Allow the following addToFreeList() to add the newly allocated memory | 559 // Allow the following addToFreeList() to add the newly allocated memory |
556 // to the free list. | 560 // to the free list. |
557 ASAN_UNPOISON_MEMORY_REGION(page->payload(), page->payloadSize()); | 561 ASAN_UNPOISON_MEMORY_REGION(page->payload(), page->payloadSize()); |
558 Address address = page->payload(); | 562 Address address = page->payload(); |
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1818 | 1822 |
1819 m_hasEntries = true; | 1823 m_hasEntries = true; |
1820 size_t index = hash(address); | 1824 size_t index = hash(address); |
1821 ASSERT(!(index & 1)); | 1825 ASSERT(!(index & 1)); |
1822 Address cachePage = roundToBlinkPageStart(address); | 1826 Address cachePage = roundToBlinkPageStart(address); |
1823 m_entries[index + 1] = m_entries[index]; | 1827 m_entries[index + 1] = m_entries[index]; |
1824 m_entries[index] = cachePage; | 1828 m_entries[index] = cachePage; |
1825 } | 1829 } |
1826 | 1830 |
1827 } // namespace blink | 1831 } // namespace blink |
OLD | NEW |