<!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>[187550] 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/187550">187550</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-07-29 12:03:34 -0700 (Wed, 29 Jul 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Implement WebAssembly module parser
https://bugs.webkit.org/show_bug.cgi?id=147293
Patch by Sukolsak Sakshuwong <sukolsak@gmail.com> on 2015-07-29
Reviewed by Mark Lam.
Reupload the patch, since <a href="http://trac.webkit.org/projects/webkit/changeset/187539">r187539</a> should fix the "Cannot open include file:
'JSWASMModule.h'" issue in the Windows build.
* CMakeLists.txt:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
* JavaScriptCore.xcodeproj/project.pbxproj:
* jsc.cpp:
(GlobalObject::finishCreation):
(functionLoadWebAssembly):
* parser/SourceProvider.h:
(JSC::WebAssemblySourceProvider::create):
(JSC::WebAssemblySourceProvider::data):
(JSC::WebAssemblySourceProvider::WebAssemblySourceProvider):
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::wasmModuleStructure):
* wasm/WASMMagicNumber.h: Added.
* wasm/WASMModuleParser.cpp: Added.
(JSC::WASMModuleParser::WASMModuleParser):
(JSC::WASMModuleParser::parse):
(JSC::WASMModuleParser::parseModule):
(JSC::parseWebAssembly):
* wasm/WASMModuleParser.h: Added.
* wasm/WASMReader.cpp: Added.
(JSC::WASMReader::readUnsignedInt32):
(JSC::WASMReader::readFloat):
(JSC::WASMReader::readDouble):
* wasm/WASMReader.h: Added.
(JSC::WASMReader::WASMReader):</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="#trunkSourceJavaScriptCorejsccpp">trunk/Source/JavaScriptCore/jsc.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreparserSourceProviderh">trunk/Source/JavaScriptCore/parser/SourceProvider.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSGlobalObjectcpp">trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSGlobalObjecth">trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCorewasmWASMMagicNumberh">trunk/Source/JavaScriptCore/wasm/WASMMagicNumber.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWASMModuleParsercpp">trunk/Source/JavaScriptCore/wasm/WASMModuleParser.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWASMModuleParserh">trunk/Source/JavaScriptCore/wasm/WASMModuleParser.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWASMReadercpp">trunk/Source/JavaScriptCore/wasm/WASMReader.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWASMReaderh">trunk/Source/JavaScriptCore/wasm/WASMReader.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 (187549 => 187550)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/CMakeLists.txt        2015-07-29 17:52:44 UTC (rev 187549)
+++ trunk/Source/JavaScriptCore/CMakeLists.txt        2015-07-29 19:03:34 UTC (rev 187550)
</span><span class="lines">@@ -411,6 +411,8 @@
</span><span class="cx"> tools/JSDollarVMPrototype.cpp
</span><span class="cx">
</span><span class="cx"> wasm/JSWASMModule.cpp
</span><ins>+ wasm/WASMModuleParser.cpp
+ wasm/WASMReader.cpp
</ins><span class="cx">
</span><span class="cx"> yarr/RegularExpression.cpp
</span><span class="cx"> yarr/YarrCanonicalizeUCS2.cpp
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (187549 => 187550)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-07-29 17:52:44 UTC (rev 187549)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-07-29 19:03:34 UTC (rev 187550)
</span><span class="lines">@@ -1,3 +1,43 @@
</span><ins>+2015-07-29 Sukolsak Sakshuwong <sukolsak@gmail.com>
+
+ Implement WebAssembly module parser
+ https://bugs.webkit.org/show_bug.cgi?id=147293
+
+ Reviewed by Mark Lam.
+
+ Reupload the patch, since r187539 should fix the "Cannot open include file:
+ 'JSWASMModule.h'" issue in the Windows build.
+
+ * CMakeLists.txt:
+ * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
+ * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
+ * JavaScriptCore.xcodeproj/project.pbxproj:
+ * jsc.cpp:
+ (GlobalObject::finishCreation):
+ (functionLoadWebAssembly):
+ * parser/SourceProvider.h:
+ (JSC::WebAssemblySourceProvider::create):
+ (JSC::WebAssemblySourceProvider::data):
+ (JSC::WebAssemblySourceProvider::WebAssemblySourceProvider):
+ * runtime/JSGlobalObject.cpp:
+ (JSC::JSGlobalObject::init):
+ (JSC::JSGlobalObject::visitChildren):
+ * runtime/JSGlobalObject.h:
+ (JSC::JSGlobalObject::wasmModuleStructure):
+ * wasm/WASMMagicNumber.h: Added.
+ * wasm/WASMModuleParser.cpp: Added.
+ (JSC::WASMModuleParser::WASMModuleParser):
+ (JSC::WASMModuleParser::parse):
+ (JSC::WASMModuleParser::parseModule):
+ (JSC::parseWebAssembly):
+ * wasm/WASMModuleParser.h: Added.
+ * wasm/WASMReader.cpp: Added.
+ (JSC::WASMReader::readUnsignedInt32):
+ (JSC::WASMReader::readFloat):
+ (JSC::WASMReader::readDouble):
+ * wasm/WASMReader.h: Added.
+ (JSC::WASMReader::WASMReader):
+
</ins><span class="cx"> 2015-07-29 Basile Clement <basile_clement@apple.com>
</span><span class="cx">
</span><span class="cx"> Unreviewed, lower the number of test iterations to prevent timing out on Debug builds
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorevcxprojJavaScriptCorevcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj (187549 => 187550)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj        2015-07-29 17:52:44 UTC (rev 187549)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj        2015-07-29 19:03:34 UTC (rev 187550)
</span><span class="lines">@@ -868,6 +868,8 @@
</span><span class="cx"> <ClCompile Include="..\tools\JSDollarVM.cpp" />
</span><span class="cx"> <ClCompile Include="..\tools\JSDollarVMPrototype.cpp" />
</span><span class="cx"> <ClCompile Include="..\wasm\JSWASMModule.cpp" />
</span><ins>+ <ClCompile Include="..\wasm\WASMModuleParser.cpp" />
+ <ClCompile Include="..\wasm\WASMReader.cpp" />
</ins><span class="cx"> <ClCompile Include="..\yarr\RegularExpression.cpp" />
</span><span class="cx"> <ClCompile Include="..\yarr\YarrCanonicalizeUCS2.cpp" />
</span><span class="cx"> <ClCompile Include="..\yarr\YarrInterpreter.cpp" />
</span><span class="lines">@@ -1734,6 +1736,9 @@
</span><span class="cx"> <ClInclude Include="..\tools\ProfileTreeNode.h" />
</span><span class="cx"> <ClInclude Include="..\tools\TieredMMapArray.h" />
</span><span class="cx"> <ClInclude Include="..\wasm\JSWASMModule.h" />
</span><ins>+ <ClInclude Include="..\wasm\WASMMagicNumber.h" />
+ <ClInclude Include="..\wasm\WASMModuleParser.h" />
+ <ClInclude Include="..\wasm\WASMReader.h" />
</ins><span class="cx"> <ClInclude Include="..\yarr\RegularExpression.h" />
</span><span class="cx"> <ClInclude Include="..\yarr\Yarr.h" />
</span><span class="cx"> <ClInclude Include="..\yarr\YarrCanonicalizeUCS2.h" />
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorevcxprojJavaScriptCorevcxprojfilters"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters (187549 => 187550)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters        2015-07-29 17:52:44 UTC (rev 187549)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters        2015-07-29 19:03:34 UTC (rev 187550)
</span><span class="lines">@@ -1797,6 +1797,12 @@
</span><span class="cx"> <ClCompile Include="..\wasm\JSWASMModule.cpp">
</span><span class="cx"> <Filter>wasm</Filter>
</span><span class="cx"> </ClCompile>
</span><ins>+ <ClCompile Include="..\wasm\WASMModuleParser.cpp">
+ <Filter>wasm</Filter>
+ </ClCompile>
+ <ClCompile Include="..\wasm\WASMReader.cpp">
+ <Filter>wasm</Filter>
+ </ClCompile>
</ins><span class="cx"> </ItemGroup>
</span><span class="cx"> <ItemGroup>
</span><span class="cx"> <ClInclude Include="..\API\APICallbackFunction.h">
</span><span class="lines">@@ -4301,6 +4307,15 @@
</span><span class="cx"> <ClInclude Include="..\wasm\JSWASMModule.h">
</span><span class="cx"> <Filter>wasm</Filter>
</span><span class="cx"> </ClInclude>
</span><ins>+ <ClInclude Include="..\wasm\WASMMagicNumber.h">
+ <Filter>wasm</Filter>
+ </ClInclude>
+ <ClInclude Include="..\wasm\WASMModuleParser.h">
+ <Filter>wasm</Filter>
+ </ClInclude>
+ <ClInclude Include="..\wasm\WASMReader.h">
+ <Filter>wasm</Filter>
+ </ClInclude>
</ins><span class="cx"> </ItemGroup>
</span><span class="cx"> <ItemGroup>
</span><span class="cx"> <None Include="JavaScriptCorePreLink.cmd" />
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (187549 => 187550)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2015-07-29 17:52:44 UTC (rev 187549)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2015-07-29 19:03:34 UTC (rev 187550)
</span><span class="lines">@@ -1021,6 +1021,11 @@
</span><span class="cx">                 70ECA6091AFDBEA200449739 /* TemplateRegistryKey.h in Headers */ = {isa = PBXBuildFile; fileRef = 70ECA6041AFDBEA200449739 /* TemplateRegistryKey.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 79EE0BFF1B4AFB85000385C9 /* VariableEnvironment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 79EE0BFD1B4AFB85000385C9 /* VariableEnvironment.cpp */; };
</span><span class="cx">                 79EE0C001B4AFB85000385C9 /* VariableEnvironment.h in Headers */ = {isa = PBXBuildFile; fileRef = 79EE0BFE1B4AFB85000385C9 /* VariableEnvironment.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                7B39F76D1B62DE2E00360FB4 /* WASMModuleParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7B39F7691B62DE2200360FB4 /* WASMModuleParser.cpp */; };
+                7B39F76E1B62DE3200360FB4 /* WASMModuleParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B39F76A1B62DE2200360FB4 /* WASMModuleParser.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                7B39F7701B62DE3200360FB4 /* WASMReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B39F76C1B62DE2200360FB4 /* WASMReader.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                7B39F7721B63574D00360FB4 /* WASMReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7B39F7711B63574B00360FB4 /* WASMReader.cpp */; };
+                7B7A5E271B68288C0027CAD0 /* WASMMagicNumber.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B7A5E261B6828840027CAD0 /* WASMMagicNumber.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 7B98D1361B60CD5F0023B1A4 /* JSWASMModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7B98D1341B60CD5A0023B1A4 /* JSWASMModule.cpp */; };
</span><span class="cx">                 7B98D1371B60CD620023B1A4 /* JSWASMModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B98D1351B60CD5A0023B1A4 /* JSWASMModule.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 7C008CDA187124BB00955C24 /* JSPromiseDeferred.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C008CD8187124BB00955C24 /* JSPromiseDeferred.cpp */; };
</span><span class="lines">@@ -2769,6 +2774,11 @@
</span><span class="cx">                 70ECA6041AFDBEA200449739 /* TemplateRegistryKey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TemplateRegistryKey.h; sourceTree = "<group>"; };
</span><span class="cx">                 79EE0BFD1B4AFB85000385C9 /* VariableEnvironment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VariableEnvironment.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 79EE0BFE1B4AFB85000385C9 /* VariableEnvironment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VariableEnvironment.h; sourceTree = "<group>"; };
</span><ins>+                7B39F7691B62DE2200360FB4 /* WASMModuleParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WASMModuleParser.cpp; sourceTree = "<group>"; };
+                7B39F76A1B62DE2200360FB4 /* WASMModuleParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WASMModuleParser.h; sourceTree = "<group>"; };
+                7B39F76C1B62DE2200360FB4 /* WASMReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WASMReader.h; sourceTree = "<group>"; };
+                7B39F7711B63574B00360FB4 /* WASMReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WASMReader.cpp; sourceTree = "<group>"; };
+                7B7A5E261B6828840027CAD0 /* WASMMagicNumber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WASMMagicNumber.h; sourceTree = "<group>"; };
</ins><span class="cx">                 7B98D1341B60CD5A0023B1A4 /* JSWASMModule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWASMModule.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 7B98D1351B60CD5A0023B1A4 /* JSWASMModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWASMModule.h; sourceTree = "<group>"; };
</span><span class="cx">                 7C008CD8187124BB00955C24 /* JSPromiseDeferred.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPromiseDeferred.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -4307,6 +4317,11 @@
</span><span class="cx">                         children = (
</span><span class="cx">                                 7B98D1341B60CD5A0023B1A4 /* JSWASMModule.cpp */,
</span><span class="cx">                                 7B98D1351B60CD5A0023B1A4 /* JSWASMModule.h */,
</span><ins>+                                7B7A5E261B6828840027CAD0 /* WASMMagicNumber.h */,
+                                7B39F7691B62DE2200360FB4 /* WASMModuleParser.cpp */,
+                                7B39F76A1B62DE2200360FB4 /* WASMModuleParser.h */,
+                                7B39F7711B63574B00360FB4 /* WASMReader.cpp */,
+                                7B39F76C1B62DE2200360FB4 /* WASMReader.h */,
</ins><span class="cx">                         );
</span><span class="cx">                         path = wasm;
</span><span class="cx">                         sourceTree = "<group>";
</span><span class="lines">@@ -6214,6 +6229,7 @@
</span><span class="cx">                                 0F5A1274192D9FDF008764A3 /* DFGDoesGC.h in Headers */,
</span><span class="cx">                                 0F2B66F517B6B5AB00A7AE3F /* JSGenericTypedArrayViewPrototype.h in Headers */,
</span><span class="cx">                                 0F2B66F617B6B5AB00A7AE3F /* JSGenericTypedArrayViewPrototypeInlines.h in Headers */,
</span><ins>+                                7B39F76E1B62DE3200360FB4 /* WASMModuleParser.h in Headers */,
</ins><span class="cx">                                 BC18C4210E16F5CD00B34460 /* JSGlobalObject.h in Headers */,
</span><span class="cx">                                 A5FD0086189B1B7E00633231 /* JSGlobalObjectConsoleAgent.h in Headers */,
</span><span class="cx">                                 A59455931824744700CC3843 /* JSGlobalObjectDebuggable.h in Headers */,
</span><span class="lines">@@ -6425,6 +6441,7 @@
</span><span class="cx">                                 BC18C4540E16F5CD00B34460 /* PropertyNameArray.h in Headers */,
</span><span class="cx">                                 0FF7168C15A3B235008F5DAA /* PropertyOffset.h in Headers */,
</span><span class="cx">                                 A785F6BC18C553FE00F10626 /* SpillRegistersMode.h in Headers */,
</span><ins>+                                7B7A5E271B68288C0027CAD0 /* WASMMagicNumber.h in Headers */,
</ins><span class="cx">                                 BC18C4550E16F5CD00B34460 /* PropertySlot.h in Headers */,
</span><span class="cx">                                 0FB7F39C15ED8E4600F167B2 /* PropertyStorage.h in Headers */,
</span><span class="cx">                                 0F6FC751196110A800E1D02D /* ComplexGetStatus.h in Headers */,
</span><span class="lines">@@ -6558,6 +6575,7 @@
</span><span class="cx">                                 0F5F08CF146C7633000472A9 /* UnconditionalFinalizer.h in Headers */,
</span><span class="cx">                                 A7B601821639FD2A00372BA3 /* UnlinkedCodeBlock.h in Headers */,
</span><span class="cx">                                 0F2E892C16D028AD009E4FD2 /* UnusedPointer.h in Headers */,
</span><ins>+                                7B39F7701B62DE3200360FB4 /* WASMReader.h in Headers */,
</ins><span class="cx">                                 0F963B3813FC6FE90002D9B2 /* ValueProfile.h in Headers */,
</span><span class="cx">                                 0F426A481460CBB300131F8F /* ValueRecovery.h in Headers */,
</span><span class="cx">                                 0F9C5E5F18E35F5E00D431C3 /* FTLDWARFRegister.h in Headers */,
</span><span class="lines">@@ -7192,6 +7210,7 @@
</span><span class="cx">                                 0F9D339617FFC4E60073C2BC /* DFGFlushedAt.cpp in Sources */,
</span><span class="cx">                                 0F9D36941AE9CC33000D4DFB /* DFGCleanUpPhase.cpp in Sources */,
</span><span class="cx">                                 A7D89CF717A0B8CC00773AD8 /* DFGFlushFormat.cpp in Sources */,
</span><ins>+                                7B39F76D1B62DE2E00360FB4 /* WASMModuleParser.cpp in Sources */,
</ins><span class="cx">                                 0F3A1BF91A9ECB7D000DE01A /* DFGPutStackSinkingPhase.cpp in Sources */,
</span><span class="cx">                                 86EC9DC71328DF82002B2AD7 /* DFGGraph.cpp in Sources */,
</span><span class="cx">                                 0F2FCCF918A60070001A27F8 /* DFGGraphSafepoint.cpp in Sources */,
</span><span class="lines">@@ -7606,6 +7625,7 @@
</span><span class="cx">                                 0F24E55017EE274900ABB217 /* Repatch.cpp in Sources */,
</span><span class="cx">                                 62D2D38F1ADF103F000206C1 /* FunctionRareData.cpp in Sources */,
</span><span class="cx">                                 0F7700921402FF3C0078EB39 /* SamplingCounter.cpp in Sources */,
</span><ins>+                                7B39F7721B63574D00360FB4 /* WASMReader.cpp in Sources */,
</ins><span class="cx">                                 1429D8850ED21C3D00B89619 /* SamplingTool.cpp in Sources */,
</span><span class="cx">                                 70EC0EC61AA0D7DA00B6AAFA /* StringIteratorPrototype.cpp in Sources */,
</span><span class="cx">                                 A5FD0067189AFE9C00633231 /* ScriptArguments.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejsccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jsc.cpp (187549 => 187550)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jsc.cpp        2015-07-29 17:52:44 UTC (rev 187549)
+++ trunk/Source/JavaScriptCore/jsc.cpp        2015-07-29 19:03:34 UTC (rev 187550)
</span><span class="lines">@@ -43,6 +43,7 @@
</span><span class="cx"> #include "JSONObject.h"
</span><span class="cx"> #include "JSProxy.h"
</span><span class="cx"> #include "JSString.h"
</span><ins>+#include "JSWASMModule.h"
</ins><span class="cx"> #include "ProfilerDatabase.h"
</span><span class="cx"> #include "SamplingTool.h"
</span><span class="cx"> #include "StackVisitor.h"
</span><span class="lines">@@ -50,6 +51,7 @@
</span><span class="cx"> #include "StructureRareDataInlines.h"
</span><span class="cx"> #include "TestRunnerUtils.h"
</span><span class="cx"> #include "TypeProfilerLog.h"
</span><ins>+#include "WASMModuleParser.h"
</ins><span class="cx"> #include <math.h>
</span><span class="cx"> #include <stdio.h>
</span><span class="cx"> #include <stdlib.h>
</span><span class="lines">@@ -492,6 +494,9 @@
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL functionDumpBasicBlockExecutionRanges(ExecState*);
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL functionHasBasicBlockExecuted(ExecState*);
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL functionEnableExceptionFuzz(ExecState*);
</span><ins>+#if ENABLE(WEBASSEMBLY)
+static EncodedJSValue JSC_HOST_CALL functionLoadWebAssembly(ExecState*);
+#endif
</ins><span class="cx">
</span><span class="cx"> #if ENABLE(SAMPLING_FLAGS)
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL functionSetSamplingFlags(ExecState*);
</span><span class="lines">@@ -655,6 +660,10 @@
</span><span class="cx">
</span><span class="cx"> addFunction(vm, "enableExceptionFuzz", functionEnableExceptionFuzz, 0);
</span><span class="cx">
</span><ins>+#if ENABLE(WEBASSEMBLY)
+ addFunction(vm, "loadWebAssembly", functionLoadWebAssembly, 1);
+#endif
+
</ins><span class="cx"> JSArray* array = constructEmptyArray(globalExec(), 0);
</span><span class="cx"> for (size_t i = 0; i < arguments.size(); ++i)
</span><span class="cx"> array->putDirectIndex(globalExec(), i, jsString(globalExec(), arguments[i]));
</span><span class="lines">@@ -1183,6 +1192,23 @@
</span><span class="cx"> return JSValue::encode(jsUndefined());
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if ENABLE(WEBASSEMBLY)
+EncodedJSValue JSC_HOST_CALL functionLoadWebAssembly(ExecState* exec)
+{
+ String fileName = exec->argument(0).toString(exec)->value(exec);
+ Vector<char> buffer;
+ if (!fillBufferWithContentsOfFile(fileName, buffer))
+ return JSValue::encode(exec->vm().throwException(exec, createError(exec, ASCIILiteral("Could not open file."))));
+ RefPtr<WebAssemblySourceProvider> sourceProvider = WebAssemblySourceProvider::create(reinterpret_cast<Vector<uint8_t>&>(buffer), fileName);
+ SourceCode source(sourceProvider);
+ String errorMessage;
+ JSWASMModule* module = parseWebAssembly(exec, source, errorMessage);
+ if (!module)
+ return JSValue::encode(exec->vm().throwException(exec, createSyntaxError(exec, errorMessage)));
+ return JSValue::encode(module);
+}
+#endif
+
</ins><span class="cx"> // Use SEH for Release builds only to get rid of the crash report dialog
</span><span class="cx"> // (luckily the same tests fail in Release and Debug builds so far). Need to
</span><span class="cx"> // be in a separate main function because the jscmain function requires object
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserSourceProviderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/SourceProvider.h (187549 => 187550)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/SourceProvider.h        2015-07-29 17:52:44 UTC (rev 187549)
+++ trunk/Source/JavaScriptCore/parser/SourceProvider.h        2015-07-29 19:03:34 UTC (rev 187550)
</span><span class="lines">@@ -94,6 +94,37 @@
</span><span class="cx"> String m_source;
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+#if ENABLE(WEBASSEMBLY)
+ class WebAssemblySourceProvider : public SourceProvider {
+ public:
+ static Ref<WebAssemblySourceProvider> create(const Vector<uint8_t>& data, const String& url)
+ {
+ return adoptRef(*new WebAssemblySourceProvider(data, url));
+ }
+
+ virtual const String& source() const override
+ {
+ return m_source;
+ }
+
+ const Vector<uint8_t>& data() const
+ {
+ return m_data;
+ }
+
+ private:
+ WebAssemblySourceProvider(const Vector<uint8_t>& data, const String& url)
+ : SourceProvider(url, TextPosition::minimumPosition())
+ , m_source("[WebAssembly source]")
+ , m_data(data)
+ {
+ }
+
+ String m_source;
+ Vector<uint8_t> m_data;
+ };
+#endif
+
</ins><span class="cx"> } // namespace JSC
</span><span class="cx">
</span><span class="cx"> #endif // SourceProvider_h
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSGlobalObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp (187549 => 187550)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp        2015-07-29 17:52:44 UTC (rev 187549)
+++ trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp        2015-07-29 19:03:34 UTC (rev 187550)
</span><span class="lines">@@ -92,6 +92,7 @@
</span><span class="cx"> #include "JSTypedArrayConstructors.h"
</span><span class="cx"> #include "JSTypedArrayPrototypes.h"
</span><span class="cx"> #include "JSTypedArrays.h"
</span><ins>+#include "JSWASMModule.h"
</ins><span class="cx"> #include "JSWeakMap.h"
</span><span class="cx"> #include "JSWeakSet.h"
</span><span class="cx"> #include "JSWithScope.h"
</span><span class="lines">@@ -340,6 +341,10 @@
</span><span class="cx"> m_promisePrototype.set(vm, this, JSPromisePrototype::create(exec, this, JSPromisePrototype::createStructure(vm, this, m_objectPrototype.get())));
</span><span class="cx"> m_promiseStructure.set(vm, this, JSPromise::createStructure(vm, this, m_promisePrototype.get()));
</span><span class="cx">
</span><ins>+#if ENABLE(WEBASSEMBLY)
+ m_wasmModuleStructure.set(vm, this, JSWASMModule::createStructure(vm, this));
+#endif
+
</ins><span class="cx"> m_parseIntFunction.set(vm, this, JSFunction::create(vm, this, 2, vm.propertyNames->parseInt.string(), globalFuncParseInt, NoIntrinsic));
</span><span class="cx"> putDirectWithoutTransition(vm, vm.propertyNames->parseInt, m_parseIntFunction.get(), DontEnum | Function);
</span><span class="cx">
</span><span class="lines">@@ -801,6 +806,9 @@
</span><span class="cx"> visitor.append(&thisObject->m_dollarVMStructure);
</span><span class="cx"> visitor.append(&thisObject->m_internalFunctionStructure);
</span><span class="cx"> visitor.append(&thisObject->m_promiseStructure);
</span><ins>+#if ENABLE(WEBASSEMBLY)
+ visitor.append(&thisObject->m_wasmModuleStructure);
+#endif
</ins><span class="cx">
</span><span class="cx"> #define VISIT_SIMPLE_TYPE(CapitalName, lowerName, properName, instanceType, jsName) \
</span><span class="cx"> visitor.append(&thisObject->m_ ## lowerName ## Prototype); \
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSGlobalObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h (187549 => 187550)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h        2015-07-29 17:52:44 UTC (rev 187549)
+++ trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h        2015-07-29 19:03:34 UTC (rev 187550)
</span><span class="lines">@@ -243,6 +243,9 @@
</span><span class="cx"> WriteBarrier<Structure> m_iteratorResultStructure;
</span><span class="cx"> WriteBarrier<Structure> m_regExpMatchesArrayStructure;
</span><span class="cx"> WriteBarrier<Structure> m_promiseStructure;
</span><ins>+#if ENABLE(WEBASSEMBLY)
+ WriteBarrier<Structure> m_wasmModuleStructure;
+#endif
</ins><span class="cx">
</span><span class="cx"> #define DEFINE_STORAGE_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
</span><span class="cx"> WriteBarrier<capitalName ## Prototype> m_ ## lowerName ## Prototype; \
</span><span class="lines">@@ -475,6 +478,9 @@
</span><span class="cx"> static ptrdiff_t iteratorResultStructureOffset() { return OBJECT_OFFSETOF(JSGlobalObject, m_iteratorResultStructure); }
</span><span class="cx"> Structure* regExpMatchesArrayStructure() const { return m_regExpMatchesArrayStructure.get(); }
</span><span class="cx"> Structure* promiseStructure() const { return m_promiseStructure.get(); }
</span><ins>+#if ENABLE(WEBASSEMBLY)
+ Structure* wasmModuleStructure() const { return m_wasmModuleStructure.get(); }
+#endif
</ins><span class="cx">
</span><span class="cx"> JS_EXPORT_PRIVATE void setRemoteDebuggingEnabled(bool);
</span><span class="cx"> JS_EXPORT_PRIVATE bool remoteDebuggingEnabled() const;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWASMMagicNumberh"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/wasm/WASMMagicNumber.h (0 => 187550)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WASMMagicNumber.h         (rev 0)
+++ trunk/Source/JavaScriptCore/wasm/WASMMagicNumber.h        2015-07-29 19:03:34 UTC (rev 187550)
</span><span class="lines">@@ -0,0 +1,39 @@
</span><ins>+/*
+ * Copyright (C) 2015 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 WASMMagicNumber_h
+#define WASMMagicNumber_h
+
+#if ENABLE(WEBASSEMBLY)
+
+namespace JSC {
+
+static const uint32_t wasmMagicNumber = 0x6d736177;
+
+} // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
+
+#endif // WASMMagicNumber_h
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWASMModuleParsercpp"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/wasm/WASMModuleParser.cpp (0 => 187550)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WASMModuleParser.cpp         (rev 0)
+++ trunk/Source/JavaScriptCore/wasm/WASMModuleParser.cpp        2015-07-29 19:03:34 UTC (rev 187550)
</span><span class="lines">@@ -0,0 +1,78 @@
</span><ins>+/*
+ * Copyright (C) 2015 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 "WASMModuleParser.h"
+
+#if ENABLE(WEBASSEMBLY)
+
+#include "JSCInlines.h"
+#include "JSWASMModule.h"
+#include "WASMMagicNumber.h"
+
+#define FAIL_WITH_MESSAGE(errorMessage) do { m_errorMessage = errorMessage; return false; } while (0)
+#define READ_UNSIGNED_INT32_OR_FAIL(x, errorMessage) do { if (!m_reader.readUnsignedInt32(x)) FAIL_WITH_MESSAGE(errorMessage); } while (0)
+#define READ_FLOAT_OR_FAIL(x, errorMessage) do { if (!m_reader.readFloat(x)) FAIL_WITH_MESSAGE(errorMessage); } while (0)
+#define READ_DOUBLE_OR_FAIL(x, errorMessage) do { if (!m_reader.readDouble(x)) FAIL_WITH_MESSAGE(errorMessage); } while (0)
+#define FAIL_IF_FALSE(condition, errorMessage) do { if (!(condition)) FAIL_WITH_MESSAGE(errorMessage); } while (0)
+
+namespace JSC {
+
+WASMModuleParser::WASMModuleParser(const SourceCode& source)
+ : m_reader(static_cast<WebAssemblySourceProvider*>(source.provider())->data())
+{
+}
+
+JSWASMModule* WASMModuleParser::parse(VM& vm, JSGlobalObject* globalObject, String& errorMessage)
+{
+ JSWASMModule* module = JSWASMModule::create(vm, globalObject->wasmModuleStructure());
+ parseModule();
+ if (!m_errorMessage.isNull()) {
+ errorMessage = m_errorMessage;
+ return nullptr;
+ }
+ return module;
+}
+
+bool WASMModuleParser::parseModule()
+{
+ uint32_t magicNumber;
+ READ_UNSIGNED_INT32_OR_FAIL(magicNumber, "Cannot read the magic number.");
+ FAIL_IF_FALSE(magicNumber == wasmMagicNumber, "The magic number is incorrect.");
+
+ // TODO: parse the rest
+
+ return true;
+}
+
+JSWASMModule* parseWebAssembly(ExecState* exec, const SourceCode& source, String& errorMessage)
+{
+ WASMModuleParser WASMModuleParser(source);
+ return WASMModuleParser.parse(exec->vm(), exec->lexicalGlobalObject(), errorMessage);
+}
+
+} // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWASMModuleParserh"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/wasm/WASMModuleParser.h (0 => 187550)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WASMModuleParser.h         (rev 0)
+++ trunk/Source/JavaScriptCore/wasm/WASMModuleParser.h        2015-07-29 19:03:34 UTC (rev 187550)
</span><span class="lines">@@ -0,0 +1,60 @@
</span><ins>+/*
+ * Copyright (C) 2015 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 WASMModuleParser_h
+#define WASMModuleParser_h
+
+#if ENABLE(WEBASSEMBLY)
+
+#include "WASMReader.h"
+#include <wtf/text/WTFString.h>
+
+namespace JSC {
+
+class ExecState;
+class JSGlobalObject;
+class JSWASMModule;
+class SourceCode;
+class VM;
+
+class WASMModuleParser {
+public:
+ WASMModuleParser(const SourceCode&);
+ JSWASMModule* parse(VM&, JSGlobalObject*, String& errorMessage);
+
+private:
+ bool parseModule();
+
+ WASMReader m_reader;
+ String m_errorMessage;
+};
+
+JS_EXPORT_PRIVATE JSWASMModule* parseWebAssembly(ExecState*, const SourceCode&, String& errorMessage);
+
+} // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
+
+#endif // WASMModuleParser_h
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWASMReadercpp"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/wasm/WASMReader.cpp (0 => 187550)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WASMReader.cpp         (rev 0)
+++ trunk/Source/JavaScriptCore/wasm/WASMReader.cpp        2015-07-29 19:03:34 UTC (rev 187550)
</span><span class="lines">@@ -0,0 +1,81 @@
</span><ins>+/*
+ * Copyright (C) 2015 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 "WASMReader.h"
+
+#if ENABLE(WEBASSEMBLY)
+
+#define CHECK_READ(length) do { if (m_cursor + length > m_buffer.end()) return false; } while (0)
+
+namespace JSC {
+
+bool WASMReader::readUnsignedInt32(uint32_t& result)
+{
+ CHECK_READ(4);
+ result = m_cursor[0] | m_cursor[1] << 8 | m_cursor[2] << 16 | m_cursor[3] << 24;
+ m_cursor += 4;
+ return true;
+}
+
+bool WASMReader::readFloat(float& result)
+{
+ CHECK_READ(4);
+ union {
+ uint8_t bytes[4];
+ float floatValue;
+ } u = {
+#if CPU(BIG_ENDIAN)
+ { m_cursor[3], m_cursor[2], m_cursor[1], m_cursor[0] }
+#else
+ { m_cursor[0], m_cursor[1], m_cursor[2], m_cursor[3] }
+#endif
+ };
+ result = u.floatValue;
+ m_cursor += 4;
+ return true;
+}
+
+bool WASMReader::readDouble(double& result)
+{
+ CHECK_READ(8);
+ union {
+ uint8_t bytes[8];
+ double doubleValue;
+ } u = {
+#if CPU(BIG_ENDIAN)
+ { m_cursor[7], m_cursor[6], m_cursor[5], m_cursor[4], m_cursor[3], m_cursor[2], m_cursor[1], m_cursor[0] }
+#else
+ { m_cursor[0], m_cursor[1], m_cursor[2], m_cursor[3], m_cursor[4], m_cursor[5], m_cursor[6], m_cursor[7] }
+#endif
+ };
+ result = u.doubleValue;
+ m_cursor += 8;
+ return true;
+}
+
+} // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWASMReaderh"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/wasm/WASMReader.h (0 => 187550)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WASMReader.h         (rev 0)
+++ trunk/Source/JavaScriptCore/wasm/WASMReader.h        2015-07-29 19:03:34 UTC (rev 187550)
</span><span class="lines">@@ -0,0 +1,56 @@
</span><ins>+/*
+ * Copyright (C) 2015 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 WASMReader_h
+#define WASMReader_h
+
+#if ENABLE(WEBASSEMBLY)
+
+#include <wtf/Vector.h>
+
+namespace JSC {
+
+class WASMReader {
+public:
+ WASMReader(const Vector<uint8_t>& buffer)
+ : m_buffer(buffer)
+ , m_cursor(buffer.data())
+ {
+ }
+
+ bool readUnsignedInt32(uint32_t& result);
+ bool readFloat(float& result);
+ bool readDouble(double& result);
+
+private:
+ const Vector<uint8_t>& m_buffer;
+ const uint8_t* m_cursor;
+};
+
+} // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
+
+#endif // WASMReader_h
</ins></span></pre>
</div>
</div>
</body>
</html>