<!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>[189584] 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/189584">189584</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-09-10 12:34:40 -0700 (Thu, 10 Sep 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Implement global variables in WebAssembly
https://bugs.webkit.org/show_bug.cgi?id=149031
Patch by Sukolsak Sakshuwong <sukolsak@gmail.com> on 2015-09-10
Reviewed by Geoffrey Garen.
This patch implements global variables in WebAssembly. There are two
types of global variables in the current format that we use (the format
used by <https://github.com/WebAssembly/polyfill-prototype-1>): internal
global variables and imported global variables. This patch does not yet
import values for imported global variables. It will be done in a
subsequent patch.
* tests/stress/wasm-globals.js: Added.
(shouldBe):
* tests/stress/wasm/globals.wasm: Added.
* wasm/JSWASMModule.h:
(JSC::JSWASMModule::globalVariables):
* wasm/WASMFunctionCompiler.h:
(JSC::WASMFunctionCompiler::buildSetGlobal):
(JSC::WASMFunctionCompiler::buildGetGlobal):
* wasm/WASMFunctionParser.cpp:
(JSC::WASMFunctionParser::parseStatement):
(JSC::WASMFunctionParser::parseSetGlobalStatement):
(JSC::WASMFunctionParser::parseExpressionI32):
(JSC::WASMFunctionParser::parseGetGlobalExpressionI32):
(JSC::WASMFunctionParser::parseExpressionF64):
(JSC::WASMFunctionParser::parseGetGlobalExpressionF64):
* wasm/WASMFunctionParser.h:
* wasm/WASMFunctionSyntaxChecker.h:
(JSC::WASMFunctionSyntaxChecker::buildSetGlobal):
(JSC::WASMFunctionSyntaxChecker::buildGetGlobal):
* wasm/WASMModuleParser.cpp:
(JSC::WASMModuleParser::parseGlobalSection):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmJSWASMModuleh">trunk/Source/JavaScriptCore/wasm/JSWASMModule.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>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoretestsstresswasmglobalswasm">trunk/Source/JavaScriptCore/tests/stress/wasm/globals.wasm</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstresswasmglobalsjs">trunk/Source/JavaScriptCore/tests/stress/wasm-globals.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (189583 => 189584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-09-10 19:19:15 UTC (rev 189583)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-09-10 19:34:40 UTC (rev 189584)
</span><span class="lines">@@ -1,3 +1,39 @@
</span><ins>+2015-09-10 Sukolsak Sakshuwong <sukolsak@gmail.com>
+
+ Implement global variables in WebAssembly
+ https://bugs.webkit.org/show_bug.cgi?id=149031
+
+ Reviewed by Geoffrey Garen.
+
+ This patch implements global variables in WebAssembly. There are two
+ types of global variables in the current format that we use (the format
+ used by <https://github.com/WebAssembly/polyfill-prototype-1>): internal
+ global variables and imported global variables. This patch does not yet
+ import values for imported global variables. It will be done in a
+ subsequent patch.
+
+ * tests/stress/wasm-globals.js: Added.
+ (shouldBe):
+ * tests/stress/wasm/globals.wasm: Added.
+ * wasm/JSWASMModule.h:
+ (JSC::JSWASMModule::globalVariables):
+ * wasm/WASMFunctionCompiler.h:
+ (JSC::WASMFunctionCompiler::buildSetGlobal):
+ (JSC::WASMFunctionCompiler::buildGetGlobal):
+ * wasm/WASMFunctionParser.cpp:
+ (JSC::WASMFunctionParser::parseStatement):
+ (JSC::WASMFunctionParser::parseSetGlobalStatement):
+ (JSC::WASMFunctionParser::parseExpressionI32):
+ (JSC::WASMFunctionParser::parseGetGlobalExpressionI32):
+ (JSC::WASMFunctionParser::parseExpressionF64):
+ (JSC::WASMFunctionParser::parseGetGlobalExpressionF64):
+ * wasm/WASMFunctionParser.h:
+ * wasm/WASMFunctionSyntaxChecker.h:
+ (JSC::WASMFunctionSyntaxChecker::buildSetGlobal):
+ (JSC::WASMFunctionSyntaxChecker::buildGetGlobal):
+ * wasm/WASMModuleParser.cpp:
+ (JSC::WASMModuleParser::parseGlobalSection):
+
</ins><span class="cx"> 2015-09-10 Yusuke Suzuki <utatane.tea@gmail.com>
</span><span class="cx">
</span><span class="cx"> Consider long module path name case in Windows
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstresswasmglobalswasm"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/wasm/globals.wasm (0 => 189584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/wasm/globals.wasm         (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/wasm/globals.wasm        2015-09-10 19:34:40 UTC (rev 189584)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+wasmy\x80\x80\x80\xA0\xC0\x80\xA1\xA0getXgetYsetXsetY
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstresswasmglobalsjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/wasm-globals.js (0 => 189584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/wasm-globals.js         (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/wasm-globals.js        2015-09-10 19:34:40 UTC (rev 189584)
</span><span class="lines">@@ -0,0 +1,57 @@
</span><ins>+//@ skip
+
+function shouldBe(actual, expected) {
+ if (actual !== expected)
+ throw new Error('bad value: ' + actual);
+}
+
+/*
+wasm/globals.wasm is generated by pack-asmjs <https://github.com/WebAssembly/polyfill-prototype-1> from the following script:
+
+function asmModule(global, env, buffer) {
+ "use asm";
+
+ var x = 0;
+ var y = 0.0;
+
+ function getX() {
+ return x;
+ }
+
+ function getY() {
+ return y;
+ }
+
+ function setX(newX) {
+ newX = newX | 0;
+ x = newX;
+ }
+
+ function setY(newY) {
+ newY = +newY;
+ y = newY;
+ }
+
+ return {
+ getX: getX,
+ getY: getY,
+ setX: setX,
+ setY: setY,
+ };
+}
+*/
+
+var module = loadWebAssembly("wasm/globals.wasm");
+
+shouldBe(module.getX(), 0);
+shouldBe(module.getY(), 0);
+
+module.setX(1);
+
+shouldBe(module.getX(), 1);
+shouldBe(module.getY(), 0);
+
+module.setY(0.5);
+
+shouldBe(module.getX(), 1);
+shouldBe(module.getY(), 0.5);
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmJSWASMModuleh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/JSWASMModule.h (189583 => 189584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/JSWASMModule.h        2015-09-10 19:19:15 UTC (rev 189583)
+++ trunk/Source/JavaScriptCore/wasm/JSWASMModule.h        2015-09-10 19:34:40 UTC (rev 189584)
</span><span class="lines">@@ -37,6 +37,25 @@
</span><span class="cx"> public:
</span><span class="cx"> typedef JSDestructibleObject Base;
</span><span class="cx">
</span><ins>+ union GlobalVariable {
+ GlobalVariable(int32_t value)
+ : intValue(value)
+ {
+ }
+ GlobalVariable(float value)
+ : floatValue(value)
+ {
+ }
+ GlobalVariable(double value)
+ : doubleValue(value)
+ {
+ }
+
+ int32_t intValue;
+ float floatValue;
+ double doubleValue;
+ };
+
</ins><span class="cx"> static JSWASMModule* create(VM& vm, Structure* structure)
</span><span class="cx"> {
</span><span class="cx"> JSWASMModule* module = new (NotNull, allocateCell<JSWASMModule>(vm.heap)) JSWASMModule(vm, structure);
</span><span class="lines">@@ -67,6 +86,7 @@
</span><span class="cx"> Vector<WriteBarrier<JSFunction>>& functions() { return m_functions; }
</span><span class="cx"> Vector<unsigned>& functionStartOffsetsInSource() { return m_functionStartOffsetsInSource; }
</span><span class="cx"> Vector<unsigned>& functionStackHeights() { return m_functionStackHeights; }
</span><ins>+ Vector<GlobalVariable>& globalVariables() { return m_globalVariables; }
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> JSWASMModule(VM& vm, Structure* structure)
</span><span class="lines">@@ -87,6 +107,7 @@
</span><span class="cx"> Vector<WriteBarrier<JSFunction>> m_functions;
</span><span class="cx"> Vector<unsigned> m_functionStartOffsetsInSource;
</span><span class="cx"> Vector<unsigned> m_functionStackHeights;
</span><ins>+ Vector<GlobalVariable> m_globalVariables;
</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 (189583 => 189584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WASMFunctionCompiler.h        2015-09-10 19:19:15 UTC (rev 189583)
+++ trunk/Source/JavaScriptCore/wasm/WASMFunctionCompiler.h        2015-09-10 19:34:40 UTC (rev 189584)
</span><span class="lines">@@ -223,6 +223,25 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ void buildSetGlobal(uint32_t globalIndex, int, WASMType type)
+ {
+ move(TrustedImmPtr(&m_module->globalVariables()[globalIndex]), GPRInfo::regT0);
+ switch (type) {
+ case WASMType::I32:
+ case WASMType::F32:
+ load32(temporaryAddress(m_tempStackTop - 1), GPRInfo::regT1);
+ store32(GPRInfo::regT1, GPRInfo::regT0);
+ break;
+ case WASMType::F64:
+ loadDouble(temporaryAddress(m_tempStackTop - 1), FPRInfo::fpRegT0);
+ storeDouble(FPRInfo::fpRegT0, GPRInfo::regT0);
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ m_tempStackTop--;
+ }
+
</ins><span class="cx"> void buildReturn(int, WASMExpressionType returnType)
</span><span class="cx"> {
</span><span class="cx"> switch (returnType) {
</span><span class="lines">@@ -293,6 +312,25 @@
</span><span class="cx"> return UNUSED;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ int buildGetGlobal(uint32_t globalIndex, WASMType type)
+ {
+ move(TrustedImmPtr(&m_module->globalVariables()[globalIndex]), GPRInfo::regT0);
+ switch (type) {
+ case WASMType::I32:
+ case WASMType::F32:
+ load32(GPRInfo::regT0, GPRInfo::regT0);
+ store32(GPRInfo::regT0, temporaryAddress(m_tempStackTop++));
+ break;
+ case WASMType::F64:
+ loadDouble(GPRInfo::regT0, FPRInfo::fpRegT0);
+ storeDouble(FPRInfo::fpRegT0, temporaryAddress(m_tempStackTop++));
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ return UNUSED;
+ }
+
</ins><span class="cx"> int buildUnaryI32(int, WASMOpExpressionI32 op)
</span><span class="cx"> {
</span><span class="cx"> load32(temporaryAddress(m_tempStackTop - 1), GPRInfo::regT0);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWASMFunctionParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WASMFunctionParser.cpp (189583 => 189584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WASMFunctionParser.cpp        2015-09-10 19:19:15 UTC (rev 189583)
+++ trunk/Source/JavaScriptCore/wasm/WASMFunctionParser.cpp        2015-09-10 19:34:40 UTC (rev 189584)
</span><span class="lines">@@ -137,6 +137,9 @@
</span><span class="cx"> case WASMOpStatement::SetLocal:
</span><span class="cx"> parseSetLocalStatement(context);
</span><span class="cx"> break;
</span><ins>+ case WASMOpStatement::SetGlobal:
+ parseSetGlobalStatement(context);
+ break;
</ins><span class="cx"> case WASMOpStatement::Return:
</span><span class="cx"> parseReturnStatement(context);
</span><span class="cx"> break;
</span><span class="lines">@@ -173,7 +176,6 @@
</span><span class="cx"> case WASMOpStatement::Switch:
</span><span class="cx"> parseSwitchStatement(context);
</span><span class="cx"> break;
</span><del>- case WASMOpStatement::SetGlobal:
</del><span class="cx"> case WASMOpStatement::I32Store8:
</span><span class="cx"> case WASMOpStatement::I32StoreWithOffset8:
</span><span class="cx"> case WASMOpStatement::I32Store16:
</span><span class="lines">@@ -198,8 +200,8 @@
</span><span class="cx"> parseSetLocalStatement(context, immediate);
</span><span class="cx"> break;
</span><span class="cx"> case WASMOpStatementWithImmediate::SetGlobal:
</span><del>- // FIXME: Implement this instruction.
- FAIL_WITH_MESSAGE("Unsupported instruction.");
</del><ins>+ parseSetGlobalStatement(context, immediate);
+ break;
</ins><span class="cx"> default:
</span><span class="cx"> ASSERT_NOT_REACHED();
</span><span class="cx"> }
</span><span class="lines">@@ -227,6 +229,25 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <class Context>
</span><ins>+ContextStatement WASMFunctionParser::parseSetGlobalStatement(Context& context, uint32_t globalIndex)
+{
+ FAIL_IF_FALSE(globalIndex < m_module->globalVariableTypes().size(), "The global index is incorrect.");
+ WASMType type = m_module->globalVariableTypes()[globalIndex];
+ ContextExpression expression = parseExpression(context, WASMExpressionType(type));
+ PROPAGATE_ERROR();
+ context.buildSetGlobal(globalIndex, expression, type);
+ return UNUSED;
+}
+
+template <class Context>
+ContextStatement WASMFunctionParser::parseSetGlobalStatement(Context& context)
+{
+ uint32_t globalIndex;
+ READ_COMPACT_UINT32_OR_FAIL(globalIndex, "Cannot read the global index.");
+ return parseSetGlobalStatement(context, globalIndex);
+}
+
+template <class Context>
</ins><span class="cx"> ContextStatement WASMFunctionParser::parseReturnStatement(Context& context)
</span><span class="cx"> {
</span><span class="cx"> ContextExpression expression = 0;
</span><span class="lines">@@ -474,6 +495,8 @@
</span><span class="cx"> return parseImmediateExpressionI32(context);
</span><span class="cx"> case WASMOpExpressionI32::GetLocal:
</span><span class="cx"> return parseGetLocalExpressionI32(context);
</span><ins>+ case WASMOpExpressionI32::GetGlobal:
+ return parseGetGlobalExpressionI32(context);
</ins><span class="cx"> case WASMOpExpressionI32::CallInternal:
</span><span class="cx"> return parseCallInternalExpressionI32(context);
</span><span class="cx"> case WASMOpExpressionI32::Negate:
</span><span class="lines">@@ -514,7 +537,6 @@
</span><span class="cx"> case WASMOpExpressionI32::GreaterThanF64:
</span><span class="cx"> case WASMOpExpressionI32::GreaterThanOrEqualF64:
</span><span class="cx"> return parseRelationalF64ExpressionI32(context, op);
</span><del>- case WASMOpExpressionI32::GetGlobal:
</del><span class="cx"> case WASMOpExpressionI32::SetLocal:
</span><span class="cx"> case WASMOpExpressionI32::SetGlobal:
</span><span class="cx"> case WASMOpExpressionI32::SLoad8:
</span><span class="lines">@@ -615,6 +637,16 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <class Context>
</span><ins>+ContextExpression WASMFunctionParser::parseGetGlobalExpressionI32(Context& context)
+{
+ uint32_t globalIndex;
+ READ_COMPACT_UINT32_OR_FAIL(globalIndex, "Cannot read the global index.");
+ FAIL_IF_FALSE(globalIndex < m_module->globalVariableTypes().size(), "The global index is incorrect.");
+ FAIL_IF_FALSE(m_module->globalVariableTypes()[globalIndex] == WASMType::I32, "Expected a global variable of type int32.");
+ return context.buildGetGlobal(globalIndex, WASMType::I32);
+}
+
+template <class Context>
</ins><span class="cx"> ContextExpression WASMFunctionParser::parseCallInternalExpressionI32(Context& context)
</span><span class="cx"> {
</span><span class="cx"> return parseCallInternal(context, WASMExpressionType::I32);
</span><span class="lines">@@ -675,6 +707,7 @@
</span><span class="cx"> case WASMOpExpressionF64::GetLocal:
</span><span class="cx"> return parseGetLocalExpressionF64(context);
</span><span class="cx"> case WASMOpExpressionF64::GetGlobal:
</span><ins>+ return parseGetGlobalExpressionF64(context);
</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">@@ -769,6 +802,16 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <class Context>
</span><ins>+ContextExpression WASMFunctionParser::parseGetGlobalExpressionF64(Context& context)
+{
+ uint32_t globalIndex;
+ READ_COMPACT_UINT32_OR_FAIL(globalIndex, "Cannot read the global index.");
+ FAIL_IF_FALSE(globalIndex < m_module->globalVariableTypes().size(), "The global index is incorrect.");
+ FAIL_IF_FALSE(m_module->globalVariableTypes()[globalIndex] == WASMType::F64, "Expected a global variable of type float64.");
+ return context.buildGetGlobal(globalIndex, WASMType::F64);
+}
+
+template <class Context>
</ins><span class="cx"> ContextExpressionList WASMFunctionParser::parseCallArguments(Context& context, const Vector<WASMType>& arguments)
</span><span class="cx"> {
</span><span class="cx"> ContextExpressionList argumentList;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWASMFunctionParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WASMFunctionParser.h (189583 => 189584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WASMFunctionParser.h        2015-09-10 19:19:15 UTC (rev 189583)
+++ trunk/Source/JavaScriptCore/wasm/WASMFunctionParser.h        2015-09-10 19:34:40 UTC (rev 189584)
</span><span class="lines">@@ -64,6 +64,8 @@
</span><span class="cx"> template <class Context> ContextStatement parseStatement(Context&);
</span><span class="cx"> template <class Context> ContextStatement parseSetLocalStatement(Context&, uint32_t localIndex);
</span><span class="cx"> template <class Context> ContextStatement parseSetLocalStatement(Context&);
</span><ins>+ template <class Context> ContextStatement parseSetGlobalStatement(Context&, uint32_t globalIndex);
+ template <class Context> ContextStatement parseSetGlobalStatement(Context&);
</ins><span class="cx"> template <class Context> ContextStatement parseReturnStatement(Context&);
</span><span class="cx"> template <class Context> ContextStatement parseBlockStatement(Context&);
</span><span class="cx"> template <class Context> ContextStatement parseIfStatement(Context&);
</span><span class="lines">@@ -86,6 +88,7 @@
</span><span class="cx"> template <class Context> ContextExpression parseImmediateExpressionI32(Context&);
</span><span class="cx"> template <class Context> ContextExpression parseGetLocalExpressionI32(Context&, uint32_t localIndex);
</span><span class="cx"> template <class Context> ContextExpression parseGetLocalExpressionI32(Context&);
</span><ins>+ template <class Context> ContextExpression parseGetGlobalExpressionI32(Context&);
</ins><span class="cx"> template <class Context> ContextExpression parseCallInternalExpressionI32(Context&);
</span><span class="cx"> template <class Context> ContextExpression parseUnaryExpressionI32(Context&, WASMOpExpressionI32);
</span><span class="cx"> template <class Context> ContextExpression parseBinaryExpressionI32(Context&, WASMOpExpressionI32);
</span><span class="lines">@@ -98,6 +101,7 @@
</span><span class="cx"> template <class Context> ContextExpression parseImmediateExpressionF64(Context&);
</span><span class="cx"> template <class Context> ContextExpression parseGetLocalExpressionF64(Context&, uint32_t localIndex);
</span><span class="cx"> template <class Context> ContextExpression parseGetLocalExpressionF64(Context&);
</span><ins>+ template <class Context> ContextExpression parseGetGlobalExpressionF64(Context&);
</ins><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></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWASMFunctionSyntaxCheckerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WASMFunctionSyntaxChecker.h (189583 => 189584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WASMFunctionSyntaxChecker.h        2015-09-10 19:19:15 UTC (rev 189583)
+++ trunk/Source/JavaScriptCore/wasm/WASMFunctionSyntaxChecker.h        2015-09-10 19:34:40 UTC (rev 189584)
</span><span class="lines">@@ -55,6 +55,11 @@
</span><span class="cx"> m_tempStackTop--;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ void buildSetGlobal(uint32_t, int, WASMType)
+ {
+ m_tempStackTop--;
+ }
+
</ins><span class="cx"> void buildReturn(int, WASMExpressionType returnType)
</span><span class="cx"> {
</span><span class="cx"> if (returnType != WASMExpressionType::Void)
</span><span class="lines">@@ -82,6 +87,13 @@
</span><span class="cx"> return UNUSED;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ int buildGetGlobal(uint32_t, WASMType)
+ {
+ m_tempStackTop++;
+ updateTempStackHeight();
+ return UNUSED;
+ }
+
</ins><span class="cx"> int buildUnaryI32(int, WASMOpExpressionI32)
</span><span class="cx"> {
</span><span class="cx"> return UNUSED;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWASMModuleParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WASMModuleParser.cpp (189583 => 189584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WASMModuleParser.cpp        2015-09-10 19:19:15 UTC (rev 189583)
+++ trunk/Source/JavaScriptCore/wasm/WASMModuleParser.cpp        2015-09-10 19:34:40 UTC (rev 189584)
</span><span class="lines">@@ -191,26 +191,37 @@
</span><span class="cx">
</span><span class="cx"> Vector<WASMType>& globalVariableTypes = m_module->globalVariableTypes();
</span><span class="cx"> globalVariableTypes.reserveInitialCapacity(numberOfGlobalVariables);
</span><del>- for (uint32_t i = 0; i < numberOfInternalI32GlobalVariables; ++i)
</del><ins>+ Vector<JSWASMModule::GlobalVariable>& globalVariables = m_module->globalVariables();
+ globalVariables.reserveInitialCapacity(numberOfGlobalVariables);
+ for (uint32_t i = 0; i < numberOfInternalI32GlobalVariables; ++i) {
</ins><span class="cx"> globalVariableTypes.uncheckedAppend(WASMType::I32);
</span><del>- for (uint32_t i = 0; i < numberOfInternalF32GlobalVariables; ++i)
</del><ins>+ globalVariables.uncheckedAppend(JSWASMModule::GlobalVariable(0));
+ }
+ for (uint32_t i = 0; i < numberOfInternalF32GlobalVariables; ++i) {
</ins><span class="cx"> globalVariableTypes.uncheckedAppend(WASMType::F32);
</span><del>- for (uint32_t i = 0; i < numberOfInternalF64GlobalVariables; ++i)
</del><ins>+ globalVariables.uncheckedAppend(JSWASMModule::GlobalVariable(0.0f));
+ }
+ for (uint32_t i = 0; i < numberOfInternalF64GlobalVariables; ++i) {
</ins><span class="cx"> globalVariableTypes.uncheckedAppend(WASMType::F64);
</span><ins>+ globalVariables.uncheckedAppend(JSWASMModule::GlobalVariable(0.0));
+ }
</ins><span class="cx"> for (uint32_t i = 0; i < numberOfImportedI32GlobalVariables; ++i) {
</span><span class="cx"> String importName;
</span><span class="cx"> READ_STRING_OR_FAIL(importName, "Cannot read the import name of an int32 global variable.");
</span><span class="cx"> globalVariableTypes.uncheckedAppend(WASMType::I32);
</span><ins>+ globalVariables.uncheckedAppend(JSWASMModule::GlobalVariable(0)); // FIXME: Import the value.
</ins><span class="cx"> }
</span><span class="cx"> for (uint32_t i = 0; i < numberOfImportedF32GlobalVariables; ++i) {
</span><span class="cx"> String importName;
</span><span class="cx"> READ_STRING_OR_FAIL(importName, "Cannot read the import name of a float32 global variable.");
</span><span class="cx"> globalVariableTypes.uncheckedAppend(WASMType::F32);
</span><ins>+ globalVariables.uncheckedAppend(JSWASMModule::GlobalVariable(0.0f)); // FIXME: Import the value.
</ins><span class="cx"> }
</span><span class="cx"> for (uint32_t i = 0; i < numberOfImportedF64GlobalVariables; ++i) {
</span><span class="cx"> String importName;
</span><span class="cx"> READ_STRING_OR_FAIL(importName, "Cannot read the import name of a float64 global variable.");
</span><span class="cx"> globalVariableTypes.uncheckedAppend(WASMType::F64);
</span><ins>+ globalVariables.uncheckedAppend(JSWASMModule::GlobalVariable(0.0)); // FIXME: Import the value.
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>