<!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>[162825] 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/162825">162825</a></dd>
<dt>Author</dt> <dd>akling@apple.com</dd>
<dt>Date</dt> <dd>2014-01-26 21:45:30 -0800 (Sun, 26 Jan 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>JSC: Pack unlinked instructions harder.
<https://webkit.org/b/127660>
Store UnlinkedCodeBlock's instructions in a variable-length stream
to reduce memory usage. Compression rate ends up around 60-61%.
The format is very simple. Every instruction starts with a 1 byte
opcode. It's followed by an opcode-dependent number of argument
values, each encoded separately for maximum packing. There are
7 packed value formats:
5-bit positive integer
5-bit negative integer
13-bit positive integer
13-bit positive integer
5-bit constant register index
13-bit constant register index
32-bit value (fallback)
27.5 MB progression on Membuster3. (~2% of total memory.)
Reviewed by Filip Pizlo.
* JavaScriptCore.xcodeproj/project.pbxproj:
* bytecode/UnlinkedInstructionStream.h: Added.
(JSC::UnlinkedInstructionStream::count):
(JSC::UnlinkedInstructionStream::Reader::atEnd):
* bytecode/UnlinkedInstructionStream.cpp: Added.
(JSC::UnlinkedInstructionStream::Reader::Reader):
(JSC::UnlinkedInstructionStream::Reader::read8):
(JSC::UnlinkedInstructionStream::Reader::read32):
(JSC::UnlinkedInstructionStream::Reader::next):
(JSC::append8):
(JSC::append32):
(JSC::UnlinkedInstructionStream::UnlinkedInstructionStream):
(JSC::UnlinkedInstructionStream::unpackForDebugging):
* bytecompiler/BytecodeGenerator.cpp:
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::CodeBlock):
* bytecode/UnlinkedCodeBlock.cpp:
(JSC::UnlinkedCodeBlock::lineNumberForBytecodeOffset):
(JSC::dumpLineColumnEntry):
(JSC::UnlinkedCodeBlock::expressionRangeForBytecodeOffset):
(JSC::UnlinkedCodeBlock::setInstructions):
(JSC::UnlinkedCodeBlock::instructions):
* bytecode/UnlinkedCodeBlock.h:
(JSC::BytecodeGenerator::generate):</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="#trunkSourceJavaScriptCoreGNUmakefilelistam">trunk/Source/JavaScriptCore/GNUmakefile.list.am</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="#trunkSourceJavaScriptCorebytecodeCodeBlockcpp">trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeUnlinkedCodeBlockcpp">trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeUnlinkedCodeBlockh">trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecompilerBytecodeGeneratorcpp">trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCorebytecodeUnlinkedInstructionStreamcpp">trunk/Source/JavaScriptCore/bytecode/UnlinkedInstructionStream.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeUnlinkedInstructionStreamh">trunk/Source/JavaScriptCore/bytecode/UnlinkedInstructionStream.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/CMakeLists.txt (162824 => 162825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/CMakeLists.txt        2014-01-27 05:44:39 UTC (rev 162824)
+++ trunk/Source/JavaScriptCore/CMakeLists.txt        2014-01-27 05:45:30 UTC (rev 162825)
</span><span class="lines">@@ -84,6 +84,7 @@
</span><span class="cx"> bytecode/StructureStubClearingWatchpoint.cpp
</span><span class="cx"> bytecode/StructureStubInfo.cpp
</span><span class="cx"> bytecode/UnlinkedCodeBlock.cpp
</span><ins>+ bytecode/UnlinkedInstructionStream.cpp
</ins><span class="cx"> bytecode/ValueRecovery.cpp
</span><span class="cx"> bytecode/Watchpoint.cpp
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (162824 => 162825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2014-01-27 05:44:39 UTC (rev 162824)
+++ trunk/Source/JavaScriptCore/ChangeLog        2014-01-27 05:45:30 UTC (rev 162825)
</span><span class="lines">@@ -1,3 +1,53 @@
</span><ins>+2014-01-26 Andreas Kling <akling@apple.com>
+
+ JSC: Pack unlinked instructions harder.
+ <https://webkit.org/b/127660>
+
+ Store UnlinkedCodeBlock's instructions in a variable-length stream
+ to reduce memory usage. Compression rate ends up around 60-61%.
+
+ The format is very simple. Every instruction starts with a 1 byte
+ opcode. It's followed by an opcode-dependent number of argument
+ values, each encoded separately for maximum packing. There are
+ 7 packed value formats:
+
+ 5-bit positive integer
+ 5-bit negative integer
+ 13-bit positive integer
+ 13-bit positive integer
+ 5-bit constant register index
+ 13-bit constant register index
+ 32-bit value (fallback)
+
+ 27.5 MB progression on Membuster3. (~2% of total memory.)
+
+ Reviewed by Filip Pizlo.
+
+ * JavaScriptCore.xcodeproj/project.pbxproj:
+ * bytecode/UnlinkedInstructionStream.h: Added.
+ (JSC::UnlinkedInstructionStream::count):
+ (JSC::UnlinkedInstructionStream::Reader::atEnd):
+ * bytecode/UnlinkedInstructionStream.cpp: Added.
+ (JSC::UnlinkedInstructionStream::Reader::Reader):
+ (JSC::UnlinkedInstructionStream::Reader::read8):
+ (JSC::UnlinkedInstructionStream::Reader::read32):
+ (JSC::UnlinkedInstructionStream::Reader::next):
+ (JSC::append8):
+ (JSC::append32):
+ (JSC::UnlinkedInstructionStream::UnlinkedInstructionStream):
+ (JSC::UnlinkedInstructionStream::unpackForDebugging):
+ * bytecompiler/BytecodeGenerator.cpp:
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::CodeBlock):
+ * bytecode/UnlinkedCodeBlock.cpp:
+ (JSC::UnlinkedCodeBlock::lineNumberForBytecodeOffset):
+ (JSC::dumpLineColumnEntry):
+ (JSC::UnlinkedCodeBlock::expressionRangeForBytecodeOffset):
+ (JSC::UnlinkedCodeBlock::setInstructions):
+ (JSC::UnlinkedCodeBlock::instructions):
+ * bytecode/UnlinkedCodeBlock.h:
+ (JSC::BytecodeGenerator::generate):
+
</ins><span class="cx"> 2014-01-26 Joseph Pecoraro <pecoraro@apple.com>
</span><span class="cx">
</span><span class="cx"> Web Inspector: Move InspectorDebuggerAgent into JavaScriptCore
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreGNUmakefilelistam"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/GNUmakefile.list.am (162824 => 162825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/GNUmakefile.list.am        2014-01-27 05:44:39 UTC (rev 162824)
+++ trunk/Source/JavaScriptCore/GNUmakefile.list.am        2014-01-27 05:45:30 UTC (rev 162825)
</span><span class="lines">@@ -184,6 +184,8 @@
</span><span class="cx">         Source/JavaScriptCore/bytecode/StructureStubClearingWatchpoint.h \
</span><span class="cx">         Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp \
</span><span class="cx">         Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h \
</span><ins>+        Source/JavaScriptCore/bytecode/UnlinkedInstructionStream.cpp \
+        Source/JavaScriptCore/bytecode/UnlinkedInstructionStream.h \
</ins><span class="cx">         Source/JavaScriptCore/bytecode/ValueProfile.h \
</span><span class="cx">         Source/JavaScriptCore/bytecode/ValueRecovery.cpp \
</span><span class="cx">         Source/JavaScriptCore/bytecode/ValueRecovery.h \
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorevcxprojJavaScriptCorevcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj (162824 => 162825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj        2014-01-27 05:44:39 UTC (rev 162824)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj        2014-01-27 05:45:30 UTC (rev 162825)
</span><span class="lines">@@ -341,6 +341,7 @@
</span><span class="cx"> <ClCompile Include="..\bytecode\StructureStubClearingWatchpoint.cpp" />
</span><span class="cx"> <ClCompile Include="..\bytecode\StructureStubInfo.cpp" />
</span><span class="cx"> <ClCompile Include="..\bytecode\UnlinkedCodeBlock.cpp" />
</span><ins>+ <ClCompile Include="..\bytecode\UnlinkedInstructionStream.cpp" />
</ins><span class="cx"> <ClCompile Include="..\bytecode\ValueRecovery.cpp" />
</span><span class="cx"> <ClCompile Include="..\bytecode\Watchpoint.cpp" />
</span><span class="cx"> <ClCompile Include="..\bytecompiler\BytecodeGenerator.cpp" />
</span><span class="lines">@@ -841,6 +842,7 @@
</span><span class="cx"> <ClInclude Include="..\bytecode\StructureStubClearingWatchpoint.h" />
</span><span class="cx"> <ClInclude Include="..\bytecode\StructureStubInfo.h" />
</span><span class="cx"> <ClInclude Include="..\bytecode\UnlinkedCodeBlock.h" />
</span><ins>+ <ClInclude Include="..\bytecode\UnlinkedInstructionStream.h" />
</ins><span class="cx"> <ClInclude Include="..\bytecode\ValueProfile.h" />
</span><span class="cx"> <ClInclude Include="..\bytecode\ValueRecovery.h" />
</span><span class="cx"> <ClInclude Include="..\bytecode\VariableWatchpointSet.h" />
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorevcxprojJavaScriptCorevcxprojfilters"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters (162824 => 162825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters        2014-01-27 05:44:39 UTC (rev 162824)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters        2014-01-27 05:45:30 UTC (rev 162825)
</span><span class="lines">@@ -186,6 +186,9 @@
</span><span class="cx"> <ClCompile Include="..\bytecode\UnlinkedCodeBlock.cpp">
</span><span class="cx"> <Filter>bytecode</Filter>
</span><span class="cx"> </ClCompile>
</span><ins>+ <ClCompile Include="..\bytecode\UnlinkedInstructionStream.cpp">
+ <Filter>bytecode</Filter>
+ </ClCompile>
</ins><span class="cx"> <ClCompile Include="..\bytecode\Watchpoint.cpp">
</span><span class="cx"> <Filter>bytecode</Filter>
</span><span class="cx"> </ClCompile>
</span><span class="lines">@@ -1559,6 +1562,9 @@
</span><span class="cx"> <ClInclude Include="..\bytecode\UnlinkedCodeBlock.h">
</span><span class="cx"> <Filter>bytecode</Filter>
</span><span class="cx"> </ClInclude>
</span><ins>+ <ClInclude Include="..\bytecode\UnlinkedInstructionStream.h">
+ <Filter>bytecode</Filter>
+ </ClInclude>
</ins><span class="cx"> <ClInclude Include="..\bytecode\ValueProfile.h">
</span><span class="cx"> <Filter>bytecode</Filter>
</span><span class="cx"> </ClInclude>
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (162824 => 162825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2014-01-27 05:44:39 UTC (rev 162824)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2014-01-27 05:45:30 UTC (rev 162825)
</span><span class="lines">@@ -1170,6 +1170,7 @@
</span><span class="cx">                 A7FCC26D17A0B6AA00786D1A /* FTLSwitchCase.h in Headers */ = {isa = PBXBuildFile; fileRef = A7FCC26C17A0B6AA00786D1A /* FTLSwitchCase.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 A8A4748E151A8306004123FF /* libWTF.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A8A4748D151A8306004123FF /* libWTF.a */; };
</span><span class="cx">                 ADE39FFF16DD144B0003CD4A /* PropertyTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD1CF06816DCAB2D00B97123 /* PropertyTable.cpp */; };
</span><ins>+                B59F89391891F29F00D5CCDC /* UnlinkedInstructionStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B59F89381891ADB500D5CCDC /* UnlinkedInstructionStream.cpp */; };
</ins><span class="cx">                 BC02E90D0E1839DB000F9297 /* ErrorConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E9050E1839DB000F9297 /* ErrorConstructor.h */; };
</span><span class="cx">                 BC02E90F0E1839DB000F9297 /* ErrorPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E9070E1839DB000F9297 /* ErrorPrototype.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 BC02E9110E1839DB000F9297 /* NativeErrorConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E9090E1839DB000F9297 /* NativeErrorConstructor.h */; };
</span><span class="lines">@@ -2591,6 +2592,8 @@
</span><span class="cx">                 A8E894310CD0602400367179 /* JSCallbackObjectFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCallbackObjectFunctions.h; sourceTree = "<group>"; };
</span><span class="cx">                 A8E894330CD0603F00367179 /* JSGlobalObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGlobalObject.h; sourceTree = "<group>"; };
</span><span class="cx">                 AD1CF06816DCAB2D00B97123 /* PropertyTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PropertyTable.cpp; sourceTree = "<group>"; };
</span><ins>+                B59F89371891AD3300D5CCDC /* UnlinkedInstructionStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnlinkedInstructionStream.h; sourceTree = "<group>"; };
+                B59F89381891ADB500D5CCDC /* UnlinkedInstructionStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnlinkedInstructionStream.cpp; sourceTree = "<group>"; };
</ins><span class="cx">                 BC021BF2136900C300FC5467 /* ToolExecutable.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ToolExecutable.xcconfig; sourceTree = "<group>"; };
</span><span class="cx">                 BC02E9040E1839DB000F9297 /* ErrorConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ErrorConstructor.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 BC02E9050E1839DB000F9297 /* ErrorConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ErrorConstructor.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -4366,6 +4369,8 @@
</span><span class="cx">                                 BCCF0D070EF0AAB900413C8F /* StructureStubInfo.h */,
</span><span class="cx">                                 A79E781E15EECBA80047C855 /* UnlinkedCodeBlock.cpp */,
</span><span class="cx">                                 A79E781F15EECBA80047C855 /* UnlinkedCodeBlock.h */,
</span><ins>+                                B59F89381891ADB500D5CCDC /* UnlinkedInstructionStream.cpp */,
+                                B59F89371891AD3300D5CCDC /* UnlinkedInstructionStream.h */,
</ins><span class="cx">                                 0F963B3613FC6FDE0002D9B2 /* ValueProfile.h */,
</span><span class="cx">                                 0F24E55717F74EDB00ABB217 /* ValueRecovery.cpp */,
</span><span class="cx">                                 0F426A451460CBAB00131F8F /* ValueRecovery.h */,
</span><span class="lines">@@ -5965,6 +5970,7 @@
</span><span class="cx">                                 86E3C616167BABEE006D760A /* JSContext.mm in Sources */,
</span><span class="cx">                                 14BD5A300A3E91F600BAF59C /* JSContextRef.cpp in Sources */,
</span><span class="cx">                                 A72028B61797601E0098028C /* JSCTestRunnerUtils.cpp in Sources */,
</span><ins>+                                B59F89391891F29F00D5CCDC /* UnlinkedInstructionStream.cpp in Sources */,
</ins><span class="cx">                                 0F2B66EB17B6B5AB00A7AE3F /* JSDataView.cpp in Sources */,
</span><span class="cx">                                 0F2B66ED17B6B5AB00A7AE3F /* JSDataViewPrototype.cpp in Sources */,
</span><span class="cx">                                 978801401471AD920041B016 /* JSDateMath.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeCodeBlockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp (162824 => 162825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp        2014-01-27 05:44:39 UTC (rev 162824)
+++ trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp        2014-01-27 05:45:30 UTC (rev 162825)
</span><span class="lines">@@ -54,6 +54,7 @@
</span><span class="cx"> #include "Repatch.h"
</span><span class="cx"> #include "RepatchBuffer.h"
</span><span class="cx"> #include "SlotVisitorInlines.h"
</span><ins>+#include "UnlinkedInstructionStream.h"
</ins><span class="cx"> #include <wtf/BagToHashMap.h>
</span><span class="cx"> #include <wtf/CommaPrinter.h>
</span><span class="cx"> #include <wtf/StringExtras.h>
</span><span class="lines">@@ -1658,21 +1659,25 @@
</span><span class="cx"> m_objectAllocationProfiles.resizeToFit(size);
</span><span class="cx">
</span><span class="cx"> // Copy and translate the UnlinkedInstructions
</span><del>- size_t instructionCount = unlinkedCodeBlock->instructions().size();
- UnlinkedInstruction* pc = unlinkedCodeBlock->instructions().data();
</del><ins>+ unsigned instructionCount = unlinkedCodeBlock->instructions().count();
+ UnlinkedInstructionStream::Reader instructionReader(unlinkedCodeBlock->instructions());
+
</ins><span class="cx"> Vector<Instruction, 0, UnsafeVectorOverflow> instructions(instructionCount);
</span><del>- for (size_t i = 0; i < unlinkedCodeBlock->instructions().size(); ) {
- unsigned opLength = opcodeLength(pc[i].u.opcode);
- instructions[i] = vm()->interpreter->getOpcode(pc[i].u.opcode);
</del><ins>+ for (unsigned i = 0; !instructionReader.atEnd(); ) {
+ const UnlinkedInstruction* pc = instructionReader.next();
+
+ unsigned opLength = opcodeLength(pc[0].u.opcode);
+
+ instructions[i] = vm()->interpreter->getOpcode(pc[0].u.opcode);
</ins><span class="cx"> for (size_t j = 1; j < opLength; ++j) {
</span><span class="cx"> if (sizeof(int32_t) != sizeof(intptr_t))
</span><span class="cx"> instructions[i + j].u.pointer = 0;
</span><del>- instructions[i + j].u.operand = pc[i + j].u.operand;
</del><ins>+ instructions[i + j].u.operand = pc[j].u.operand;
</ins><span class="cx"> }
</span><del>- switch (pc[i].u.opcode) {
</del><ins>+ switch (pc[0].u.opcode) {
</ins><span class="cx"> case op_get_by_val:
</span><span class="cx"> case op_get_argument_by_val: {
</span><del>- int arrayProfileIndex = pc[i + opLength - 2].u.operand;
</del><ins>+ int arrayProfileIndex = pc[opLength - 2].u.operand;
</ins><span class="cx"> m_arrayProfiles[arrayProfileIndex] = ArrayProfile(i);
</span><span class="cx">
</span><span class="cx"> instructions[i + opLength - 2] = &m_arrayProfiles[arrayProfileIndex];
</span><span class="lines">@@ -1680,20 +1685,20 @@
</span><span class="cx"> }
</span><span class="cx"> case op_get_by_id:
</span><span class="cx"> case op_call_varargs: {
</span><del>- ValueProfile* profile = &m_valueProfiles[pc[i + opLength - 1].u.operand];
</del><ins>+ ValueProfile* profile = &m_valueProfiles[pc[opLength - 1].u.operand];
</ins><span class="cx"> ASSERT(profile->m_bytecodeOffset == -1);
</span><span class="cx"> profile->m_bytecodeOffset = i;
</span><span class="cx"> instructions[i + opLength - 1] = profile;
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> case op_put_by_val: {
</span><del>- int arrayProfileIndex = pc[i + opLength - 1].u.operand;
</del><ins>+ int arrayProfileIndex = pc[opLength - 1].u.operand;
</ins><span class="cx"> m_arrayProfiles[arrayProfileIndex] = ArrayProfile(i);
</span><span class="cx"> instructions[i + opLength - 1] = &m_arrayProfiles[arrayProfileIndex];
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> case op_put_by_val_direct: {
</span><del>- int arrayProfileIndex = pc[i + opLength - 1].u.operand;
</del><ins>+ int arrayProfileIndex = pc[opLength - 1].u.operand;
</ins><span class="cx"> m_arrayProfiles[arrayProfileIndex] = ArrayProfile(i);
</span><span class="cx"> instructions[i + opLength - 1] = &m_arrayProfiles[arrayProfileIndex];
</span><span class="cx"> break;
</span><span class="lines">@@ -1702,14 +1707,14 @@
</span><span class="cx"> case op_new_array:
</span><span class="cx"> case op_new_array_buffer:
</span><span class="cx"> case op_new_array_with_size: {
</span><del>- int arrayAllocationProfileIndex = pc[i + opLength - 1].u.operand;
</del><ins>+ int arrayAllocationProfileIndex = pc[opLength - 1].u.operand;
</ins><span class="cx"> instructions[i + opLength - 1] = &m_arrayAllocationProfiles[arrayAllocationProfileIndex];
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> case op_new_object: {
</span><del>- int objectAllocationProfileIndex = pc[i + opLength - 1].u.operand;
</del><ins>+ int objectAllocationProfileIndex = pc[opLength - 1].u.operand;
</ins><span class="cx"> ObjectAllocationProfile* objectAllocationProfile = &m_objectAllocationProfiles[objectAllocationProfileIndex];
</span><del>- int inferredInlineCapacity = pc[i + opLength - 2].u.operand;
</del><ins>+ int inferredInlineCapacity = pc[opLength - 2].u.operand;
</ins><span class="cx">
</span><span class="cx"> instructions[i + opLength - 1] = objectAllocationProfile;
</span><span class="cx"> objectAllocationProfile->initialize(*vm(),
</span><span class="lines">@@ -1719,23 +1724,23 @@
</span><span class="cx">
</span><span class="cx"> case op_call:
</span><span class="cx"> case op_call_eval: {
</span><del>- ValueProfile* profile = &m_valueProfiles[pc[i + opLength - 1].u.operand];
</del><ins>+ ValueProfile* profile = &m_valueProfiles[pc[opLength - 1].u.operand];
</ins><span class="cx"> ASSERT(profile->m_bytecodeOffset == -1);
</span><span class="cx"> profile->m_bytecodeOffset = i;
</span><span class="cx"> instructions[i + opLength - 1] = profile;
</span><del>- int arrayProfileIndex = pc[i + opLength - 2].u.operand;
</del><ins>+ int arrayProfileIndex = pc[opLength - 2].u.operand;
</ins><span class="cx"> m_arrayProfiles[arrayProfileIndex] = ArrayProfile(i);
</span><span class="cx"> instructions[i + opLength - 2] = &m_arrayProfiles[arrayProfileIndex];
</span><span class="cx"> #if ENABLE(LLINT)
</span><del>- instructions[i + 5] = &m_llintCallLinkInfos[pc[i + 5].u.operand];
</del><ins>+ instructions[i + 5] = &m_llintCallLinkInfos[pc[5].u.operand];
</ins><span class="cx"> #endif
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> case op_construct: {
</span><span class="cx"> #if ENABLE(LLINT)
</span><del>- instructions[i + 5] = &m_llintCallLinkInfos[pc[i + 5].u.operand];
</del><ins>+ instructions[i + 5] = &m_llintCallLinkInfos[pc[5].u.operand];
</ins><span class="cx"> #endif
</span><del>- ValueProfile* profile = &m_valueProfiles[pc[i + opLength - 1].u.operand];
</del><ins>+ ValueProfile* profile = &m_valueProfiles[pc[opLength - 1].u.operand];
</ins><span class="cx"> ASSERT(profile->m_bytecodeOffset == -1);
</span><span class="cx"> profile->m_bytecodeOffset = i;
</span><span class="cx"> instructions[i + opLength - 1] = profile;
</span><span class="lines">@@ -1758,7 +1763,7 @@
</span><span class="cx">
</span><span class="cx"> case op_init_global_const_nop: {
</span><span class="cx"> ASSERT(codeType() == GlobalCode);
</span><del>- Identifier ident = identifier(pc[i + 4].u.operand);
</del><ins>+ Identifier ident = identifier(pc[4].u.operand);
</ins><span class="cx"> SymbolTableEntry entry = m_globalObject->symbolTable()->get(ident.impl());
</span><span class="cx"> if (entry.isNull())
</span><span class="cx"> break;
</span><span class="lines">@@ -1769,8 +1774,8 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> case op_resolve_scope: {
</span><del>- const Identifier& ident = identifier(pc[i + 2].u.operand);
- ResolveType type = static_cast<ResolveType>(pc[i + 3].u.operand);
</del><ins>+ const Identifier& ident = identifier(pc[2].u.operand);
+ ResolveType type = static_cast<ResolveType>(pc[3].u.operand);
</ins><span class="cx">
</span><span class="cx"> ResolveOp op = JSScope::abstractResolve(m_globalObject->globalExec(), scope, ident, Get, type);
</span><span class="cx"> instructions[i + 3].u.operand = op.type;
</span><span class="lines">@@ -1781,14 +1786,14 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> case op_get_from_scope: {
</span><del>- ValueProfile* profile = &m_valueProfiles[pc[i + opLength - 1].u.operand];
</del><ins>+ ValueProfile* profile = &m_valueProfiles[pc[opLength - 1].u.operand];
</ins><span class="cx"> ASSERT(profile->m_bytecodeOffset == -1);
</span><span class="cx"> profile->m_bytecodeOffset = i;
</span><span class="cx"> instructions[i + opLength - 1] = profile;
</span><span class="cx">
</span><span class="cx"> // get_from_scope dst, scope, id, ResolveModeAndType, Structure, Operand
</span><del>- const Identifier& ident = identifier(pc[i + 3].u.operand);
- ResolveModeAndType modeAndType = ResolveModeAndType(pc[i + 4].u.operand);
</del><ins>+ const Identifier& ident = identifier(pc[3].u.operand);
+ ResolveModeAndType modeAndType = ResolveModeAndType(pc[4].u.operand);
</ins><span class="cx"> ResolveOp op = JSScope::abstractResolve(m_globalObject->globalExec(), scope, ident, Get, modeAndType.type());
</span><span class="cx">
</span><span class="cx"> instructions[i + 4].u.operand = ResolveModeAndType(modeAndType.mode(), op.type).operand();
</span><span class="lines">@@ -1802,8 +1807,8 @@
</span><span class="cx">
</span><span class="cx"> case op_put_to_scope: {
</span><span class="cx"> // put_to_scope scope, id, value, ResolveModeAndType, Structure, Operand
</span><del>- const Identifier& ident = identifier(pc[i + 2].u.operand);
- ResolveModeAndType modeAndType = ResolveModeAndType(pc[i + 4].u.operand);
</del><ins>+ const Identifier& ident = identifier(pc[2].u.operand);
+ ResolveModeAndType modeAndType = ResolveModeAndType(pc[4].u.operand);
</ins><span class="cx"> ResolveOp op = JSScope::abstractResolve(m_globalObject->globalExec(), scope, ident, Put, modeAndType.type());
</span><span class="cx">
</span><span class="cx"> instructions[i + 4].u.operand = ResolveModeAndType(modeAndType.mode(), op.type).operand();
</span><span class="lines">@@ -1820,11 +1825,11 @@
</span><span class="cx">
</span><span class="cx"> case op_captured_mov:
</span><span class="cx"> case op_new_captured_func: {
</span><del>- if (pc[i + 3].u.index == UINT_MAX) {
</del><ins>+ if (pc[3].u.index == UINT_MAX) {
</ins><span class="cx"> instructions[i + 3].u.watchpointSet = 0;
</span><span class="cx"> break;
</span><span class="cx"> }
</span><del>- StringImpl* uid = identifier(pc[i + 3].u.index).impl();
</del><ins>+ StringImpl* uid = identifier(pc[3].u.index).impl();
</ins><span class="cx"> RELEASE_ASSERT(didCloneSymbolTable);
</span><span class="cx"> ConcurrentJITLocker locker(m_symbolTable->m_lock);
</span><span class="cx"> SymbolTable::Map::iterator iter = m_symbolTable->find(locker, uid);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeUnlinkedCodeBlockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp (162824 => 162825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp        2014-01-27 05:44:39 UTC (rev 162824)
+++ trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp        2014-01-27 05:45:30 UTC (rev 162825)
</span><span class="lines">@@ -37,6 +37,7 @@
</span><span class="cx"> #include "SourceProvider.h"
</span><span class="cx"> #include "Structure.h"
</span><span class="cx"> #include "SymbolTable.h"
</span><ins>+#include "UnlinkedInstructionStream.h"
</ins><span class="cx"> #include <wtf/DataLog.h>
</span><span class="cx">
</span><span class="cx"> namespace JSC {
</span><span class="lines">@@ -247,7 +248,7 @@
</span><span class="cx">
</span><span class="cx"> int UnlinkedCodeBlock::lineNumberForBytecodeOffset(unsigned bytecodeOffset)
</span><span class="cx"> {
</span><del>- ASSERT(bytecodeOffset < instructions().size());
</del><ins>+ ASSERT(bytecodeOffset < instructions().count());
</ins><span class="cx"> int divot;
</span><span class="cx"> int startOffset;
</span><span class="cx"> int endOffset;
</span><span class="lines">@@ -278,8 +279,9 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #ifndef NDEBUG
</span><del>-static void dumpLineColumnEntry(size_t index, const RefCountedArray<UnlinkedInstruction>& instructions, unsigned instructionOffset, unsigned line, unsigned column)
</del><ins>+static void dumpLineColumnEntry(size_t index, const UnlinkedInstructionStream& instructionStream, unsigned instructionOffset, unsigned line, unsigned column)
</ins><span class="cx"> {
</span><ins>+ const auto& instructions = instructionStream.unpackForDebugging();
</ins><span class="cx"> OpcodeID opcode = instructions[instructionOffset].u.opcode;
</span><span class="cx"> const char* event = "";
</span><span class="cx"> if (opcode == op_debug) {
</span><span class="lines">@@ -315,7 +317,7 @@
</span><span class="cx"> void UnlinkedCodeBlock::expressionRangeForBytecodeOffset(unsigned bytecodeOffset,
</span><span class="cx"> int& divot, int& startOffset, int& endOffset, unsigned& line, unsigned& column)
</span><span class="cx"> {
</span><del>- ASSERT(bytecodeOffset < instructions().size());
</del><ins>+ ASSERT(bytecodeOffset < instructions().count());
</ins><span class="cx">
</span><span class="cx"> if (!m_expressionInfo.size()) {
</span><span class="cx"> startOffset = 0;
</span><span class="lines">@@ -437,5 +439,16 @@
</span><span class="cx"> jsCast<UnlinkedFunctionExecutable*>(cell)->~UnlinkedFunctionExecutable();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void UnlinkedCodeBlock::setInstructions(std::unique_ptr<UnlinkedInstructionStream> instructions)
+{
+ m_unlinkedInstructions = std::move(instructions);
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+const UnlinkedInstructionStream& UnlinkedCodeBlock::instructions() const
+{
+ ASSERT(m_unlinkedInstructions.get());
+ return *m_unlinkedInstructions;
+}
+
+}
+
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeUnlinkedCodeBlockh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h (162824 => 162825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h        2014-01-27 05:44:39 UTC (rev 162824)
+++ trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h        2014-01-27 05:45:30 UTC (rev 162825)
</span><span class="lines">@@ -57,6 +57,7 @@
</span><span class="cx"> class SymbolTable;
</span><span class="cx"> class UnlinkedCodeBlock;
</span><span class="cx"> class UnlinkedFunctionCodeBlock;
</span><ins>+class UnlinkedInstructionStream;
</ins><span class="cx">
</span><span class="cx"> typedef unsigned UnlinkedValueProfile;
</span><span class="cx"> typedef unsigned UnlinkedArrayProfile;
</span><span class="lines">@@ -341,9 +342,8 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- unsigned numberOfInstructions() const { return m_unlinkedInstructions.size(); }
- RefCountedArray<UnlinkedInstruction>& instructions() { return m_unlinkedInstructions; }
- const RefCountedArray<UnlinkedInstruction>& instructions() const { return m_unlinkedInstructions; }
</del><ins>+ void setInstructions(std::unique_ptr<UnlinkedInstructionStream>);
+ const UnlinkedInstructionStream& instructions() const;
</ins><span class="cx">
</span><span class="cx"> int m_numVars;
</span><span class="cx"> int m_numCapturedVars;
</span><span class="lines">@@ -484,7 +484,7 @@
</span><span class="cx">
</span><span class="cx"> void getLineAndColumn(ExpressionRangeInfo&, unsigned& line, unsigned& column);
</span><span class="cx">
</span><del>- RefCountedArray<UnlinkedInstruction> m_unlinkedInstructions;
</del><ins>+ std::unique_ptr<UnlinkedInstructionStream> m_unlinkedInstructions;
</ins><span class="cx">
</span><span class="cx"> int m_numParameters;
</span><span class="cx"> VM* m_vm;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeUnlinkedInstructionStreamcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/bytecode/UnlinkedInstructionStream.cpp (0 => 162825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/UnlinkedInstructionStream.cpp         (rev 0)
+++ trunk/Source/JavaScriptCore/bytecode/UnlinkedInstructionStream.cpp        2014-01-27 05:45:30 UTC (rev 162825)
</span><span class="lines">@@ -0,0 +1,200 @@
</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 "UnlinkedInstructionStream.h"
+
+namespace JSC {
+
+// Unlinked instructions are packed in a simple stream format.
+//
+// The first byte is always the opcode.
+// It's followed by an opcode-dependent number of argument values.
+// The first 3 bits of each value determines the format:
+//
+// 5-bit positive integer (1 byte total)
+// 5-bit negative integer (1 byte total)
+// 13-bit positive integer (2 bytes total)
+// 13-bit negative integer (2 bytes total)
+// 5-bit constant register index, based at 0x40000000 (1 byte total)
+// 13-bit constant register index, based at 0x40000000 (2 bytes total)
+// 32-bit raw value (5 bytes total)
+
+enum PackedValueType {
+ Positive5Bit = 0,
+ Negative5Bit,
+ Positive13Bit,
+ Negative13Bit,
+ ConstantRegister5Bit,
+ ConstantRegister13Bit,
+ Full32Bit
+};
+
+UnlinkedInstructionStream::Reader::Reader(const UnlinkedInstructionStream& stream)
+ : m_stream(stream)
+ , m_index(0)
+{
+}
+
+inline unsigned char UnlinkedInstructionStream::Reader::read8()
+{
+ return m_stream.m_data.data()[m_index++];
+}
+
+inline unsigned UnlinkedInstructionStream::Reader::read32()
+{
+ const unsigned char* data = &m_stream.m_data.data()[m_index];
+ unsigned char type = data[0] >> 5;
+
+ switch (type) {
+ case Positive5Bit:
+ m_index++;
+ return data[0];
+ case Negative5Bit:
+ m_index++;
+ return 0xffffffe0 | data[0];
+ case Positive13Bit:
+ m_index += 2;
+ return ((data[0] & 0x1F) << 8) | data[1];
+ case Negative13Bit:
+ m_index += 2;
+ return 0xffffe000 | ((data[0] & 0x1F) << 8) | data[1];
+ case ConstantRegister5Bit:
+ m_index++;
+ return 0x40000000 | (data[0] & 0x1F);
+ case ConstantRegister13Bit:
+ m_index += 2;
+ return 0x40000000 | ((data[0] & 0x1F) << 8) | data[1];
+ default:
+ ASSERT(type == Full32Bit);
+ m_index += 5;
+ return data[1] | data[2] << 8 | data[3] << 16 | data[4] << 24;
+ }
+}
+
+const UnlinkedInstruction* UnlinkedInstructionStream::Reader::next()
+{
+ m_unpackedBuffer[0].u.opcode = static_cast<OpcodeID>(read8());
+ unsigned opLength = opcodeLength(m_unpackedBuffer[0].u.opcode);
+ for (unsigned i = 1; i < opLength; ++i)
+ m_unpackedBuffer[i].u.index = read32();
+ return m_unpackedBuffer;
+}
+
+static void append8(unsigned char*& ptr, unsigned char value)
+{
+ *(ptr++) = value;
+}
+
+static void append32(unsigned char*& ptr, unsigned value)
+{
+ if (!(value & 0xffffffe0)) {
+ *(ptr++) = value;
+ return;
+ }
+
+ if ((value & 0xffffffe0) == 0xffffffe0) {
+ *(ptr++) = (Negative5Bit << 5) | (value & 0x1f);
+ return;
+ }
+
+ if ((value & 0xffffffe0) == 0x40000000) {
+ *(ptr++) = (ConstantRegister5Bit << 5) | (value & 0x1f);
+ return;
+ }
+
+ if (!(value & 0xffffe000)) {
+ *(ptr++) = (Positive13Bit << 5) | ((value >> 8) & 0x1f);
+ *(ptr++) = value & 0xff;
+ return;
+ }
+
+ if ((value & 0xffffe000) == 0xffffe000) {
+ *(ptr++) = (Negative13Bit << 5) | ((value >> 8) & 0x1f);
+ *(ptr++) = value & 0xff;
+ return;
+ }
+
+ if ((value & 0xffffe000) == 0x40000000) {
+ *(ptr++) = (ConstantRegister13Bit << 5) | ((value >> 8) & 0x1f);
+ *(ptr++) = value & 0xff;
+ return;
+ }
+
+ *(ptr++) = Full32Bit << 5;
+ *(ptr++) = value & 0xff;
+ *(ptr++) = (value >> 8) & 0xff;
+ *(ptr++) = (value >> 16) & 0xff;
+ *(ptr++) = (value >> 24) & 0xff;
+}
+
+UnlinkedInstructionStream::UnlinkedInstructionStream(const Vector<UnlinkedInstruction>& instructions)
+ : m_instructionCount(instructions.size())
+{
+ Vector<unsigned char> buffer;
+
+ // Reserve enough space up front so we never have to reallocate when appending.
+ buffer.resizeToFit(m_instructionCount * 5);
+ unsigned char* ptr = buffer.data();
+
+ const UnlinkedInstruction* instructionsData = instructions.data();
+ for (unsigned i = 0; i < m_instructionCount;) {
+ const UnlinkedInstruction* pc = &instructionsData[i];
+ OpcodeID opcode = pc[0].u.opcode;
+ append8(ptr, opcode);
+
+ unsigned opLength = opcodeLength(opcode);
+
+ for (unsigned j = 1; j < opLength; ++j)
+ append32(ptr, pc[j].u.index);
+
+ i += opLength;
+ }
+
+ buffer.shrink(ptr - buffer.data());
+ m_data = RefCountedArray<unsigned char>(buffer);
+}
+
+#ifndef NDEBUG
+const RefCountedArray<UnlinkedInstruction>& UnlinkedInstructionStream::unpackForDebugging() const
+{
+ if (!m_unpackedInstructionsForDebugging.size()) {
+ m_unpackedInstructionsForDebugging = RefCountedArray<UnlinkedInstruction>(m_instructionCount);
+
+ Reader instructionReader(*this);
+ for (unsigned i = 0; !instructionReader.atEnd(); ) {
+ const UnlinkedInstruction* pc = instructionReader.next();
+ unsigned opLength = opcodeLength(pc[0].u.opcode);
+ for (unsigned j = 0; j < opLength; ++j)
+ m_unpackedInstructionsForDebugging[i++] = pc[j];
+ }
+ }
+
+ return m_unpackedInstructionsForDebugging;
+}
+#endif
+
+}
+
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeUnlinkedInstructionStreamh"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/bytecode/UnlinkedInstructionStream.h (0 => 162825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/UnlinkedInstructionStream.h         (rev 0)
+++ trunk/Source/JavaScriptCore/bytecode/UnlinkedInstructionStream.h        2014-01-27 05:45:30 UTC (rev 162825)
</span><span class="lines">@@ -0,0 +1,74 @@
</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 UnlinkedInstructionStream_h
+#define UnlinkedInstructionStream_h
+
+#include "UnlinkedCodeBlock.h"
+#include <wtf/RefCountedArray.h>
+
+namespace JSC {
+
+class UnlinkedInstructionStream {
+public:
+ explicit UnlinkedInstructionStream(const Vector<UnlinkedInstruction>&);
+
+ unsigned count() const { return m_instructionCount; }
+
+ class Reader {
+ public:
+ explicit Reader(const UnlinkedInstructionStream&);
+
+ const UnlinkedInstruction* next();
+ bool atEnd() const { return m_index == m_stream.m_data.size(); }
+
+ private:
+ unsigned char read8();
+ unsigned read32();
+
+ const UnlinkedInstructionStream& m_stream;
+ UnlinkedInstruction m_unpackedBuffer[16];
+ unsigned m_index;
+ };
+
+#ifndef NDEBUG
+ const RefCountedArray<UnlinkedInstruction>& unpackForDebugging() const;
+#endif
+
+private:
+ friend class Reader;
+
+#ifndef NDEBUG
+ mutable RefCountedArray<UnlinkedInstruction> m_unpackedInstructionsForDebugging;
+#endif
+
+ RefCountedArray<unsigned char> m_data;
+ unsigned m_instructionCount;
+};
+
+} // namespace JSC
+
+#endif // UnlinkedInstructionStream_h
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecompilerBytecodeGeneratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp (162824 => 162825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp        2014-01-27 05:44:39 UTC (rev 162824)
+++ trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp        2014-01-27 05:45:30 UTC (rev 162825)
</span><span class="lines">@@ -41,6 +41,7 @@
</span><span class="cx"> #include "StackAlignment.h"
</span><span class="cx"> #include "StrongInlines.h"
</span><span class="cx"> #include "UnlinkedCodeBlock.h"
</span><ins>+#include "UnlinkedInstructionStream.h"
</ins><span class="cx"> #include <wtf/StdLibExtras.h>
</span><span class="cx"> #include <wtf/text/WTFString.h>
</span><span class="cx">
</span><span class="lines">@@ -106,7 +107,7 @@
</span><span class="cx"> m_codeBlock->addExceptionHandler(info);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- m_codeBlock->instructions() = RefCountedArray<UnlinkedInstruction>(m_instructions);
</del><ins>+ m_codeBlock->setInstructions(std::make_unique<UnlinkedInstructionStream>(m_instructions));
</ins><span class="cx">
</span><span class="cx"> m_codeBlock->shrinkToFit();
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>