<!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>[164393] trunk/Source/JavaScriptCore</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/164393">164393</a></dd>
<dt>Author</dt> <dd>fpizlo@apple.com</dd>
<dt>Date</dt> <dd>2014-02-19 15:11:06 -0800 (Wed, 19 Feb 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>FTL should allow LLVM to allocate data sections with alignment > 8
https://bugs.webkit.org/show_bug.cgi?id=129066
Reviewed by Geoffrey Garen.
We were previously using the native allocator's alignment guarantees (which we presumed
to be 8 bytes), and further hinting our desires by using the LSectionWord type (which
was 8 bytes). This breaks now that LLVM will sometimes ask for 16 byte alignment on
some sections.
This changes our data section allocation strategy to use the new FTL::DataSection,
which can handle arbitrary 2^k alignment.
* JavaScriptCore.xcodeproj/project.pbxproj:
* ftl/FTLCompile.cpp:
(JSC::FTL::mmAllocateDataSection):
(JSC::FTL::dumpDataSection):
(JSC::FTL::compile):
* ftl/FTLDataSection.cpp: Added.
(JSC::FTL::DataSection::DataSection):
(JSC::FTL::DataSection::~DataSection):
* ftl/FTLDataSection.h: Added.
(JSC::FTL::DataSection::base):
(JSC::FTL::DataSection::size):
* ftl/FTLJITCode.cpp:
(JSC::FTL::JITCode::addDataSection):
* ftl/FTLJITCode.h:
(JSC::FTL::JITCode::dataSections):
* ftl/FTLState.h:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj">trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLCompilecpp">trunk/Source/JavaScriptCore/ftl/FTLCompile.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLJITCodecpp">trunk/Source/JavaScriptCore/ftl/FTLJITCode.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLJITCodeh">trunk/Source/JavaScriptCore/ftl/FTLJITCode.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLStateh">trunk/Source/JavaScriptCore/ftl/FTLState.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreftlFTLDataSectioncpp">trunk/Source/JavaScriptCore/ftl/FTLDataSection.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLDataSectionh">trunk/Source/JavaScriptCore/ftl/FTLDataSection.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (164392 => 164393)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2014-02-19 23:04:36 UTC (rev 164392)
+++ trunk/Source/JavaScriptCore/ChangeLog        2014-02-19 23:11:06 UTC (rev 164393)
</span><span class="lines">@@ -1,5 +1,37 @@
</span><span class="cx"> 2014-02-19 Filip Pizlo <fpizlo@apple.com>
</span><span class="cx">
</span><ins>+ FTL should allow LLVM to allocate data sections with alignment > 8
+ https://bugs.webkit.org/show_bug.cgi?id=129066
+
+ Reviewed by Geoffrey Garen.
+
+ We were previously using the native allocator's alignment guarantees (which we presumed
+ to be 8 bytes), and further hinting our desires by using the LSectionWord type (which
+ was 8 bytes). This breaks now that LLVM will sometimes ask for 16 byte alignment on
+ some sections.
+
+ This changes our data section allocation strategy to use the new FTL::DataSection,
+ which can handle arbitrary 2^k alignment.
+
+ * JavaScriptCore.xcodeproj/project.pbxproj:
+ * ftl/FTLCompile.cpp:
+ (JSC::FTL::mmAllocateDataSection):
+ (JSC::FTL::dumpDataSection):
+ (JSC::FTL::compile):
+ * ftl/FTLDataSection.cpp: Added.
+ (JSC::FTL::DataSection::DataSection):
+ (JSC::FTL::DataSection::~DataSection):
+ * ftl/FTLDataSection.h: Added.
+ (JSC::FTL::DataSection::base):
+ (JSC::FTL::DataSection::size):
+ * ftl/FTLJITCode.cpp:
+ (JSC::FTL::JITCode::addDataSection):
+ * ftl/FTLJITCode.h:
+ (JSC::FTL::JITCode::dataSections):
+ * ftl/FTLState.h:
+
+2014-02-19 Filip Pizlo <fpizlo@apple.com>
+
</ins><span class="cx"> Unreviewed, fix comment.
</span><span class="cx">
</span><span class="cx"> * ftl/FTLWeight.h:
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (164392 => 164393)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2014-02-19 23:04:36 UTC (rev 164392)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2014-02-19 23:11:06 UTC (rev 164393)
</span><span class="lines">@@ -500,6 +500,8 @@
</span><span class="cx">                 0FE228EE1436AB2C00196C48 /* Options.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FE228EA1436AB2300196C48 /* Options.cpp */; };
</span><span class="cx">                 0FE8534B1723CDA500B618F5 /* DFGDesiredWatchpoints.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FE853491723CDA500B618F5 /* DFGDesiredWatchpoints.cpp */; };
</span><span class="cx">                 0FE8534C1723CDA500B618F5 /* DFGDesiredWatchpoints.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FE8534A1723CDA500B618F5 /* DFGDesiredWatchpoints.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                0FE95F7918B5694700B531FB /* FTLDataSection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FE95F7718B5694700B531FB /* FTLDataSection.cpp */; };
+                0FE95F7A18B5694700B531FB /* FTLDataSection.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FE95F7818B5694700B531FB /* FTLDataSection.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 0FEA0A08170513DB00BB722C /* FTLAbbreviations.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FEA09FD170513DB00BB722C /* FTLAbbreviations.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 0FEA0A09170513DB00BB722C /* FTLCapabilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FEA09FE170513DB00BB722C /* FTLCapabilities.cpp */; };
</span><span class="cx">                 0FEA0A0A170513DB00BB722C /* FTLCapabilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FEA09FF170513DB00BB722C /* FTLCapabilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -1984,6 +1986,8 @@
</span><span class="cx">                 0FE228EB1436AB2300196C48 /* Options.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Options.h; sourceTree = "<group>"; };
</span><span class="cx">                 0FE853491723CDA500B618F5 /* DFGDesiredWatchpoints.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGDesiredWatchpoints.cpp; path = dfg/DFGDesiredWatchpoints.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 0FE8534A1723CDA500B618F5 /* DFGDesiredWatchpoints.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGDesiredWatchpoints.h; path = dfg/DFGDesiredWatchpoints.h; sourceTree = "<group>"; };
</span><ins>+                0FE95F7718B5694700B531FB /* FTLDataSection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FTLDataSection.cpp; path = ftl/FTLDataSection.cpp; sourceTree = "<group>"; };
+                0FE95F7818B5694700B531FB /* FTLDataSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FTLDataSection.h; path = ftl/FTLDataSection.h; sourceTree = "<group>"; };
</ins><span class="cx">                 0FEA09FD170513DB00BB722C /* FTLAbbreviations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FTLAbbreviations.h; path = ftl/FTLAbbreviations.h; sourceTree = "<group>"; };
</span><span class="cx">                 0FEA09FE170513DB00BB722C /* FTLCapabilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FTLCapabilities.cpp; path = ftl/FTLCapabilities.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 0FEA09FF170513DB00BB722C /* FTLCapabilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FTLCapabilities.h; path = ftl/FTLCapabilities.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -3173,6 +3177,8 @@
</span><span class="cx">                                 0FEA0A211709606900BB722C /* FTLCommonValues.h */,
</span><span class="cx">                                 0FEA0A00170513DB00BB722C /* FTLCompile.cpp */,
</span><span class="cx">                                 0FEA0A01170513DB00BB722C /* FTLCompile.h */,
</span><ins>+                                0FE95F7718B5694700B531FB /* FTLDataSection.cpp */,
+                                0FE95F7818B5694700B531FB /* FTLDataSection.h */,
</ins><span class="cx">                                 2AC922B918A16182003CE0FB /* FTLDWARFDebugLineInfo.cpp */,
</span><span class="cx">                                 2AC922BA18A16182003CE0FB /* FTLDWARFDebugLineInfo.h */,
</span><span class="cx">                                 0F235BBD17178E1C00690C7F /* FTLExitArgument.cpp */,
</span><span class="lines">@@ -4899,6 +4905,7 @@
</span><span class="cx">                                 C2C8D03014A3CEFC00578E65 /* CopiedBlock.h in Headers */,
</span><span class="cx">                                 C2FC9BD316644DFB00810D33 /* CopiedBlockInlines.h in Headers */,
</span><span class="cx">                                 C2EAA3FA149A835E00FCE112 /* CopiedSpace.h in Headers */,
</span><ins>+                                0FE95F7A18B5694700B531FB /* FTLDataSection.h in Headers */,
</ins><span class="cx">                                 C2C8D02D14A3C6E000578E65 /* CopiedSpaceInlines.h in Headers */,
</span><span class="cx">                                 0F5A52D017ADD717008ECB2D /* CopyToken.h in Headers */,
</span><span class="cx">                                 0F6B1CC61862C47800845D97 /* FTLUnwindInfo.h in Headers */,
</span><span class="lines">@@ -6139,6 +6146,7 @@
</span><span class="cx">                                 0FD82E56141DAF0800179C94 /* DFGOSREntry.cpp in Sources */,
</span><span class="cx">                                 0FD8A32517D51F5700CA2C40 /* DFGOSREntrypointCreationPhase.cpp in Sources */,
</span><span class="cx">                                 0FC09791146A6F7100CF2442 /* DFGOSRExit.cpp in Sources */,
</span><ins>+                                0FE95F7918B5694700B531FB /* FTLDataSection.cpp in Sources */,
</ins><span class="cx">                                 0F235BEB17178E7300690C7F /* DFGOSRExitBase.cpp in Sources */,
</span><span class="cx">                                 0FC09792146A6F7300CF2442 /* DFGOSRExitCompiler.cpp in Sources */,
</span><span class="cx">                                 0FC09776146943B000CF2442 /* DFGOSRExitCompiler32_64.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLCompilecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLCompile.cpp (164392 => 164393)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLCompile.cpp        2014-02-19 23:04:36 UTC (rev 164392)
+++ trunk/Source/JavaScriptCore/ftl/FTLCompile.cpp        2014-02-19 23:11:06 UTC (rev 164393)
</span><span class="lines">@@ -81,23 +81,20 @@
</span><span class="cx">
</span><span class="cx"> State& state = *static_cast<State*>(opaqueState);
</span><span class="cx">
</span><del>- RELEASE_ASSERT(alignment <= sizeof(LSectionWord));
</del><ins>+ RefPtr<DataSection> section = adoptRef(new DataSection(size, alignment));
</ins><span class="cx">
</span><del>- RefCountedArray<LSectionWord> section(
- (size + sizeof(LSectionWord) - 1) / sizeof(LSectionWord));
-
</del><span class="cx"> if (!strcmp(sectionName, "__llvm_stackmaps"))
</span><span class="cx"> state.stackmapsSection = section;
</span><span class="cx"> else {
</span><span class="cx"> state.jitCode->addDataSection(section);
</span><span class="cx"> state.dataSectionNames.append(sectionName);
</span><span class="cx"> if (!strcmp(sectionName, "__compact_unwind")) {
</span><del>- state.compactUnwind = section.data();
</del><ins>+ state.compactUnwind = section->base();
</ins><span class="cx"> state.compactUnwindSize = size;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- return bitwise_cast<uint8_t*>(section.data());
</del><ins>+ return bitwise_cast<uint8_t*>(section->base());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static LLVMBool mmApplyPermissions(void*, char**)
</span><span class="lines">@@ -109,12 +106,13 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void dumpDataSection(RefCountedArray<LSectionWord> section, const char* prefix)
</del><ins>+static void dumpDataSection(DataSection* section, const char* prefix)
</ins><span class="cx"> {
</span><del>- for (unsigned j = 0; j < section.size(); ++j) {
</del><ins>+ for (unsigned j = 0; j < section->size() / sizeof(int64_t); ++j) {
</ins><span class="cx"> char buf[32];
</span><del>- snprintf(buf, sizeof(buf), "0x%lx", static_cast<unsigned long>(bitwise_cast<uintptr_t>(section.data() + j)));
- dataLogF("%s%16s: 0x%016llx\n", prefix, buf, static_cast<long long>(section[j]));
</del><ins>+ int64_t* wordPointer = static_cast<int64_t*>(section->base()) + j;
+ snprintf(buf, sizeof(buf), "0x%lx", static_cast<unsigned long>(bitwise_cast<uintptr_t>(wordPointer)));
+ dataLogF("%s%16s: 0x%016llx\n", prefix, buf, static_cast<long long>(*wordPointer));
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -566,7 +564,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> for (unsigned i = 0; i < state.jitCode->dataSections().size(); ++i) {
</span><del>- const RefCountedArray<LSectionWord>& section = state.jitCode->dataSections()[i];
</del><ins>+ DataSection* section = state.jitCode->dataSections()[i].get();
</ins><span class="cx"> dataLog(
</span><span class="cx"> "Generated LLVM data section for ",
</span><span class="cx"> CodeBlockWithJITType(state.graph.m_codeBlock, JITCode::FTLJIT),
</span><span class="lines">@@ -580,17 +578,17 @@
</span><span class="cx"> if (shouldShowDisassembly())
</span><span class="cx"> dataLog("Unwind info for ", CodeBlockWithJITType(state.graph.m_codeBlock, JITCode::FTLJIT), ":\n ", state.jitCode->unwindInfo, "\n");
</span><span class="cx">
</span><del>- if (state.stackmapsSection.size()) {
</del><ins>+ if (state.stackmapsSection && state.stackmapsSection->size()) {
</ins><span class="cx"> if (shouldShowDisassembly()) {
</span><span class="cx"> dataLog(
</span><span class="cx"> "Generated LLVM stackmaps section for ",
</span><span class="cx"> CodeBlockWithJITType(state.graph.m_codeBlock, JITCode::FTLJIT), ":\n");
</span><span class="cx"> dataLog(" Raw data:\n");
</span><del>- dumpDataSection(state.stackmapsSection, " ");
</del><ins>+ dumpDataSection(state.stackmapsSection.get(), " ");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> RefPtr<DataView> stackmapsData = DataView::create(
</span><del>- ArrayBuffer::create(state.stackmapsSection.data(), state.stackmapsSection.byteSize()));
</del><ins>+ ArrayBuffer::create(state.stackmapsSection->base(), state.stackmapsSection->size()));
</ins><span class="cx"> state.jitCode->stackmaps.parse(stackmapsData.get());
</span><span class="cx">
</span><span class="cx"> if (shouldShowDisassembly()) {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLDataSectioncpp"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/ftl/FTLDataSection.cpp (0 => 164393)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLDataSection.cpp         (rev 0)
+++ trunk/Source/JavaScriptCore/ftl/FTLDataSection.cpp        2014-02-19 23:11:06 UTC (rev 164393)
</span><span class="lines">@@ -0,0 +1,64 @@
</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 "config.h"
+#include "FTLDataSection.h"
+
+#if ENABLE(FTL_JIT)
+
+#include <wtf/Assertions.h>
+#include <wtf/DataLog.h>
+#include <wtf/FastMalloc.h>
+
+namespace JSC { namespace FTL {
+
+DataSection::DataSection(size_t size, unsigned alignment)
+ : m_size(size)
+{
+ RELEASE_ASSERT(WTF::bitCount(alignment) == 1);
+
+ const unsigned nativeAlignment = 8;
+
+ alignment = std::max(nativeAlignment, alignment);
+
+ size_t allocatedSize = size + alignment - nativeAlignment;
+ m_allocationBase = fastMalloc(allocatedSize);
+
+ m_base = bitwise_cast<void*>(
+ (bitwise_cast<uintptr_t>(m_allocationBase) + alignment - 1) & ~static_cast<uintptr_t>(alignment - 1));
+
+ RELEASE_ASSERT(!(bitwise_cast<uintptr_t>(m_base) & (alignment - 1)));
+ RELEASE_ASSERT(bitwise_cast<uintptr_t>(m_base) + size <= bitwise_cast<uintptr_t>(m_allocationBase) + allocatedSize);
+}
+
+DataSection::~DataSection()
+{
+ fastFree(m_allocationBase);
+}
+
+} } // namespace JSC::FTL
+
+#endif // ENABLE(FTL_JIT)
+
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLDataSectionh"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/ftl/FTLDataSection.h (0 => 164393)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLDataSection.h         (rev 0)
+++ trunk/Source/JavaScriptCore/ftl/FTLDataSection.h        2014-02-19 23:11:06 UTC (rev 164393)
</span><span class="lines">@@ -0,0 +1,54 @@
</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 FTLDataSection_h
+#define FTLDataSection_h
+
+#if ENABLE(FTL_JIT)
+
+#include <wtf/RefCounted.h>
+
+namespace JSC { namespace FTL {
+
+class DataSection : public RefCounted<DataSection> {
+public:
+ DataSection(size_t size, unsigned alignment);
+ ~DataSection();
+
+ void* base() { return m_base; }
+ size_t size() const { return m_size; }
+
+private:
+ void* m_allocationBase;
+ void* m_base;
+ size_t m_size;
+};
+
+} } // namespace JSC::FTL
+
+#endif // ENABLE(FTL_JIT)
+
+#endif // FTLDataSection_h
+
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLJITCodecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLJITCode.cpp (164392 => 164393)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLJITCode.cpp        2014-02-19 23:04:36 UTC (rev 164392)
+++ trunk/Source/JavaScriptCore/ftl/FTLJITCode.cpp        2014-02-19 23:11:06 UTC (rev 164393)
</span><span class="lines">@@ -49,7 +49,7 @@
</span><span class="cx"> m_handles.append(handle);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void JITCode::addDataSection(RefCountedArray<LSectionWord> dataSection)
</del><ins>+void JITCode::addDataSection(PassRefPtr<DataSection> dataSection)
</ins><span class="cx"> {
</span><span class="cx"> m_dataSections.append(dataSection);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLJITCodeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLJITCode.h (164392 => 164393)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLJITCode.h        2014-02-19 23:04:36 UTC (rev 164392)
+++ trunk/Source/JavaScriptCore/ftl/FTLJITCode.h        2014-02-19 23:11:06 UTC (rev 164393)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #if ENABLE(FTL_JIT)
</span><span class="cx">
</span><span class="cx"> #include "DFGCommonData.h"
</span><ins>+#include "FTLDataSection.h"
</ins><span class="cx"> #include "FTLOSRExit.h"
</span><span class="cx"> #include "FTLStackMaps.h"
</span><span class="cx"> #include "FTLUnwindInfo.h"
</span><span class="lines">@@ -40,8 +41,6 @@
</span><span class="cx">
</span><span class="cx"> namespace JSC { namespace FTL {
</span><span class="cx">
</span><del>-typedef int64_t LSectionWord; // We refer to LLVM data sections using LSectionWord*, just to be clear about our intended alignment restrictions.
-
</del><span class="cx"> class JITCode : public JSC::JITCode {
</span><span class="cx"> public:
</span><span class="cx"> JITCode();
</span><span class="lines">@@ -56,12 +55,12 @@
</span><span class="cx">
</span><span class="cx"> void initializeExitThunks(CodeRef);
</span><span class="cx"> void addHandle(PassRefPtr<ExecutableMemoryHandle>);
</span><del>- void addDataSection(RefCountedArray<LSectionWord>);
</del><ins>+ void addDataSection(PassRefPtr<DataSection>);
</ins><span class="cx"> void initializeArityCheckEntrypoint(CodeRef);
</span><span class="cx"> void initializeAddressForCall(CodePtr);
</span><span class="cx">
</span><span class="cx"> const Vector<RefPtr<ExecutableMemoryHandle>>& handles() const { return m_handles; }
</span><del>- const Vector<RefCountedArray<LSectionWord>>& dataSections() const { return m_dataSections; }
</del><ins>+ const Vector<RefPtr<DataSection>>& dataSections() const { return m_dataSections; }
</ins><span class="cx">
</span><span class="cx"> CodePtr exitThunks();
</span><span class="cx">
</span><span class="lines">@@ -74,7 +73,7 @@
</span><span class="cx"> UnwindInfo unwindInfo;
</span><span class="cx">
</span><span class="cx"> private:
</span><del>- Vector<RefCountedArray<LSectionWord>> m_dataSections;
</del><ins>+ Vector<RefPtr<DataSection>> m_dataSections;
</ins><span class="cx"> Vector<RefPtr<ExecutableMemoryHandle>> m_handles;
</span><span class="cx"> CodePtr m_addressForCall;
</span><span class="cx"> CodeRef m_arityCheckEntrypoint;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLStateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLState.h (164392 => 164393)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLState.h        2014-02-19 23:04:36 UTC (rev 164392)
+++ trunk/Source/JavaScriptCore/ftl/FTLState.h        2014-02-19 23:11:06 UTC (rev 164393)
</span><span class="lines">@@ -79,7 +79,7 @@
</span><span class="cx"> Vector<CString> dataSectionNames;
</span><span class="cx"> void* compactUnwind;
</span><span class="cx"> size_t compactUnwindSize;
</span><del>- RefCountedArray<LSectionWord> stackmapsSection;
</del><ins>+ RefPtr<DataSection> stackmapsSection;
</ins><span class="cx">
</span><span class="cx"> void dumpState(const char* when);
</span><span class="cx"> };
</span></span></pre>
</div>
</div>
</body>
</html>