<!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>[197441] trunk/Source</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/197441">197441</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-03-01 22:56:36 -0800 (Tue, 01 Mar 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Unreviewed, rolling out <a href="http://trac.webkit.org/projects/webkit/changeset/197226">r197226</a> and <a href="http://trac.webkit.org/projects/webkit/changeset/197256">r197256</a>.
https://bugs.webkit.org/show_bug.cgi?id=154910
Caused crashes on Mac 32-bit and on ARM (Requested by ap on
#webkit).
Reverted changesets:
"Remove the on demand executable allocator"
https://bugs.webkit.org/show_bug.cgi?id=154749
http://trac.webkit.org/changeset/197226
"CLoop build fix."
http://trac.webkit.org/changeset/197256</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreCMakeListstxt">trunk/Source/JavaScriptCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreJavaScriptCorevcxprojJavaScriptCorevcxproj">trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj</a></li>
<li><a href="#trunkSourceJavaScriptCoreJavaScriptCorevcxprojJavaScriptCorevcxprojfilters">trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters</a></li>
<li><a href="#trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj">trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceJavaScriptCorejitExecutableAllocatorh">trunk/Source/JavaScriptCore/jit/ExecutableAllocator.h</a></li>
<li><a href="#trunkSourceJavaScriptCorejitExecutableAllocatorFixedVMPoolcpp">trunk/Source/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITStubRoutineh">trunk/Source/JavaScriptCore/jit/JITStubRoutine.h</a></li>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfPlatformh">trunk/Source/WTF/wtf/Platform.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCorejitExecutableAllocatorcpp">trunk/Source/JavaScriptCore/jit/ExecutableAllocator.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/CMakeLists.txt (197440 => 197441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/CMakeLists.txt        2016-03-02 06:53:50 UTC (rev 197440)
+++ trunk/Source/JavaScriptCore/CMakeLists.txt        2016-03-02 06:56:36 UTC (rev 197441)
</span><span class="lines">@@ -515,6 +515,7 @@
</span><span class="cx"> jit/CallFrameShuffler32_64.cpp
</span><span class="cx"> jit/CallFrameShuffler64.cpp
</span><span class="cx"> jit/ExecutableAllocationFuzz.cpp
</span><ins>+ jit/ExecutableAllocator.cpp
</ins><span class="cx"> jit/ExecutableAllocatorFixedVMPool.cpp
</span><span class="cx"> jit/GCAwareJITStubRoutine.cpp
</span><span class="cx"> jit/GPRInfo.cpp
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (197440 => 197441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-03-02 06:53:50 UTC (rev 197440)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-03-02 06:56:36 UTC (rev 197441)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2016-03-01 Commit Queue <commit-queue@webkit.org>
+
+ Unreviewed, rolling out r197226 and r197256.
+ https://bugs.webkit.org/show_bug.cgi?id=154910
+
+ Caused crashes on Mac 32-bit and on ARM (Requested by ap on
+ #webkit).
+
+ Reverted changesets:
+
+ "Remove the on demand executable allocator"
+ https://bugs.webkit.org/show_bug.cgi?id=154749
+ http://trac.webkit.org/changeset/197226
+
+ "CLoop build fix."
+ http://trac.webkit.org/changeset/197256
+
</ins><span class="cx"> 2016-03-01 Joseph Pecoraro <pecoraro@apple.com>
</span><span class="cx">
</span><span class="cx"> Simplify some StringBuilder appends
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorevcxprojJavaScriptCorevcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj (197440 => 197441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj        2016-03-02 06:53:50 UTC (rev 197440)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj        2016-03-02 06:56:36 UTC (rev 197441)
</span><span class="lines">@@ -635,6 +635,7 @@
</span><span class="cx"> <ClCompile Include="..\jit\CallFrameShuffler32_64.cpp" />
</span><span class="cx"> <ClCompile Include="..\jit\CallFrameShuffler64.cpp" />
</span><span class="cx"> <ClCompile Include="..\jit\ExecutableAllocationFuzz.cpp" />
</span><ins>+ <ClCompile Include="..\jit\ExecutableAllocator.cpp" />
</ins><span class="cx"> <ClCompile Include="..\jit\ExecutableAllocatorFixedVMPool.cpp" />
</span><span class="cx"> <ClCompile Include="..\jit\GCAwareJITStubRoutine.cpp" />
</span><span class="cx"> <ClCompile Include="..\jit\HostCallReturnValue.cpp" />
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorevcxprojJavaScriptCorevcxprojfilters"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters (197440 => 197441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters        2016-03-02 06:53:50 UTC (rev 197440)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters        2016-03-02 06:56:36 UTC (rev 197441)
</span><span class="lines">@@ -390,6 +390,9 @@
</span><span class="cx"> <ClCompile Include="..\interpreter\StackVisitor.cpp">
</span><span class="cx"> <Filter>interpreter</Filter>
</span><span class="cx"> </ClCompile>
</span><ins>+ <ClCompile Include="..\jit\ExecutableAllocator.cpp">
+ <Filter>jit</Filter>
+ </ClCompile>
</ins><span class="cx"> <ClCompile Include="..\jit\GCAwareJITStubRoutine.cpp">
</span><span class="cx"> <Filter>jit</Filter>
</span><span class="cx"> </ClCompile>
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (197440 => 197441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2016-03-02 06:53:50 UTC (rev 197440)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2016-03-02 06:56:36 UTC (rev 197441)
</span><span class="lines">@@ -1758,6 +1758,7 @@
</span><span class="cx">                 A7A8AF4017ADB5F3005AB174 /* Uint8ClampedArray.h in Headers */ = {isa = PBXBuildFile; fileRef = A7A8AF3117ADB5F3005AB174 /* Uint8ClampedArray.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 A7A8AF4117ADB5F3005AB174 /* Uint16Array.h in Headers */ = {isa = PBXBuildFile; fileRef = A7A8AF3217ADB5F3005AB174 /* Uint16Array.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 A7A8AF4217ADB5F3005AB174 /* Uint32Array.h in Headers */ = {isa = PBXBuildFile; fileRef = A7A8AF3317ADB5F3005AB174 /* Uint32Array.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                A7B48F490EE8936F00DCBDB6 /* ExecutableAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7B48DB60EE74CFC00DCBDB6 /* ExecutableAllocator.cpp */; };
</ins><span class="cx">                 A7B4ACAF1484C9CE00B38A36 /* JSExportMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = A7B4ACAE1484C9CE00B38A36 /* JSExportMacros.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 A7B601821639FD2A00372BA3 /* UnlinkedCodeBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = A79E781F15EECBA80047C855 /* UnlinkedCodeBlock.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 A7BDAEC817F4EA1400F6140C /* ArrayIteratorPrototype.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7BDAEC217F4EA1400F6140C /* ArrayIteratorPrototype.cpp */; };
</span><span class="lines">@@ -3948,6 +3949,7 @@
</span><span class="cx">                 A7A8AF3317ADB5F3005AB174 /* Uint32Array.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Uint32Array.h; sourceTree = "<group>"; };
</span><span class="cx">                 A7A979C418BE8D9E002C3733 /* FunctionPrototype.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = FunctionPrototype.js; sourceTree = "<group>"; };
</span><span class="cx">                 A7B48DB50EE74CFC00DCBDB6 /* ExecutableAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExecutableAllocator.h; sourceTree = "<group>"; };
</span><ins>+                A7B48DB60EE74CFC00DCBDB6 /* ExecutableAllocator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExecutableAllocator.cpp; sourceTree = "<group>"; };
</ins><span class="cx">                 A7B4ACAE1484C9CE00B38A36 /* JSExportMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSExportMacros.h; sourceTree = "<group>"; };
</span><span class="cx">                 A7BDAEC217F4EA1400F6140C /* ArrayIteratorPrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = ArrayIteratorPrototype.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
</span><span class="cx">                 A7BDAEC317F4EA1400F6140C /* ArrayIteratorPrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArrayIteratorPrototype.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -4942,6 +4944,7 @@
</span><span class="cx">                                 0FD82E37141AB14200179C94 /* CompactJITCodeMap.h */,
</span><span class="cx">                                 0FF054F71AC35B4400E5BE57 /* ExecutableAllocationFuzz.cpp */,
</span><span class="cx">                                 0FF054F81AC35B4400E5BE57 /* ExecutableAllocationFuzz.h */,
</span><ins>+                                A7B48DB60EE74CFC00DCBDB6 /* ExecutableAllocator.cpp */,
</ins><span class="cx">                                 A7B48DB50EE74CFC00DCBDB6 /* ExecutableAllocator.h */,
</span><span class="cx">                                 86DB64630F95C6FC00D7D921 /* ExecutableAllocatorFixedVMPool.cpp */,
</span><span class="cx">                                 0F24E53E17EA9F5900ABB217 /* FPRInfo.h */,
</span><span class="lines">@@ -8850,6 +8853,7 @@
</span><span class="cx">                                 1429D8780ED21ACD00B89619 /* ExceptionHelpers.cpp in Sources */,
</span><span class="cx">                                 86CA032E1038E8440028A609 /* Executable.cpp in Sources */,
</span><span class="cx">                                 0FF054F91AC35B4400E5BE57 /* ExecutableAllocationFuzz.cpp in Sources */,
</span><ins>+                                A7B48F490EE8936F00DCBDB6 /* ExecutableAllocator.cpp in Sources */,
</ins><span class="cx">                                 86DB64640F95C6FC00D7D921 /* ExecutableAllocatorFixedVMPool.cpp in Sources */,
</span><span class="cx">                                 0F56A1D515001CF4002992B1 /* ExecutionCounter.cpp in Sources */,
</span><span class="cx">                                 0F0332C018ADFAE1005F979A /* ExitingJITType.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitExecutableAllocatorcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/jit/ExecutableAllocator.cpp (0 => 197441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/ExecutableAllocator.cpp         (rev 0)
+++ trunk/Source/JavaScriptCore/jit/ExecutableAllocator.cpp        2016-03-02 06:56:36 UTC (rev 197441)
</span><span class="lines">@@ -0,0 +1,275 @@
</span><ins>+/*
+ * Copyright (C) 2008 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 "config.h"
+#include "ExecutableAllocator.h"
+
+#include "JSCInlines.h"
+
+#if ENABLE(EXECUTABLE_ALLOCATOR_DEMAND)
+#include "CodeProfiling.h"
+#include <wtf/HashSet.h>
+#include <wtf/Lock.h>
+#include <wtf/MetaAllocator.h>
+#include <wtf/NeverDestroyed.h>
+#include <wtf/PageReservation.h>
+#include <wtf/VMTags.h>
+#endif
+
+// Uncomment to create an artificial executable memory usage limit. This limit
+// is imperfect and is primarily useful for testing the VM's ability to handle
+// out-of-executable-memory situations.
+// #define EXECUTABLE_MEMORY_LIMIT 1000000
+
+#if ENABLE(ASSEMBLER)
+
+using namespace WTF;
+
+namespace JSC {
+
+#if ENABLE(EXECUTABLE_ALLOCATOR_DEMAND)
+
+class DemandExecutableAllocator : public MetaAllocator {
+public:
+ DemandExecutableAllocator()
+ : MetaAllocator(jitAllocationGranule)
+ {
+ std::lock_guard<StaticLock> lock(allocatorsMutex());
+ allocators().add(this);
+ // Don't preallocate any memory here.
+ }
+
+ virtual ~DemandExecutableAllocator()
+ {
+ {
+ std::lock_guard<StaticLock> lock(allocatorsMutex());
+ allocators().remove(this);
+ }
+ for (unsigned i = 0; i < reservations.size(); ++i)
+ reservations.at(i).deallocate();
+ }
+
+ static size_t bytesAllocatedByAllAllocators()
+ {
+ size_t total = 0;
+ std::lock_guard<StaticLock> lock(allocatorsMutex());
+ for (HashSet<DemandExecutableAllocator*>::const_iterator allocator = allocators().begin(); allocator != allocators().end(); ++allocator)
+ total += (*allocator)->bytesAllocated();
+ return total;
+ }
+
+ static size_t bytesCommittedByAllocactors()
+ {
+ size_t total = 0;
+ std::lock_guard<StaticLock> lock(allocatorsMutex());
+ for (HashSet<DemandExecutableAllocator*>::const_iterator allocator = allocators().begin(); allocator != allocators().end(); ++allocator)
+ total += (*allocator)->bytesCommitted();
+ return total;
+ }
+
+#if ENABLE(META_ALLOCATOR_PROFILE)
+ static void dumpProfileFromAllAllocators()
+ {
+ std::lock_guard<StaticLock> lock(allocatorsMutex());
+ for (HashSet<DemandExecutableAllocator*>::const_iterator allocator = allocators().begin(); allocator != allocators().end(); ++allocator)
+ (*allocator)->dumpProfile();
+ }
+#endif
+
+protected:
+ virtual void* allocateNewSpace(size_t& numPages)
+ {
+ size_t newNumPages = (((numPages * pageSize() + JIT_ALLOCATOR_LARGE_ALLOC_SIZE - 1) / JIT_ALLOCATOR_LARGE_ALLOC_SIZE * JIT_ALLOCATOR_LARGE_ALLOC_SIZE) + pageSize() - 1) / pageSize();
+
+ ASSERT(newNumPages >= numPages);
+
+ numPages = newNumPages;
+
+#ifdef EXECUTABLE_MEMORY_LIMIT
+ if (bytesAllocatedByAllAllocators() >= EXECUTABLE_MEMORY_LIMIT)
+ return 0;
+#endif
+
+ PageReservation reservation = PageReservation::reserve(numPages * pageSize(), OSAllocator::JSJITCodePages, EXECUTABLE_POOL_WRITABLE, true);
+ RELEASE_ASSERT(reservation);
+
+ reservations.append(reservation);
+
+ return reservation.base();
+ }
+
+ virtual void notifyNeedPage(void* page)
+ {
+ OSAllocator::commit(page, pageSize(), EXECUTABLE_POOL_WRITABLE, true);
+ }
+
+ virtual void notifyPageIsFree(void* page)
+ {
+ OSAllocator::decommit(page, pageSize());
+ }
+
+private:
+ Vector<PageReservation, 16> reservations;
+ static HashSet<DemandExecutableAllocator*>& allocators()
+ {
+ static NeverDestroyed<HashSet<DemandExecutableAllocator*>> set;
+ return set;
+ }
+
+ static StaticLock& allocatorsMutex()
+ {
+ static StaticLock mutex;
+
+ return mutex;
+ }
+};
+
+#if ENABLE(ASSEMBLER_WX_EXCLUSIVE)
+void ExecutableAllocator::initializeAllocator()
+{
+}
+#else
+static DemandExecutableAllocator* gAllocator;
+
+namespace {
+static inline DemandExecutableAllocator* allocator()
+{
+ return gAllocator;
+}
+}
+
+void ExecutableAllocator::initializeAllocator()
+{
+ ASSERT(!gAllocator);
+ gAllocator = new DemandExecutableAllocator();
+ CodeProfiling::notifyAllocator(gAllocator);
+}
+#endif
+
+ExecutableAllocator::ExecutableAllocator(VM&)
+#if ENABLE(ASSEMBLER_WX_EXCLUSIVE)
+ : m_allocator(std::make_unique<DemandExecutableAllocator>())
+#endif
+{
+ ASSERT(allocator());
+}
+
+ExecutableAllocator::~ExecutableAllocator()
+{
+}
+
+bool ExecutableAllocator::isValid() const
+{
+ return true;
+}
+
+bool ExecutableAllocator::underMemoryPressure()
+{
+#ifdef EXECUTABLE_MEMORY_LIMIT
+ return DemandExecutableAllocator::bytesAllocatedByAllAllocators() > EXECUTABLE_MEMORY_LIMIT / 2;
+#else
+ return false;
+#endif
+}
+
+double ExecutableAllocator::memoryPressureMultiplier(size_t addedMemoryUsage)
+{
+ double result;
+#ifdef EXECUTABLE_MEMORY_LIMIT
+ size_t bytesAllocated = DemandExecutableAllocator::bytesAllocatedByAllAllocators() + addedMemoryUsage;
+ if (bytesAllocated >= EXECUTABLE_MEMORY_LIMIT)
+ bytesAllocated = EXECUTABLE_MEMORY_LIMIT;
+ result = static_cast<double>(EXECUTABLE_MEMORY_LIMIT) /
+ (EXECUTABLE_MEMORY_LIMIT - bytesAllocated);
+#else
+ UNUSED_PARAM(addedMemoryUsage);
+ result = 1.0;
+#endif
+ if (result < 1.0)
+ result = 1.0;
+ return result;
+
+}
+
+RefPtr<ExecutableMemoryHandle> ExecutableAllocator::allocate(VM&, size_t sizeInBytes, void* ownerUID, JITCompilationEffort effort)
+{
+ RefPtr<ExecutableMemoryHandle> result = allocator()->allocate(sizeInBytes, ownerUID);
+ RELEASE_ASSERT(result || effort != JITCompilationMustSucceed);
+ return result;
+}
+
+size_t ExecutableAllocator::committedByteCount()
+{
+ return DemandExecutableAllocator::bytesCommittedByAllocactors();
+}
+
+#if ENABLE(META_ALLOCATOR_PROFILE)
+void ExecutableAllocator::dumpProfile()
+{
+ DemandExecutableAllocator::dumpProfileFromAllAllocators();
+}
+#endif
+
+Lock& ExecutableAllocator::getLock() const
+{
+ return gAllocator->getLock();
+}
+
+bool ExecutableAllocator::isValidExecutableMemory(const LockHolder& locker, void* address)
+{
+ return gAllocator->isInAllocatedMemory(locker, address);
+}
+
+#endif // ENABLE(EXECUTABLE_ALLOCATOR_DEMAND)
+
+#if ENABLE(ASSEMBLER_WX_EXCLUSIVE)
+
+#if OS(WINDOWS)
+#error "ASSEMBLER_WX_EXCLUSIVE not yet suported on this platform."
+#endif
+
+void ExecutableAllocator::reprotectRegion(void* start, size_t size, ProtectionSetting setting)
+{
+ size_t pageSize = WTF::pageSize();
+
+ // Calculate the start of the page containing this region,
+ // and account for this extra memory within size.
+ intptr_t startPtr = reinterpret_cast<intptr_t>(start);
+ intptr_t pageStartPtr = startPtr & ~(pageSize - 1);
+ void* pageStart = reinterpret_cast<void*>(pageStartPtr);
+ size += (startPtr - pageStartPtr);
+
+ // Round size up
+ size += (pageSize - 1);
+ size &= ~(pageSize - 1);
+
+ mprotect(pageStart, size, (setting == Writable) ? PROTECTION_FLAGS_RW : PROTECTION_FLAGS_RX);
+}
+
+#endif
+
+}
+
+#endif // HAVE(ASSEMBLER)
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCorejitExecutableAllocatorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/ExecutableAllocator.h (197440 => 197441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/ExecutableAllocator.h        2016-03-02 06:53:50 UTC (rev 197440)
+++ trunk/Source/JavaScriptCore/jit/ExecutableAllocator.h        2016-03-02 06:56:36 UTC (rev 197441)
</span><span class="lines">@@ -69,6 +69,11 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(ASSEMBLER)
</span><span class="cx">
</span><ins>+#if ENABLE(EXECUTABLE_ALLOCATOR_DEMAND)
+class DemandExecutableAllocator;
+#endif
+
+#if ENABLE(EXECUTABLE_ALLOCATOR_FIXED)
</ins><span class="cx"> #if CPU(ARM)
</span><span class="cx"> static const size_t fixedExecutableMemoryPoolSize = 16 * 1024 * 1024;
</span><span class="cx"> #elif CPU(ARM64)
</span><span class="lines">@@ -85,6 +90,7 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> extern uintptr_t startOfFixedExecutableMemoryPool;
</span><ins>+#endif
</ins><span class="cx">
</span><span class="cx"> class ExecutableAllocator {
</span><span class="cx"> enum ProtectionSetting { Writable, Executable };
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitExecutableAllocatorFixedVMPoolcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp (197440 => 197441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp        2016-03-02 06:53:50 UTC (rev 197440)
+++ trunk/Source/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp        2016-03-02 06:56:36 UTC (rev 197441)
</span><span class="lines">@@ -26,10 +26,10 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "ExecutableAllocator.h"
</span><span class="cx">
</span><del>-#if ENABLE(ASSEMBLER)
-
</del><span class="cx"> #include "JSCInlines.h"
</span><span class="cx">
</span><ins>+#if ENABLE(EXECUTABLE_ALLOCATOR_FIXED)
+
</ins><span class="cx"> #include "CodeProfiling.h"
</span><span class="cx"> #include "ExecutableAllocationFuzz.h"
</span><span class="cx"> #include <errno.h>
</span><span class="lines">@@ -223,4 +223,5 @@
</span><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#endif
</del><ins>+
+#endif // ENABLE(EXECUTABLE_ALLOCATOR_FIXED)
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITStubRoutineh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITStubRoutine.h (197440 => 197441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITStubRoutine.h        2016-03-02 06:53:50 UTC (rev 197440)
+++ trunk/Source/JavaScriptCore/jit/JITStubRoutine.h        2016-03-02 06:56:36 UTC (rev 197441)
</span><span class="lines">@@ -103,15 +103,29 @@
</span><span class="cx">
</span><span class="cx"> static bool canPerformRangeFilter()
</span><span class="cx"> {
</span><ins>+#if ENABLE(EXECUTABLE_ALLOCATOR_FIXED)
</ins><span class="cx"> return true;
</span><ins>+#else
+ return false;
+#endif
</ins><span class="cx"> }
</span><span class="cx"> static uintptr_t filteringStartAddress()
</span><span class="cx"> {
</span><ins>+#if ENABLE(EXECUTABLE_ALLOCATOR_FIXED)
</ins><span class="cx"> return startOfFixedExecutableMemoryPool;
</span><ins>+#else
+ UNREACHABLE_FOR_PLATFORM();
+ return 0;
+#endif
</ins><span class="cx"> }
</span><span class="cx"> static size_t filteringExtentSize()
</span><span class="cx"> {
</span><ins>+#if ENABLE(EXECUTABLE_ALLOCATOR_FIXED)
</ins><span class="cx"> return fixedExecutableMemoryPoolSize;
</span><ins>+#else
+ UNREACHABLE_FOR_PLATFORM();
+ return 0;
+#endif
</ins><span class="cx"> }
</span><span class="cx"> static bool passesFilter(uintptr_t address)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (197440 => 197441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2016-03-02 06:53:50 UTC (rev 197440)
+++ trunk/Source/WTF/ChangeLog        2016-03-02 06:56:36 UTC (rev 197441)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2016-03-01 Commit Queue <commit-queue@webkit.org>
+
+ Unreviewed, rolling out r197226 and r197256.
+ https://bugs.webkit.org/show_bug.cgi?id=154910
+
+ Caused crashes on Mac 32-bit and on ARM (Requested by ap on
+ #webkit).
+
+ Reverted changesets:
+
+ "Remove the on demand executable allocator"
+ https://bugs.webkit.org/show_bug.cgi?id=154749
+ http://trac.webkit.org/changeset/197226
+
+ "CLoop build fix."
+ http://trac.webkit.org/changeset/197256
+
</ins><span class="cx"> 2016-03-01 Alex Christensen <achristensen@webkit.org>
</span><span class="cx">
</span><span class="cx"> Reduce size of internal windows build output
</span></span></pre></div>
<a id="trunkSourceWTFwtfPlatformh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/Platform.h (197440 => 197441)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/Platform.h        2016-03-02 06:53:50 UTC (rev 197440)
+++ trunk/Source/WTF/wtf/Platform.h        2016-03-02 06:56:36 UTC (rev 197441)
</span><span class="lines">@@ -882,6 +882,16 @@
</span><span class="cx"> #define ENABLE_MASM_PROBE 0
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+/* Pick which allocator to use; we only need an executable allocator if the assembler is compiled in.
+ On non-Windows x86-64, iOS, and ARM64 we use a single fixed mmap, on other platforms we mmap on demand. */
+#if ENABLE(ASSEMBLER)
+#if CPU(X86_64) || PLATFORM(IOS) || CPU(ARM64)
+#define ENABLE_EXECUTABLE_ALLOCATOR_FIXED 1
+#else
+#define ENABLE_EXECUTABLE_ALLOCATOR_DEMAND 1
+#endif
+#endif
+
</ins><span class="cx"> /* CSS Selector JIT Compiler */
</span><span class="cx"> #if !defined(ENABLE_CSS_SELECTOR_JIT)
</span><span class="cx"> #if (CPU(X86_64) || CPU(ARM64) || (CPU(ARM_THUMB2) && PLATFORM(IOS))) && ENABLE(JIT) && (OS(DARWIN) || PLATFORM(GTK) || PLATFORM(EFL))
</span></span></pre>
</div>
</div>
</body>
</html>