<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[198829] trunk/Source/bmalloc</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/198829">198829</a></dd>
<dt>Author</dt> <dd>ggaren@apple.com</dd>
<dt>Date</dt> <dd>2016-03-29 23:42:36 -0700 (Tue, 29 Mar 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>bmalloc: support physical page sizes that don't match the virtual page size (take 2)
https://bugs.webkit.org/show_bug.cgi?id=156003

Reviewed by Andreas Kling.

This is a memory savings on iOS devices where the virtual page size
is 16kB but the physical page size is 4kB.

Take 1 was a memory regression on 16kB virtual / 16kB physical systems
because it used a 4kB page size within a 16kB page size, allowing up to
4 different object types to mix within a physical page. Because objects
of the same type tend to deallocate at the same time, mixing objects of
different types made pages less likely to become completely empty.

(Take 1 also had a bug where it used a platform #ifdef that didn't exist.
Oops.)

Take 2 allocates units of SmallPages equal to the physical page size.

* bmalloc/Heap.cpp:
(bmalloc::Heap::Heap):
(bmalloc::Heap::initializeLineMetadata):
(bmalloc::Heap::allocateSmallBumpRanges):
(bmalloc::Heap::allocateSmallPage):
(bmalloc::Heap::allocateLarge):
(bmalloc::Heap::splitAndAllocate):
(bmalloc::Heap::tryAllocateXLarge):
(bmalloc::Heap::shrinkXLarge):
* bmalloc/Heap.h: Use the physical page size for our VM operations because
we're only concerned with returning physical pages to the OS.

* bmalloc/VMAllocate.h:
(bmalloc::vmPageSize):
(bmalloc::vmPageShift):
(bmalloc::vmSize):
(bmalloc::vmValidate):
(bmalloc::vmPageSizePhysical):
(bmalloc::vmValidatePhysical):
(bmalloc::tryVMAllocate):
(bmalloc::vmDeallocatePhysicalPages):
(bmalloc::vmAllocatePhysicalPages):
(bmalloc::vmDeallocatePhysicalPagesSloppy):
(bmalloc::vmAllocatePhysicalPagesSloppy): Use the physical page size.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourcebmallocChangeLog">trunk/Source/bmalloc/ChangeLog</a></li>
<li><a href="#trunkSourcebmallocbmallocHeapcpp">trunk/Source/bmalloc/bmalloc/Heap.cpp</a></li>
<li><a href="#trunkSourcebmallocbmallocHeaph">trunk/Source/bmalloc/bmalloc/Heap.h</a></li>
<li><a href="#trunkSourcebmallocbmallocVMAllocateh">trunk/Source/bmalloc/bmalloc/VMAllocate.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourcebmallocChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/ChangeLog (198828 => 198829)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/ChangeLog        2016-03-30 06:00:22 UTC (rev 198828)
+++ trunk/Source/bmalloc/ChangeLog        2016-03-30 06:42:36 UTC (rev 198829)
</span><span class="lines">@@ -1,5 +1,51 @@
</span><span class="cx"> 2016-03-29  Geoffrey Garen  &lt;ggaren@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        bmalloc: support physical page sizes that don't match the virtual page size (take 2)
+        https://bugs.webkit.org/show_bug.cgi?id=156003
+
+        Reviewed by Andreas Kling.
+
+        This is a memory savings on iOS devices where the virtual page size
+        is 16kB but the physical page size is 4kB.
+
+        Take 1 was a memory regression on 16kB virtual / 16kB physical systems
+        because it used a 4kB page size within a 16kB page size, allowing up to
+        4 different object types to mix within a physical page. Because objects
+        of the same type tend to deallocate at the same time, mixing objects of
+        different types made pages less likely to become completely empty.
+
+        (Take 1 also had a bug where it used a platform #ifdef that didn't exist.
+        Oops.)
+
+        Take 2 allocates units of SmallPages equal to the physical page size.
+
+        * bmalloc/Heap.cpp:
+        (bmalloc::Heap::Heap):
+        (bmalloc::Heap::initializeLineMetadata):
+        (bmalloc::Heap::allocateSmallBumpRanges):
+        (bmalloc::Heap::allocateSmallPage):
+        (bmalloc::Heap::allocateLarge):
+        (bmalloc::Heap::splitAndAllocate):
+        (bmalloc::Heap::tryAllocateXLarge):
+        (bmalloc::Heap::shrinkXLarge):
+        * bmalloc/Heap.h: Use the physical page size for our VM operations because
+        we're only concerned with returning physical pages to the OS.
+
+        * bmalloc/VMAllocate.h:
+        (bmalloc::vmPageSize):
+        (bmalloc::vmPageShift):
+        (bmalloc::vmSize):
+        (bmalloc::vmValidate):
+        (bmalloc::vmPageSizePhysical):
+        (bmalloc::vmValidatePhysical):
+        (bmalloc::tryVMAllocate):
+        (bmalloc::vmDeallocatePhysicalPages):
+        (bmalloc::vmAllocatePhysicalPages):
+        (bmalloc::vmDeallocatePhysicalPagesSloppy):
+        (bmalloc::vmAllocatePhysicalPagesSloppy): Use the physical page size.
+
+2016-03-29  Geoffrey Garen  &lt;ggaren@apple.com&gt;
+
</ins><span class="cx">         bmalloc: page size should be configurable at runtime
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=155993
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocHeapcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/Heap.cpp (198828 => 198829)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/Heap.cpp        2016-03-30 06:00:22 UTC (rev 198828)
+++ trunk/Source/bmalloc/bmalloc/Heap.cpp        2016-03-30 06:42:36 UTC (rev 198829)
</span><span class="lines">@@ -35,11 +35,15 @@
</span><span class="cx"> namespace bmalloc {
</span><span class="cx"> 
</span><span class="cx"> Heap::Heap(std::lock_guard&lt;StaticMutex&gt;&amp;)
</span><del>-    : m_vmPageSize(vmPageSize())
</del><ins>+    : m_vmPageSizePhysical(vmPageSizePhysical())
</ins><span class="cx">     , m_largeObjects(VMState::HasPhysical::True)
</span><span class="cx">     , m_isAllocatingPages(false)
</span><span class="cx">     , m_scavenger(*this, &amp;Heap::concurrentScavenge)
</span><span class="cx"> {
</span><ins>+    RELEASE_BASSERT(vmPageSizePhysical() &gt;= smallPageSize);
+    RELEASE_BASSERT(vmPageSize() &gt;= vmPageSizePhysical());
+    RELEASE_BASSERT(xLargeAlignment &gt;= vmPageSize());
+
</ins><span class="cx">     initializeLineMetadata();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -47,7 +51,7 @@
</span><span class="cx"> {
</span><span class="cx">     // We assume that m_smallLineMetadata is zero-filled.
</span><span class="cx"> 
</span><del>-    size_t smallLineCount = m_vmPageSize / smallLineSize;
</del><ins>+    size_t smallLineCount = m_vmPageSizePhysical / smallLineSize;
</ins><span class="cx">     m_smallLineMetadata.grow(sizeClassCount * smallLineCount);
</span><span class="cx"> 
</span><span class="cx">     for (size_t sizeClass = 0; sizeClass &lt; sizeClassCount; ++sizeClass) {
</span><span class="lines">@@ -56,7 +60,7 @@
</span><span class="cx"> 
</span><span class="cx">         size_t object = 0;
</span><span class="cx">         size_t line = 0;
</span><del>-        while (object &lt; m_vmPageSize) {
</del><ins>+        while (object &lt; m_vmPageSizePhysical) {
</ins><span class="cx">             line = object / smallLineSize;
</span><span class="cx">             size_t leftover = object % smallLineSize;
</span><span class="cx"> 
</span><span class="lines">@@ -70,7 +74,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Don't allow the last object in a page to escape the page.
</span><del>-        if (object &gt; m_vmPageSize) {
</del><ins>+        if (object &gt; m_vmPageSizePhysical) {
</ins><span class="cx">             BASSERT(pageMetadata[line].objectCount);
</span><span class="cx">             --pageMetadata[line].objectCount;
</span><span class="cx">         }
</span><span class="lines">@@ -152,7 +156,7 @@
</span><span class="cx">     SmallPage* page = allocateSmallPage(lock, sizeClass);
</span><span class="cx">     SmallLine* lines = page-&gt;begin();
</span><span class="cx">     BASSERT(page-&gt;hasFreeLines(lock));
</span><del>-    size_t smallLineCount = m_vmPageSize / smallLineSize;
</del><ins>+    size_t smallLineCount = m_vmPageSizePhysical / smallLineSize;
</ins><span class="cx">     LineMetadata* pageMetadata = &amp;m_smallLineMetadata[sizeClass * smallLineCount];
</span><span class="cx"> 
</span><span class="cx">     // Find a free line.
</span><span class="lines">@@ -211,8 +215,8 @@
</span><span class="cx">         return page;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    size_t unalignedSize = largeMin + m_vmPageSize - largeAlignment + m_vmPageSize;
-    LargeObject largeObject = allocateLarge(lock, m_vmPageSize, m_vmPageSize, unalignedSize);
</del><ins>+    size_t unalignedSize = largeMin + m_vmPageSizePhysical - largeAlignment + m_vmPageSizePhysical;
+    LargeObject largeObject = allocateLarge(lock, m_vmPageSizePhysical, m_vmPageSizePhysical, unalignedSize);
</ins><span class="cx">     
</span><span class="cx">     // Transform our large object into a small object page. We deref here
</span><span class="cx">     // because our small objects will keep their own line refcounts.
</span><span class="lines">@@ -222,10 +226,10 @@
</span><span class="cx"> 
</span><span class="cx">     SmallPage* page = object.page();
</span><span class="cx">     page-&gt;setSizeClass(sizeClass);
</span><del>-    page-&gt;setSmallPageCount(m_vmPageSize / smallPageSize);
</del><ins>+    page-&gt;setSmallPageCount(m_vmPageSizePhysical / smallPageSize);
</ins><span class="cx"> 
</span><span class="cx">     // Set a slide() value on intermediate SmallPages so they hash to their
</span><del>-    // vmPageSize-sized page.
</del><ins>+    // vmPageSizePhysical-sized page.
</ins><span class="cx">     for (size_t i = 1; i &lt; page-&gt;smallPageCount(); ++i)
</span><span class="cx">         page[i].setSlide(i);
</span><span class="cx"> 
</span><span class="lines">@@ -326,7 +330,7 @@
</span><span class="cx">     BASSERT(size &gt;= largeMin);
</span><span class="cx">     BASSERT(size == roundUpToMultipleOf&lt;largeAlignment&gt;(size));
</span><span class="cx">     
</span><del>-    if (size &lt;= m_vmPageSize)
</del><ins>+    if (size &lt;= m_vmPageSizePhysical)
</ins><span class="cx">         scavengeSmallPages(lock);
</span><span class="cx"> 
</span><span class="cx">     LargeObject largeObject = m_largeObjects.take(size);
</span><span class="lines">@@ -357,7 +361,7 @@
</span><span class="cx">     BASSERT(alignment &gt;= largeAlignment);
</span><span class="cx">     BASSERT(isPowerOfTwo(alignment));
</span><span class="cx"> 
</span><del>-    if (size &lt;= m_vmPageSize)
</del><ins>+    if (size &lt;= m_vmPageSizePhysical)
</ins><span class="cx">         scavengeSmallPages(lock);
</span><span class="cx"> 
</span><span class="cx">     LargeObject largeObject = m_largeObjects.take(alignment, size, unalignedSize);
</span><span class="lines">@@ -431,7 +435,7 @@
</span><span class="cx">     // in the allocated list. This is an important optimization because it
</span><span class="cx">     // keeps the free list short, speeding up allocation and merging.
</span><span class="cx"> 
</span><del>-    std::pair&lt;XLargeRange, XLargeRange&gt; allocated = range.split(roundUpToMultipleOf(m_vmPageSize, size));
</del><ins>+    std::pair&lt;XLargeRange, XLargeRange&gt; allocated = range.split(roundUpToMultipleOf(m_vmPageSizePhysical, size));
</ins><span class="cx">     if (allocated.first.vmState().hasVirtual()) {
</span><span class="cx">         vmAllocatePhysicalPagesSloppy(allocated.first.begin(), allocated.first.size());
</span><span class="cx">         allocated.first.setVMState(VMState::Physical);
</span><span class="lines">@@ -448,7 +452,7 @@
</span><span class="cx"> 
</span><span class="cx">     m_isAllocatingPages = true;
</span><span class="cx"> 
</span><del>-    size = std::max(m_vmPageSize, size);
</del><ins>+    size = std::max(m_vmPageSizePhysical, size);
</ins><span class="cx">     alignment = roundUpToMultipleOf&lt;xLargeAlignment&gt;(alignment);
</span><span class="cx"> 
</span><span class="cx">     XLargeRange range = m_xLargeMap.takeFree(alignment, size);
</span><span class="lines">@@ -475,7 +479,7 @@
</span><span class="cx"> {
</span><span class="cx">     BASSERT(object.size() &gt; newSize);
</span><span class="cx"> 
</span><del>-    if (object.size() - newSize &lt; m_vmPageSize)
</del><ins>+    if (object.size() - newSize &lt; m_vmPageSizePhysical)
</ins><span class="cx">         return;
</span><span class="cx">     
</span><span class="cx">     XLargeRange range = m_xLargeMap.takeAllocated(object.begin());
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocHeaph"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/Heap.h (198828 => 198829)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/Heap.h        2016-03-30 06:00:22 UTC (rev 198828)
+++ trunk/Source/bmalloc/bmalloc/Heap.h        2016-03-30 06:42:36 UTC (rev 198829)
</span><span class="lines">@@ -93,7 +93,7 @@
</span><span class="cx">     void scavengeLargeObjects(std::unique_lock&lt;StaticMutex&gt;&amp;, std::chrono::milliseconds);
</span><span class="cx">     void scavengeXLargeObjects(std::unique_lock&lt;StaticMutex&gt;&amp;, std::chrono::milliseconds);
</span><span class="cx"> 
</span><del>-    size_t m_vmPageSize;
</del><ins>+    size_t m_vmPageSizePhysical;
</ins><span class="cx"> 
</span><span class="cx">     Vector&lt;LineMetadata&gt; m_smallLineMetadata;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocVMAllocateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/VMAllocate.h (198828 => 198829)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/VMAllocate.h        2016-03-30 06:00:22 UTC (rev 198828)
+++ trunk/Source/bmalloc/bmalloc/VMAllocate.h        2016-03-30 06:42:36 UTC (rev 198829)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> #include &lt;unistd.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #if BOS(DARWIN)
</span><ins>+#include &lt;mach/vm_page_size.h&gt;
</ins><span class="cx"> #include &lt;mach/vm_statistics.h&gt;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -49,12 +50,18 @@
</span><span class="cx"> 
</span><span class="cx"> inline size_t vmPageSize()
</span><span class="cx"> {
</span><del>-    return sysconf(_SC_PAGESIZE);
</del><ins>+    static size_t cached;
+    if (!cached)
+        cached = sysconf(_SC_PAGESIZE);
+    return cached;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> inline size_t vmPageShift()
</span><span class="cx"> {
</span><del>-    return log2(vmPageSize());
</del><ins>+    static size_t cached;
+    if (!cached)
+        cached = log2(vmPageSize());
+    return cached;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> inline size_t vmSize(size_t size)
</span><span class="lines">@@ -78,6 +85,34 @@
</span><span class="cx">     BASSERT(p == mask(p, ~(vmPageSize() - 1)));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+inline size_t vmPageSizePhysical()
+{
+#if (BPLATFORM(IOS) &amp;&amp; __IPHONE_OS_VERSION_MIN_REQUIRED &gt;= 100000)
+    return vm_kernel_page_size;
+#else
+    static size_t cached;
+    if (!cached)
+        cached = sysconf(_SC_PAGESIZE);
+    return cached;
+#endif
+}
+
+inline void vmValidatePhysical(size_t vmSize)
+{
+    UNUSED(vmSize);
+    BASSERT(vmSize);
+    BASSERT(vmSize == roundUpToMultipleOf(vmPageSizePhysical(), vmSize));
+}
+
+inline void vmValidatePhysical(void* p, size_t vmSize)
+{
+    vmValidatePhysical(vmSize);
+    
+    UNUSED(p);
+    BASSERT(p);
+    BASSERT(p == mask(p, ~(vmPageSizePhysical() - 1)));
+}
+
</ins><span class="cx"> inline void* tryVMAllocate(size_t vmSize)
</span><span class="cx"> {
</span><span class="cx">     vmValidate(vmSize);
</span><span class="lines">@@ -139,7 +174,7 @@
</span><span class="cx"> 
</span><span class="cx"> inline void vmDeallocatePhysicalPages(void* p, size_t vmSize)
</span><span class="cx"> {
</span><del>-    vmValidate(p, vmSize);
</del><ins>+    vmValidatePhysical(p, vmSize);
</ins><span class="cx"> #if BOS(DARWIN)
</span><span class="cx">     SYSCALL(madvise(p, vmSize, MADV_FREE_REUSABLE));
</span><span class="cx"> #else
</span><span class="lines">@@ -149,7 +184,7 @@
</span><span class="cx"> 
</span><span class="cx"> inline void vmAllocatePhysicalPages(void* p, size_t vmSize)
</span><span class="cx"> {
</span><del>-    vmValidate(p, vmSize);
</del><ins>+    vmValidatePhysical(p, vmSize);
</ins><span class="cx"> #if BOS(DARWIN)
</span><span class="cx">     SYSCALL(madvise(p, vmSize, MADV_FREE_REUSE));
</span><span class="cx"> #else
</span><span class="lines">@@ -160,8 +195,8 @@
</span><span class="cx"> // Trims requests that are un-page-aligned.
</span><span class="cx"> inline void vmDeallocatePhysicalPagesSloppy(void* p, size_t size)
</span><span class="cx"> {
</span><del>-    char* begin = roundUpToMultipleOf(vmPageSize(), static_cast&lt;char*&gt;(p));
-    char* end = roundDownToMultipleOf(vmPageSize(), static_cast&lt;char*&gt;(p) + size);
</del><ins>+    char* begin = roundUpToMultipleOf(vmPageSizePhysical(), static_cast&lt;char*&gt;(p));
+    char* end = roundDownToMultipleOf(vmPageSizePhysical(), static_cast&lt;char*&gt;(p) + size);
</ins><span class="cx"> 
</span><span class="cx">     if (begin &gt;= end)
</span><span class="cx">         return;
</span><span class="lines">@@ -172,8 +207,8 @@
</span><span class="cx"> // Expands requests that are un-page-aligned.
</span><span class="cx"> inline void vmAllocatePhysicalPagesSloppy(void* p, size_t size)
</span><span class="cx"> {
</span><del>-    char* begin = roundDownToMultipleOf(vmPageSize(), static_cast&lt;char*&gt;(p));
-    char* end = roundUpToMultipleOf(vmPageSize(), static_cast&lt;char*&gt;(p) + size);
</del><ins>+    char* begin = roundDownToMultipleOf(vmPageSizePhysical(), static_cast&lt;char*&gt;(p));
+    char* end = roundUpToMultipleOf(vmPageSizePhysical(), static_cast&lt;char*&gt;(p) + size);
</ins><span class="cx"> 
</span><span class="cx">     if (begin &gt;= end)
</span><span class="cx">         return;
</span></span></pre>
</div>
</div>

</body>
</html>