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

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

Issue 1319163003: Oilpan: Remove a redundant loop from NormalPageHeap::allocatePage() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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 | no next file » | 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 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
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);
sof 2015/09/08 07:13:11 Don't you need to assign pageMemory?
544 } else { 544 } else {
545 Heap::freePagePool()->addFreePage(heapIndex(), memory); 545 Heap::freePagePool()->addFreePage(heapIndex(), memory);
546 } 546 }
547 } 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);
553 } 548 }
549
554 NormalPage* page = new (pageMemory->writableStart()) NormalPage(pageMemory, this); 550 NormalPage* page = new (pageMemory->writableStart()) NormalPage(pageMemory, this);
555 page->link(&m_firstPage); 551 page->link(&m_firstPage);
556 552
557 Heap::increaseAllocatedSpace(page->size()); 553 Heap::increaseAllocatedSpace(page->size());
558 #if ENABLE(ASSERT) || defined(LEAK_SANITIZER) || defined(ADDRESS_SANITIZER) 554 #if ENABLE(ASSERT) || defined(LEAK_SANITIZER) || defined(ADDRESS_SANITIZER)
559 // Allow the following addToFreeList() to add the newly allocated memory 555 // Allow the following addToFreeList() to add the newly allocated memory
560 // to the free list. 556 // to the free list.
561 ASAN_UNPOISON_MEMORY_REGION(page->payload(), page->payloadSize()); 557 ASAN_UNPOISON_MEMORY_REGION(page->payload(), page->payloadSize());
562 Address address = page->payload(); 558 Address address = page->payload();
563 for (size_t i = 0; i < page->payloadSize(); i++) 559 for (size_t i = 0; i < page->payloadSize(); i++)
(...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1822 1818
1823 m_hasEntries = true; 1819 m_hasEntries = true;
1824 size_t index = hash(address); 1820 size_t index = hash(address);
1825 ASSERT(!(index & 1)); 1821 ASSERT(!(index & 1));
1826 Address cachePage = roundToBlinkPageStart(address); 1822 Address cachePage = roundToBlinkPageStart(address);
1827 m_entries[index + 1] = m_entries[index]; 1823 m_entries[index + 1] = m_entries[index];
1828 m_entries[index] = cachePage; 1824 m_entries[index] = cachePage;
1829 } 1825 }
1830 1826
1831 } // namespace blink 1827 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698