<!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>[178611] trunk/PerformanceTests</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/178611">178611</a></dd>
<dt>Author</dt> <dd>ggaren@apple.com</dd>
<dt>Date</dt> <dd>2015-01-16 16:10:59 -0800 (Fri, 16 Jan 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>bmalloc: added the tiniest bit of testing for aligned allocation
https://bugs.webkit.org/show_bug.cgi?id=140573

Reviewed by Andreas Kling.

Just good enoug to catch two bugs in a preliminary implementation.

* MallocBench/MallocBench.xcodeproj/project.pbxproj:
* MallocBench/MallocBench/Benchmark.cpp:
* MallocBench/MallocBench/mbmalloc.cpp:
* MallocBench/MallocBench/mbmalloc.h:
* MallocBench/MallocBench/memalign.cpp: Added.
(benchmark_memalign):
* MallocBench/MallocBench/memalign.h: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkPerformanceTestsChangeLog">trunk/PerformanceTests/ChangeLog</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchBenchmarkcpp">trunk/PerformanceTests/MallocBench/MallocBench/Benchmark.cpp</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchmbmalloccpp">trunk/PerformanceTests/MallocBench/MallocBench/mbmalloc.cpp</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchmbmalloch">trunk/PerformanceTests/MallocBench/MallocBench/mbmalloc.h</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchxcodeprojprojectpbxproj">trunk/PerformanceTests/MallocBench/MallocBench.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchmemaligncpp">trunk/PerformanceTests/MallocBench/MallocBench/memalign.cpp</a></li>
<li><a href="#trunkPerformanceTestsMallocBenchMallocBenchmemalignh">trunk/PerformanceTests/MallocBench/MallocBench/memalign.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkPerformanceTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/PerformanceTests/ChangeLog (178610 => 178611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/ChangeLog        2015-01-17 00:10:18 UTC (rev 178610)
+++ trunk/PerformanceTests/ChangeLog        2015-01-17 00:10:59 UTC (rev 178611)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2015-01-16  Geoffrey Garen  &lt;ggaren@apple.com&gt;
+
+        bmalloc: added the tiniest bit of testing for aligned allocation
+        https://bugs.webkit.org/show_bug.cgi?id=140573
+
+        Reviewed by Andreas Kling.
+
+        Just good enoug to catch two bugs in a preliminary implementation.
+
+        * MallocBench/MallocBench.xcodeproj/project.pbxproj:
+        * MallocBench/MallocBench/Benchmark.cpp:
+        * MallocBench/MallocBench/mbmalloc.cpp:
+        * MallocBench/MallocBench/mbmalloc.h:
+        * MallocBench/MallocBench/memalign.cpp: Added.
+        (benchmark_memalign):
+        * MallocBench/MallocBench/memalign.h: Added.
+
</ins><span class="cx"> 2014-12-09  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add performance test related to font fallback
</span></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchBenchmarkcpp"></a>
<div class="modfile"><h4>Modified: trunk/PerformanceTests/MallocBench/MallocBench/Benchmark.cpp (178610 => 178611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/Benchmark.cpp        2015-01-17 00:10:18 UTC (rev 178610)
+++ trunk/PerformanceTests/MallocBench/MallocBench/Benchmark.cpp        2015-01-17 00:10:59 UTC (rev 178611)
</span><span class="lines">@@ -33,8 +33,10 @@
</span><span class="cx"> #include &quot;fragment.h&quot;
</span><span class="cx"> #include &quot;list.h&quot;
</span><span class="cx"> #include &quot;medium.h&quot;
</span><ins>+#include &quot;memalign.h&quot;
</ins><span class="cx"> #include &quot;message.h&quot;
</span><span class="cx"> #include &quot;reddit.h&quot;
</span><ins>+#include &quot;realloc.h&quot;
</ins><span class="cx"> #include &quot;stress.h&quot;
</span><span class="cx"> #include &quot;theverge.h&quot;
</span><span class="cx"> #include &quot;tree.h&quot;
</span><span class="lines">@@ -69,8 +71,10 @@
</span><span class="cx">     { &quot;list_allocate&quot;, benchmark_list_allocate },
</span><span class="cx">     { &quot;list_traverse&quot;, benchmark_list_traverse },
</span><span class="cx">     { &quot;medium&quot;, benchmark_medium },
</span><ins>+    { &quot;memalign&quot;, benchmark_memalign },
</ins><span class="cx">     { &quot;message_many&quot;, benchmark_message_many },
</span><span class="cx">     { &quot;message_one&quot;, benchmark_message_one },
</span><ins>+    { &quot;realloc&quot;, benchmark_realloc },
</ins><span class="cx">     { &quot;reddit&quot;, benchmark_reddit },
</span><span class="cx">     { &quot;reddit_memory_warning&quot;, benchmark_reddit_memory_warning },
</span><span class="cx">     { &quot;stress&quot;, benchmark_stress },
</span></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchmbmalloccpp"></a>
<div class="modfile"><h4>Modified: trunk/PerformanceTests/MallocBench/MallocBench/mbmalloc.cpp (178610 => 178611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/mbmalloc.cpp        2015-01-17 00:10:18 UTC (rev 178610)
+++ trunk/PerformanceTests/MallocBench/MallocBench/mbmalloc.cpp        2015-01-17 00:10:59 UTC (rev 178611)
</span><span class="lines">@@ -35,6 +35,13 @@
</span><span class="cx">     return malloc(size);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void* mbmemalign(size_t alignment, size_t size)
+{
+    void* result;
+    posix_memalign(&amp;result, alignment, size);
+    return result;
+}
+
</ins><span class="cx"> void mbfree(void* p, size_t)
</span><span class="cx"> {
</span><span class="cx">     return free(p);
</span></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchmbmalloch"></a>
<div class="modfile"><h4>Modified: trunk/PerformanceTests/MallocBench/MallocBench/mbmalloc.h (178610 => 178611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/mbmalloc.h        2015-01-17 00:10:18 UTC (rev 178610)
+++ trunk/PerformanceTests/MallocBench/MallocBench/mbmalloc.h        2015-01-17 00:10:59 UTC (rev 178611)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> extern &quot;C&quot; {
</span><span class="cx"> 
</span><span class="cx"> void* mbmalloc(size_t);
</span><ins>+void* mbmemalign(size_t, size_t);
</ins><span class="cx"> void mbfree(void*, size_t);
</span><span class="cx"> void* mbrealloc(void*, size_t, size_t);
</span><span class="cx"> void mbscavenge();
</span></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchmemaligncpp"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/memalign.cpp (0 => 178611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/memalign.cpp                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/memalign.cpp        2015-01-17 00:10:59 UTC (rev 178611)
</span><span class="lines">@@ -0,0 +1,56 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include &lt;assert.h&gt;
+#include &quot;memalign.h&quot;
+#include &lt;memory&gt;
+#include &lt;stddef.h&gt;
+
+#include &quot;mbmalloc.h&quot;
+
+void benchmark_memalign(bool isParallel)
+{
+    {
+        size_t alignment = 128;
+        size_t size = 8;
+        void* result = mbmemalign(alignment, size);
+
+        assert(result);
+        assert(((uintptr_t)result &amp; (alignment - 1)) == 0);
+        
+        mbfree(result, size);
+    }
+    
+    {
+        size_t alignment = 2048 * 1024 * 1024;
+        size_t size = 8;
+        void* result = mbmemalign(alignment, size);
+
+        assert(result);
+        assert(((uintptr_t)result &amp; (alignment - 1)) == 0);
+        
+        mbfree(result, size);
+    }
+}
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchmemalignh"></a>
<div class="addfile"><h4>Added: trunk/PerformanceTests/MallocBench/MallocBench/memalign.h (0 => 178611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench/memalign.h                                (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/memalign.h        2015-01-17 00:10:59 UTC (rev 178611)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef memalign_h
+#define memalign_h
+
+void benchmark_memalign(bool isParallel);
+
+#endif // memalign_h
+
</ins></span></pre></div>
<a id="trunkPerformanceTestsMallocBenchMallocBenchxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/PerformanceTests/MallocBench/MallocBench.xcodeproj/project.pbxproj (178610 => 178611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/MallocBench/MallocBench.xcodeproj/project.pbxproj        2015-01-17 00:10:18 UTC (rev 178610)
+++ trunk/PerformanceTests/MallocBench/MallocBench.xcodeproj/project.pbxproj        2015-01-17 00:10:59 UTC (rev 178611)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx">                 14CC393C18EA812B004AFE34 /* libmbmalloc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 14CC393818EA811F004AFE34 /* libmbmalloc.dylib */; settings = {ATTRIBUTES = (Required, ); }; };
</span><span class="cx">                 14CC393F18EA8184004AFE34 /* mbmalloc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14CC391C18EA6759004AFE34 /* mbmalloc.cpp */; };
</span><span class="cx">                 14CE4A6017BD355800288DAA /* big.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14CE4A5E17BD355800288DAA /* big.cpp */; };
</span><ins>+                14D6322E1A69BE0B00A8F84F /* memalign.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14D6322C1A69BE0B00A8F84F /* memalign.cpp */; };
</ins><span class="cx">                 14E11932177ECC8B003A8D15 /* CPUCount.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14E11930177ECC8B003A8D15 /* CPUCount.cpp */; };
</span><span class="cx">                 14FCA36119A7C917001CFDA9 /* stress.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14FCA35F19A7C917001CFDA9 /* stress.cpp */; };
</span><span class="cx"> /* End PBXBuildFile section */
</span><span class="lines">@@ -103,6 +104,8 @@
</span><span class="cx">                 14CC393818EA811F004AFE34 /* libmbmalloc.dylib */ = {isa = PBXFileReference; explicitFileType = &quot;compiled.mach-o.dylib&quot;; includeInIndex = 0; path = libmbmalloc.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
</span><span class="cx">                 14CE4A5E17BD355800288DAA /* big.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = big.cpp; path = MallocBench/big.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 14CE4A5F17BD355800288DAA /* big.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = big.h; path = MallocBench/big.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                14D6322C1A69BE0B00A8F84F /* memalign.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = memalign.cpp; path = MallocBench/memalign.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                14D6322D1A69BE0B00A8F84F /* memalign.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = memalign.h; path = MallocBench/memalign.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 14E11930177ECC8B003A8D15 /* CPUCount.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CPUCount.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 14E11931177ECC8B003A8D15 /* CPUCount.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CPUCount.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 14E11934177F5219003A8D15 /* mbmalloc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mbmalloc.h; path = MallocBench/mbmalloc.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -205,6 +208,8 @@
</span><span class="cx">                                 14976EC7177E3649006B819A /* list.h */,
</span><span class="cx">                                 1451FAEB18B14B7100DB6D47 /* medium.cpp */,
</span><span class="cx">                                 1451FAEC18B14B7100DB6D47 /* medium.h */,
</span><ins>+                                14D6322C1A69BE0B00A8F84F /* memalign.cpp */,
+                                14D6322D1A69BE0B00A8F84F /* memalign.h */,
</ins><span class="cx">                                 1444AE94177E8DF200F8030A /* message.cpp */,
</span><span class="cx">                                 1444AE95177E8DF200F8030A /* message.h */,
</span><span class="cx">                                 14105E8018E13EEC003A106E /* realloc.cpp */,
</span><span class="lines">@@ -319,6 +324,7 @@
</span><span class="cx">                                 14C5009318403DA0007A531D /* Interpreter.cpp in Sources */,
</span><span class="cx">                                 1447AE9118FB584200B3D7FF /* reddit.cpp in Sources */,
</span><span class="cx">                                 14E11932177ECC8B003A8D15 /* CPUCount.cpp in Sources */,
</span><ins>+                                14D6322E1A69BE0B00A8F84F /* memalign.cpp in Sources */,
</ins><span class="cx">                                 1444AE93177E79BB00F8030A /* fragment.cpp in Sources */,
</span><span class="cx">                                 14105E8218E13EEC003A106E /* realloc.cpp in Sources */,
</span><span class="cx">                                 14105E7F18DF7D73003A106E /* balloon.cpp in Sources */,
</span></span></pre>
</div>
</div>

</body>
</html>