<!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>[189892] 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/189892">189892</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-09-16 18:23:20 -0700 (Wed, 16 Sep 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Implement indirect calls in WebAssembly
https://bugs.webkit.org/show_bug.cgi?id=149100
Patch by Sukolsak Sakshuwong <sukolsak@gmail.com> on 2015-09-16
Reviewed by Geoffrey Garen.
This patch implement indirect calls for WebAssembly files generated by
pack-asmjs <https://github.com/WebAssembly/polyfill-prototype-1>.
pack-asmjs uses the same indirect call model as asm.js. In asm.js, an
indirect call looks like this:
t[i & n](...)
where t is a variable referring to an array of functions with the same
signature, i is an integer expression, n is an integer that is equal to
(t.length - 1), and t.length is a power of two. pack-asmjs does not
use the '&' operator nor n in the WebAssembly output, but the semantics
is still the same as asm.js.
* tests/stress/wasm-calls.js:
* tests/stress/wasm/calls.wasm:
* wasm/WASMFormat.h:
* wasm/WASMFunctionCompiler.h:
(JSC::WASMFunctionCompiler::buildCallIndirect):
* wasm/WASMFunctionParser.cpp:
(JSC::WASMFunctionParser::parseExpressionI32):
(JSC::WASMFunctionParser::parseExpressionF32):
(JSC::WASMFunctionParser::parseExpressionF64):
(JSC::WASMFunctionParser::parseCallIndirect):
* wasm/WASMFunctionParser.h:
* wasm/WASMFunctionSyntaxChecker.h:
(JSC::WASMFunctionSyntaxChecker::buildCallIndirect):
* wasm/WASMModuleParser.cpp:
(JSC::WASMModuleParser::parseFunctionPointerTableSection):
(JSC::WASMModuleParser::parseFunctionDefinitionSection):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstresswasmcallswasm">trunk/Source/JavaScriptCore/tests/stress/wasm/calls.wasm</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstresswasmcallsjs">trunk/Source/JavaScriptCore/tests/stress/wasm-calls.js</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWASMFormath">trunk/Source/JavaScriptCore/wasm/WASMFormat.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWASMFunctionCompilerh">trunk/Source/JavaScriptCore/wasm/WASMFunctionCompiler.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWASMFunctionParsercpp">trunk/Source/JavaScriptCore/wasm/WASMFunctionParser.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWASMFunctionParserh">trunk/Source/JavaScriptCore/wasm/WASMFunctionParser.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWASMFunctionSyntaxCheckerh">trunk/Source/JavaScriptCore/wasm/WASMFunctionSyntaxChecker.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWASMModuleParsercpp">trunk/Source/JavaScriptCore/wasm/WASMModuleParser.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (189891 => 189892)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-09-17 01:16:09 UTC (rev 189891)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-09-17 01:23:20 UTC (rev 189892)
</span><span class="lines">@@ -1,5 +1,40 @@
</span><span class="cx"> 2015-09-16 Sukolsak Sakshuwong <sukolsak@gmail.com>
</span><span class="cx">
</span><ins>+ Implement indirect calls in WebAssembly
+ https://bugs.webkit.org/show_bug.cgi?id=149100
+
+ Reviewed by Geoffrey Garen.
+
+ This patch implement indirect calls for WebAssembly files generated by
+ pack-asmjs <https://github.com/WebAssembly/polyfill-prototype-1>.
+ pack-asmjs uses the same indirect call model as asm.js. In asm.js, an
+ indirect call looks like this:
+ t[i & n](...)
+ where t is a variable referring to an array of functions with the same
+ signature, i is an integer expression, n is an integer that is equal to
+ (t.length - 1), and t.length is a power of two. pack-asmjs does not
+ use the '&' operator nor n in the WebAssembly output, but the semantics
+ is still the same as asm.js.
+
+ * tests/stress/wasm-calls.js:
+ * tests/stress/wasm/calls.wasm:
+ * wasm/WASMFormat.h:
+ * wasm/WASMFunctionCompiler.h:
+ (JSC::WASMFunctionCompiler::buildCallIndirect):
+ * wasm/WASMFunctionParser.cpp:
+ (JSC::WASMFunctionParser::parseExpressionI32):
+ (JSC::WASMFunctionParser::parseExpressionF32):
+ (JSC::WASMFunctionParser::parseExpressionF64):
+ (JSC::WASMFunctionParser::parseCallIndirect):
+ * wasm/WASMFunctionParser.h:
+ * wasm/WASMFunctionSyntaxChecker.h:
+ (JSC::WASMFunctionSyntaxChecker::buildCallIndirect):
+ * wasm/WASMModuleParser.cpp:
+ (JSC::WASMModuleParser::parseFunctionPointerTableSection):
+ (JSC::WASMModuleParser::parseFunctionDefinitionSection):
+
+2015-09-16 Sukolsak Sakshuwong <sukolsak@gmail.com>
+
</ins><span class="cx"> Fix 32-bit build issues in WebAssembly
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=149240
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstresswasmcallswasm"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/tests/stress/wasm/calls.wasm (189891 => 189892)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/wasm/calls.wasm        2015-09-17 01:16:09 UTC (rev 189891)
+++ trunk/Source/JavaScriptCore/tests/stress/wasm/calls.wasm        2015-09-17 01:23:20 UTC (rev 189892)
</span><span class="lines">@@ -1 +1,2 @@
</span><del>-wasm\x82summax\x808\xC0\xA1\xA1\xC0\xA1\xC0\xA2\x80.\xC1\xA0\xC0\xC1#\xC0\xC1\x80! \xC0\xC1\xC0\xC1\x80\xC0\xC1\x80\xC0\xC1fibonaccigcdlcmcallSumcallMax
</del><span class="cx">\ No newline at end of file
</span><ins>+wasm\xB3summax
+\x808\xC0\xA1\xA1\xC0\xA1\xC0\xA2\x80.\xC1\xA0\xC0\xC1#\xC0\xC1\x80! \xC0\xC1\xC0\xC1\x80\xC0\xC1\xC0\xC1\x80\xC0\xC1\x80 \xC0\xC1\x80!\xC0\xC1\x80\xC0\xC1\x80\xC0\xC1fibonaccigcdlcmaddSubMulDivcallSumcallMax        
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstresswasmcallsjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/tests/stress/wasm-calls.js (189891 => 189892)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/wasm-calls.js        2015-09-17 01:16:09 UTC (rev 189891)
+++ trunk/Source/JavaScriptCore/tests/stress/wasm-calls.js        2015-09-17 01:23:20 UTC (rev 189892)
</span><span class="lines">@@ -36,6 +36,37 @@
</span><span class="cx"> return (imul(x, y) / (gcd(x, y) | 0)) | 0;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ function addSubMulDiv(i, x, y) {
+ i = i | 0;
+ x = x | 0;
+ y = y | 0;
+ return addSubMulDivTable[i & 3](x, y) | 0;
+ }
+
+ function add(x, y) {
+ x = x | 0;
+ y = y | 0;
+ return (x + y) | 0;
+ }
+
+ function sub(x, y) {
+ x = x | 0;
+ y = y | 0;
+ return (x - y) | 0;
+ }
+
+ function mul(x, y) {
+ x = x | 0;
+ y = y | 0;
+ return imul(x, y);
+ }
+
+ function div(x, y) {
+ x = x | 0;
+ y = y | 0;
+ return ((x | 0) / (y | 0)) | 0;
+ }
+
</ins><span class="cx"> function callSum(x, y) {
</span><span class="cx"> x = x | 0;
</span><span class="cx"> y = y | 0;
</span><span class="lines">@@ -48,10 +79,15 @@
</span><span class="cx"> return max(x | 0, y | 0) | 0;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ var addSubMulDivTable = [add, sub, mul, div];
+
</ins><span class="cx"> return {
</span><span class="cx"> fibonacci: fibonacci,
</span><span class="cx"> gcd: gcd,
</span><span class="cx"> lcm: lcm,
</span><ins>+
+ addSubMulDiv: addSubMulDiv,
+
</ins><span class="cx"> callSum: callSum,
</span><span class="cx"> callMax: callMax,
</span><span class="cx"> };
</span><span class="lines">@@ -68,5 +104,13 @@
</span><span class="cx"> shouldBe(module.gcd(15, 25), 5);
</span><span class="cx"> shouldBe(module.lcm(15, 25), 75);
</span><span class="cx">
</span><ins>+shouldBe(module.addSubMulDiv(0, 6, 2), 8);
+shouldBe(module.addSubMulDiv(1, 6, 2), 4);
+shouldBe(module.addSubMulDiv(2, 6, 2), 12);
+shouldBe(module.addSubMulDiv(3, 6, 2), 3);
+shouldBe(module.addSubMulDiv(4, 6, 2), 8);
+shouldBe(module.addSubMulDiv(10, 6, 2), 12);
+shouldBe(module.addSubMulDiv(-1, 6, 2), 3);
+
</ins><span class="cx"> shouldBe(module.callSum(1, 2), 3);
</span><span class="cx"> shouldBe(module.callMax(1, 2), 2);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWASMFormath"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WASMFormat.h (189891 => 189892)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WASMFormat.h        2015-09-17 01:16:09 UTC (rev 189891)
+++ trunk/Source/JavaScriptCore/wasm/WASMFormat.h        2015-09-17 01:23:20 UTC (rev 189892)
</span><span class="lines">@@ -50,6 +50,8 @@
</span><span class="cx">
</span><span class="cx"> namespace JSC {
</span><span class="cx">
</span><ins>+class JSFunction;
+
</ins><span class="cx"> enum class WASMType : uint8_t {
</span><span class="cx"> I32,
</span><span class="cx"> F32,
</span><span class="lines">@@ -85,7 +87,8 @@
</span><span class="cx">
</span><span class="cx"> struct WASMFunctionPointerTable {
</span><span class="cx"> uint32_t signatureIndex;
</span><del>- Vector<uint32_t> elements;
</del><ins>+ Vector<uint32_t> functionIndices;
+ Vector<JSFunction*> functions;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWASMFunctionCompilerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WASMFunctionCompiler.h (189891 => 189892)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WASMFunctionCompiler.h        2015-09-17 01:16:09 UTC (rev 189891)
+++ trunk/Source/JavaScriptCore/wasm/WASMFunctionCompiler.h        2015-09-17 01:23:20 UTC (rev 189892)
</span><span class="lines">@@ -671,6 +671,21 @@
</span><span class="cx"> return UNUSED;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ int buildCallIndirect(uint32_t functionPointerTableIndex, int, int, const WASMSignature& signature, WASMExpressionType returnType)
+ {
+ boxArgumentsAndAdjustStackPointer(signature.arguments);
+
+ const Vector<JSFunction*>& functions = m_module->functionPointerTables()[functionPointerTableIndex].functions;
+ move(TrustedImmPtr(functions.data()), GPRInfo::regT0);
+ load32(temporaryAddress(m_tempStackTop - 1), GPRInfo::regT1);
+ m_tempStackTop--;
+ and32(TrustedImm32(functions.size() - 1), GPRInfo::regT1);
+ loadPtr(BaseIndex(GPRInfo::regT0, GPRInfo::regT1, timesPtr()), GPRInfo::regT0);
+
+ callAndUnboxResult(returnType);
+ return UNUSED;
+ }
+
</ins><span class="cx"> int buildCallImport(uint32_t functionImportIndex, int, const WASMSignature& signature, WASMExpressionType returnType)
</span><span class="cx"> {
</span><span class="cx"> boxArgumentsAndAdjustStackPointer(signature.arguments);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWASMFunctionParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WASMFunctionParser.cpp (189891 => 189892)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WASMFunctionParser.cpp        2015-09-17 01:16:09 UTC (rev 189891)
+++ trunk/Source/JavaScriptCore/wasm/WASMFunctionParser.cpp        2015-09-17 01:23:20 UTC (rev 189892)
</span><span class="lines">@@ -530,6 +530,8 @@
</span><span class="cx"> return parseGetGlobalExpressionI32(context);
</span><span class="cx"> case WASMOpExpressionI32::CallInternal:
</span><span class="cx"> return parseCallInternalExpressionI32(context);
</span><ins>+ case WASMOpExpressionI32::CallIndirect:
+ return parseCallIndirect(context, WASMExpressionType::I32);
</ins><span class="cx"> case WASMOpExpressionI32::CallImport:
</span><span class="cx"> return parseCallImport(context, WASMExpressionType::I32);
</span><span class="cx"> case WASMOpExpressionI32::Negate:
</span><span class="lines">@@ -595,7 +597,6 @@
</span><span class="cx"> case WASMOpExpressionI32::StoreWithOffset16:
</span><span class="cx"> case WASMOpExpressionI32::Store32:
</span><span class="cx"> case WASMOpExpressionI32::StoreWithOffset32:
</span><del>- case WASMOpExpressionI32::CallIndirect:
</del><span class="cx"> case WASMOpExpressionI32::Conditional:
</span><span class="cx"> case WASMOpExpressionI32::Comma:
</span><span class="cx"> case WASMOpExpressionI32::FromF32:
</span><span class="lines">@@ -751,6 +752,8 @@
</span><span class="cx"> return parseGetLocalExpressionF32(context);
</span><span class="cx"> case WASMOpExpressionF32::GetGlobal:
</span><span class="cx"> return parseGetGlobalExpressionF32(context);
</span><ins>+ case WASMOpExpressionF32::CallIndirect:
+ return parseCallIndirect(context, WASMExpressionType::F32);
</ins><span class="cx"> case WASMOpExpressionF32::Negate:
</span><span class="cx"> case WASMOpExpressionF32::Abs:
</span><span class="cx"> case WASMOpExpressionF32::Ceil:
</span><span class="lines">@@ -769,7 +772,6 @@
</span><span class="cx"> case WASMOpExpressionF32::Store:
</span><span class="cx"> case WASMOpExpressionF32::StoreWithOffset:
</span><span class="cx"> case WASMOpExpressionF32::CallInternal:
</span><del>- case WASMOpExpressionF32::CallIndirect:
</del><span class="cx"> case WASMOpExpressionF32::Conditional:
</span><span class="cx"> case WASMOpExpressionF32::Comma:
</span><span class="cx"> case WASMOpExpressionF32::FromS32:
</span><span class="lines">@@ -880,6 +882,8 @@
</span><span class="cx"> return parseGetGlobalExpressionF64(context);
</span><span class="cx"> case WASMOpExpressionF64::CallImport:
</span><span class="cx"> return parseCallImport(context, WASMExpressionType::F64);
</span><ins>+ case WASMOpExpressionF64::CallIndirect:
+ return parseCallIndirect(context, WASMExpressionType::F64);
</ins><span class="cx"> case WASMOpExpressionF64::SetLocal:
</span><span class="cx"> case WASMOpExpressionF64::SetGlobal:
</span><span class="cx"> case WASMOpExpressionF64::Load:
</span><span class="lines">@@ -887,7 +891,6 @@
</span><span class="cx"> case WASMOpExpressionF64::Store:
</span><span class="cx"> case WASMOpExpressionF64::StoreWithOffset:
</span><span class="cx"> case WASMOpExpressionF64::CallInternal:
</span><del>- case WASMOpExpressionF64::CallIndirect:
</del><span class="cx"> case WASMOpExpressionF64::Conditional:
</span><span class="cx"> case WASMOpExpressionF64::Comma:
</span><span class="cx"> case WASMOpExpressionF64::FromS32:
</span><span class="lines">@@ -1009,6 +1012,24 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <class Context>
</span><ins>+ContextExpression WASMFunctionParser::parseCallIndirect(Context& context, WASMExpressionType returnType)
+{
+ uint32_t functionPointerTableIndex;
+ READ_COMPACT_UINT32_OR_FAIL(functionPointerTableIndex, "Cannot read the function pointer table index.");
+ FAIL_IF_FALSE(functionPointerTableIndex < m_module->functionPointerTables().size(), "The function pointer table index is incorrect.");
+ const WASMFunctionPointerTable& functionPointerTable = m_module->functionPointerTables()[functionPointerTableIndex];
+ const WASMSignature& signature = m_module->signatures()[functionPointerTable.signatureIndex];
+ FAIL_IF_FALSE(signature.returnType == returnType, "Wrong return type.");
+
+ ContextExpression index = parseExpressionI32(context);
+ PROPAGATE_ERROR();
+
+ ContextExpressionList argumentList = parseCallArguments(context, signature.arguments);
+ PROPAGATE_ERROR();
+ return context.buildCallIndirect(functionPointerTableIndex, index, argumentList, signature, returnType);
+}
+
+template <class Context>
</ins><span class="cx"> ContextExpression WASMFunctionParser::parseCallImport(Context& context, WASMExpressionType returnType)
</span><span class="cx"> {
</span><span class="cx"> uint32_t functionImportSignatureIndex;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWASMFunctionParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WASMFunctionParser.h (189891 => 189892)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WASMFunctionParser.h        2015-09-17 01:16:09 UTC (rev 189891)
+++ trunk/Source/JavaScriptCore/wasm/WASMFunctionParser.h        2015-09-17 01:23:20 UTC (rev 189892)
</span><span class="lines">@@ -116,6 +116,7 @@
</span><span class="cx">
</span><span class="cx"> template <class Context> ContextExpressionList parseCallArguments(Context&, const Vector<WASMType>& arguments);
</span><span class="cx"> template <class Context> ContextExpression parseCallInternal(Context&, WASMExpressionType returnType);
</span><ins>+ template <class Context> ContextExpression parseCallIndirect(Context&, WASMExpressionType returnType);
</ins><span class="cx"> template <class Context> ContextExpression parseCallImport(Context&, WASMExpressionType returnType);
</span><span class="cx">
</span><span class="cx"> JSWASMModule* m_module;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWASMFunctionSyntaxCheckerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WASMFunctionSyntaxChecker.h (189891 => 189892)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WASMFunctionSyntaxChecker.h        2015-09-17 01:16:09 UTC (rev 189891)
+++ trunk/Source/JavaScriptCore/wasm/WASMFunctionSyntaxChecker.h        2015-09-17 01:23:20 UTC (rev 189892)
</span><span class="lines">@@ -165,6 +165,16 @@
</span><span class="cx"> return UNUSED;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ int buildCallIndirect(uint32_t, int, int, const WASMSignature& signature, WASMExpressionType returnType)
+ {
+ size_t argumentCount = signature.arguments.size();
+ updateTempStackHeightForCall(argumentCount);
+ m_tempStackTop -= argumentCount + 1;
+ if (returnType != WASMExpressionType::Void)
+ m_tempStackTop++;
+ return UNUSED;
+ }
+
</ins><span class="cx"> void appendExpressionList(int&, int) { }
</span><span class="cx">
</span><span class="cx"> void linkTarget(const int&) { }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWASMModuleParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WASMModuleParser.cpp (189891 => 189892)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WASMModuleParser.cpp        2015-09-17 01:16:09 UTC (rev 189891)
+++ trunk/Source/JavaScriptCore/wasm/WASMModuleParser.cpp        2015-09-17 01:23:20 UTC (rev 189892)
</span><span class="lines">@@ -271,14 +271,17 @@
</span><span class="cx"> WASMFunctionPointerTable functionPointerTable;
</span><span class="cx"> READ_COMPACT_UINT32_OR_FAIL(functionPointerTable.signatureIndex, "Cannot read the signature index.");
</span><span class="cx"> FAIL_IF_FALSE(functionPointerTable.signatureIndex < m_module->signatures().size(), "The signature index is incorrect.");
</span><del>- uint32_t numberOfElements;
- READ_COMPACT_UINT32_OR_FAIL(numberOfElements, "Cannot read the number of elements of a function pointer table.");
- FAIL_IF_FALSE(hasOneBitSet(numberOfElements), "The number of elements must be a power of two.");
- functionPointerTable.elements.reserveInitialCapacity(numberOfElements);
- for (uint32_t j = 0; j < numberOfElements; ++j) {
- uint32_t element;
- READ_COMPACT_UINT32_OR_FAIL(element, "Cannot read an element of a function pointer table.");
- functionPointerTable.elements.uncheckedAppend(element);
</del><ins>+ uint32_t numberOfFunctions;
+ READ_COMPACT_UINT32_OR_FAIL(numberOfFunctions, "Cannot read the number of functions of a function pointer table.");
+ FAIL_IF_FALSE(hasOneBitSet(numberOfFunctions), "The number of functions must be a power of two.");
+ functionPointerTable.functionIndices.reserveInitialCapacity(numberOfFunctions);
+ functionPointerTable.functions.reserveInitialCapacity(numberOfFunctions);
+ for (uint32_t j = 0; j < numberOfFunctions; ++j) {
+ uint32_t functionIndex;
+ READ_COMPACT_UINT32_OR_FAIL(functionIndex, "Cannot read a function index of a function pointer table.");
+ FAIL_IF_FALSE(functionIndex < m_module->functionDeclarations().size(), "The function index is incorrect.");
+ FAIL_IF_FALSE(m_module->functionDeclarations()[functionIndex].signatureIndex == functionPointerTable.signatureIndex, "The signature of the function doesn't match that of the function pointer table.");
+ functionPointerTable.functionIndices.uncheckedAppend(functionIndex);
</ins><span class="cx"> }
</span><span class="cx"> m_module->functionPointerTables().uncheckedAppend(functionPointerTable);
</span><span class="cx"> }
</span><span class="lines">@@ -290,6 +293,11 @@
</span><span class="cx"> parseFunctionDefinition(functionIndex);
</span><span class="cx"> PROPAGATE_ERROR();
</span><span class="cx"> }
</span><ins>+
+ for (WASMFunctionPointerTable& functionPointerTable : m_module->functionPointerTables()) {
+ for (size_t i = 0; i < functionPointerTable.functionIndices.size(); ++i)
+ functionPointerTable.functions.uncheckedAppend(m_module->functions()[functionPointerTable.functionIndices[i]].get());
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WASMModuleParser::parseFunctionDefinition(size_t functionIndex)
</span></span></pre>
</div>
</div>
</body>
</html>