<!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>[189744] 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/189744">189744</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-09-14 11:30:08 -0700 (Mon, 14 Sep 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Implement the arithmetic instructions for floats in WebAssembly
https://bugs.webkit.org/show_bug.cgi?id=149102

Patch by Sukolsak Sakshuwong &lt;sukolsak@gmail.com&gt; on 2015-09-14
Reviewed by Geoffrey Garen.

This patch implements the arithmetic instructions for floats (float32)
in WebAssembly by converting the float operands to doubles, performing
the equivalent double instructions, and converting the result back to
float. The asm.js spec says that &quot;As proved in 'When is double rounding
innocuous?' (Figueroa 1995), both the 32- and 64-bit versions of
standard arithmetic operations produce equivalent results when given
32-bit inputs and coerced to 32-bit outputs.&quot;
(http://asmjs.org/spec/latest/#floatish)

This patch also pads WebAssembly call frames by maxFrameExtentForSlowPathCall,
so that there is no need to adjust the stack pointer every time we make
a slow path call.

* tests/stress/wasm-arithmetic-float32.js:
* tests/stress/wasm/arithmetic-float32.wasm:
* wasm/WASMFunctionCompiler.h:
(JSC::WASMFunctionCompiler::startFunction):
(JSC::WASMFunctionCompiler::buildUnaryF32):
(JSC::WASMFunctionCompiler::buildBinaryF32):
(JSC::WASMFunctionCompiler::callOperation):
(JSC::WASMFunctionCompiler::callAndUnboxResult):
(JSC::WASMFunctionCompiler::endFunction): Deleted.
(JSC::WASMFunctionCompiler::buildBinaryI32): Deleted.
* wasm/WASMFunctionParser.cpp:
(JSC::WASMFunctionParser::parseExpressionF32):
(JSC::WASMFunctionParser::parseUnaryExpressionF32):
(JSC::WASMFunctionParser::parseBinaryExpressionF32):
* wasm/WASMFunctionParser.h:
* wasm/WASMFunctionSyntaxChecker.h:
(JSC::WASMFunctionSyntaxChecker::buildUnaryF32):
(JSC::WASMFunctionSyntaxChecker::buildBinaryF32):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstresswasmarithmeticfloat32wasm">trunk/Source/JavaScriptCore/tests/stress/wasm/arithmetic-float32.wasm</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstresswasmarithmeticfloat32js">trunk/Source/JavaScriptCore/tests/stress/wasm-arithmetic-float32.js</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>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (189743 => 189744)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-09-14 17:58:11 UTC (rev 189743)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-09-14 18:30:08 UTC (rev 189744)
</span><span class="lines">@@ -1,3 +1,42 @@
</span><ins>+2015-09-14  Sukolsak Sakshuwong  &lt;sukolsak@gmail.com&gt;
+
+        Implement the arithmetic instructions for floats in WebAssembly
+        https://bugs.webkit.org/show_bug.cgi?id=149102
+
+        Reviewed by Geoffrey Garen.
+
+        This patch implements the arithmetic instructions for floats (float32)
+        in WebAssembly by converting the float operands to doubles, performing
+        the equivalent double instructions, and converting the result back to
+        float. The asm.js spec says that &quot;As proved in 'When is double rounding
+        innocuous?' (Figueroa 1995), both the 32- and 64-bit versions of
+        standard arithmetic operations produce equivalent results when given
+        32-bit inputs and coerced to 32-bit outputs.&quot;
+        (http://asmjs.org/spec/latest/#floatish)
+
+        This patch also pads WebAssembly call frames by maxFrameExtentForSlowPathCall,
+        so that there is no need to adjust the stack pointer every time we make
+        a slow path call.
+
+        * tests/stress/wasm-arithmetic-float32.js:
+        * tests/stress/wasm/arithmetic-float32.wasm:
+        * wasm/WASMFunctionCompiler.h:
+        (JSC::WASMFunctionCompiler::startFunction):
+        (JSC::WASMFunctionCompiler::buildUnaryF32):
+        (JSC::WASMFunctionCompiler::buildBinaryF32):
+        (JSC::WASMFunctionCompiler::callOperation):
+        (JSC::WASMFunctionCompiler::callAndUnboxResult):
+        (JSC::WASMFunctionCompiler::endFunction): Deleted.
+        (JSC::WASMFunctionCompiler::buildBinaryI32): Deleted.
+        * wasm/WASMFunctionParser.cpp:
+        (JSC::WASMFunctionParser::parseExpressionF32):
+        (JSC::WASMFunctionParser::parseUnaryExpressionF32):
+        (JSC::WASMFunctionParser::parseBinaryExpressionF32):
+        * wasm/WASMFunctionParser.h:
+        * wasm/WASMFunctionSyntaxChecker.h:
+        (JSC::WASMFunctionSyntaxChecker::buildUnaryF32):
+        (JSC::WASMFunctionSyntaxChecker::buildBinaryF32):
+
</ins><span class="cx"> 2015-09-13  Geoffrey Garen  &lt;ggaren@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Eden GC should not try to jettison old CodeBlocks in the remembered set
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstresswasmarithmeticfloat32wasm"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/tests/stress/wasm/arithmetic-float32.wasm (189743 => 189744)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/wasm/arithmetic-float32.wasm        2015-09-14 17:58:11 UTC (rev 189743)
+++ trunk/Source/JavaScriptCore/tests/stress/wasm/arithmetic-float32.wasm        2015-09-14 18:30:08 UTC (rev 189744)
</span><span class="lines">@@ -1 +1,3 @@
</span><del>-wasm\xF7\x80?number
</del><span class="cx">\ No newline at end of file
</span><ins>+wasm\xFD
+\x80?\x80\xA0\x80\xA0\xA1\x80\xA0\xA1\x80\xA0\xA1\x80\xA0\xA1\x80\xA0\x80\xA0\x80\xA0\x80\xA0
+numbernegateaddsubtractmultiplydivideabsoluteceilNumberfloorNumbersquareRoot        
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstresswasmarithmeticfloat32js"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/tests/stress/wasm-arithmetic-float32.js (189743 => 189744)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/wasm-arithmetic-float32.js        2015-09-14 17:58:11 UTC (rev 189743)
+++ trunk/Source/JavaScriptCore/tests/stress/wasm-arithmetic-float32.js        2015-09-14 18:30:08 UTC (rev 189744)
</span><span class="lines">@@ -12,13 +12,75 @@
</span><span class="cx">     &quot;use asm&quot;;
</span><span class="cx"> 
</span><span class="cx">     var fround = global.Math.fround;
</span><ins>+    var abs = global.Math.abs;
+    var ceil = global.Math.ceil;
+    var floor = global.Math.floor;
+    var sqrt = global.Math.sqrt;
</ins><span class="cx"> 
</span><span class="cx">     function number() {
</span><span class="cx">         return fround(0.5);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    function negate(x) {
+        x = fround(x);
+        return fround(-x);
+    }
+
+    function add(x, y) {
+        x = fround(x);
+        y = fround(y);
+        return fround(x + y);
+    }
+
+    function subtract(x, y) {
+        x = fround(x);
+        y = fround(y);
+        return fround(x - y);
+    }
+
+    function multiply(x, y) {
+        x = fround(x);
+        y = fround(y);
+        return fround(x * y);
+    }
+
+    function divide(x, y) {
+        x = fround(x);
+        y = fround(y);
+        return fround(x / y);
+    }
+
+    function absolute(x) {
+        x = fround(x);
+        return fround(abs(x));
+    }
+
+    function ceilNumber(x) {
+        x = fround(x);
+        return fround(ceil(x));
+    }
+
+    function floorNumber(x) {
+        x = fround(x);
+        return fround(floor(x));
+    }
+
+    function squareRoot(x) {
+        x = fround(x);
+        return fround(sqrt(x));
+    }
+
</ins><span class="cx">     return {
</span><span class="cx">         number: number,
</span><ins>+        negate: negate,
+        add: add,
+        subtract: subtract,
+        multiply: multiply,
+        divide: divide,
+        absolute: absolute,
+        ceilNumber: ceilNumber,
+        floorNumber: floorNumber,
+        squareRoot: squareRoot,
</ins><span class="cx">     };
</span><span class="cx"> }
</span><span class="cx"> */
</span><span class="lines">@@ -26,3 +88,18 @@
</span><span class="cx"> var module = loadWebAssembly(&quot;wasm/arithmetic-float32.wasm&quot;);
</span><span class="cx"> 
</span><span class="cx"> shouldBe(module.number(), 0.5);
</span><ins>+shouldBe(module.negate(0.1), -0.10000000149011612);
+shouldBe(module.add(0.1, 0.5), 0.6000000238418579);
+shouldBe(isNaN(module.add(0.1, NaN)), true);
+shouldBe(module.add(0.1, Infinity), Infinity);
+shouldBe(isNaN(module.add(Infinity, -Infinity)), true);
+shouldBe(module.subtract(0.1, 0.5), -0.4000000059604645);
+shouldBe(module.multiply(0.1, 0.5), 0.05000000074505806);
+shouldBe(module.divide(0.1, 0.5), 0.20000000298023224);
+shouldBe(module.divide(0.1, 0), Infinity);
+shouldBe(module.divide(0.1, -0), -Infinity);
+shouldBe(module.absolute(-4.2), 4.199999809265137);
+shouldBe(module.absolute(4.2), 4.199999809265137);
+shouldBe(module.ceilNumber(4.2), 5);
+shouldBe(module.floorNumber(4.2), 4);
+shouldBe(module.squareRoot(0.09), 0.30000001192092896);
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWASMFunctionCompilerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WASMFunctionCompiler.h (189743 => 189744)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WASMFunctionCompiler.h        2015-09-14 17:58:11 UTC (rev 189743)
+++ trunk/Source/JavaScriptCore/wasm/WASMFunctionCompiler.h        2015-09-14 18:30:08 UTC (rev 189744)
</span><span class="lines">@@ -96,7 +96,7 @@
</span><span class="cx"> 
</span><span class="cx">         m_beginLabel = label();
</span><span class="cx"> 
</span><del>-        addPtr(TrustedImm32(-WTF::roundUpToMultipleOf(stackAlignmentRegisters(), m_stackHeight) * sizeof(StackSlot)), GPRInfo::callFrameRegister, GPRInfo::regT1);
</del><ins>+        addPtr(TrustedImm32(-WTF::roundUpToMultipleOf(stackAlignmentRegisters(), m_stackHeight) * sizeof(StackSlot) - maxFrameExtentForSlowPathCall), GPRInfo::callFrameRegister, GPRInfo::regT1);
</ins><span class="cx">         m_stackOverflow = branchPtr(Above, AbsoluteAddress(m_vm-&gt;addressOfStackLimit()), GPRInfo::regT1);
</span><span class="cx"> 
</span><span class="cx">         move(GPRInfo::regT1, stackPointerRegister);
</span><span class="lines">@@ -165,8 +165,6 @@
</span><span class="cx">         if (!m_divideErrorJumpList.empty()) {
</span><span class="cx">             m_divideErrorJumpList.link(this);
</span><span class="cx"> 
</span><del>-            if (maxFrameExtentForSlowPathCall)
-                addPtr(TrustedImm32(-maxFrameExtentForSlowPathCall), stackPointerRegister);
</del><span class="cx">             setupArgumentsExecState();
</span><span class="cx">             appendCallWithExceptionCheck(operationThrowDivideError);
</span><span class="cx">         }
</span><span class="lines">@@ -380,6 +378,38 @@
</span><span class="cx">         return UNUSED;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    int buildUnaryF32(int, WASMOpExpressionF32 op)
+    {
+        loadDouble(temporaryAddress(m_tempStackTop - 1), FPRInfo::fpRegT1);
+        switch (op) {
+        case WASMOpExpressionF32::Negate:
+            convertFloatToDouble(FPRInfo::fpRegT1, FPRInfo::fpRegT1);
+            negateDouble(FPRInfo::fpRegT1, FPRInfo::fpRegT0);
+            convertDoubleToFloat(FPRInfo::fpRegT0, FPRInfo::fpRegT0);
+            break;
+        case WASMOpExpressionF32::Abs:
+            convertFloatToDouble(FPRInfo::fpRegT1, FPRInfo::fpRegT1);
+            absDouble(FPRInfo::fpRegT1, FPRInfo::fpRegT0);
+            convertDoubleToFloat(FPRInfo::fpRegT0, FPRInfo::fpRegT0);
+            break;
+        case WASMOpExpressionF32::Ceil:
+            callOperation(ceilf, FPRInfo::fpRegT1, FPRInfo::fpRegT0);
+            break;
+        case WASMOpExpressionF32::Floor:
+            callOperation(floorf, FPRInfo::fpRegT1, FPRInfo::fpRegT0);
+            break;
+        case WASMOpExpressionF32::Sqrt:
+            convertFloatToDouble(FPRInfo::fpRegT1, FPRInfo::fpRegT1);
+            sqrtDouble(FPRInfo::fpRegT1, FPRInfo::fpRegT0);
+            convertDoubleToFloat(FPRInfo::fpRegT0, FPRInfo::fpRegT0);
+            break;
+        default:
+            ASSERT_NOT_REACHED();
+        }
+        storeDouble(FPRInfo::fpRegT0, temporaryAddress(m_tempStackTop - 1));
+        return UNUSED;
+    }
+
</ins><span class="cx">     int buildBinaryI32(int, int, WASMOpExpressionI32 op)
</span><span class="cx">     {
</span><span class="cx">         load32(temporaryAddress(m_tempStackTop - 2), GPRInfo::regT0);
</span><span class="lines">@@ -419,8 +449,6 @@
</span><span class="cx">                 move(X86Registers::edx, GPRInfo::regT0);
</span><span class="cx"> #else
</span><span class="cx">             // FIXME: We should be able to do an inline div on ARMv7 and ARM64.
</span><del>-            if (maxFrameExtentForSlowPathCall)
-                addPtr(TrustedImm32(-maxFrameExtentForSlowPathCall), stackPointerRegister);
</del><span class="cx">             switch (op) {
</span><span class="cx">             case WASMOpExpressionI32::SDiv:
</span><span class="cx">                 callOperation(operationDiv, GPRInfo::regT0, GPRInfo::regT1, GPRInfo::regT0);
</span><span class="lines">@@ -437,8 +465,6 @@
</span><span class="cx">             default:
</span><span class="cx">                 ASSERT_NOT_REACHED();
</span><span class="cx">             }
</span><del>-            if (maxFrameExtentForSlowPathCall)
-                addPtr(TrustedImm32(maxFrameExtentForSlowPathCall), stackPointerRegister);
</del><span class="cx"> #endif
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="lines">@@ -468,6 +494,34 @@
</span><span class="cx">         return UNUSED;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    int buildBinaryF32(int, int, WASMOpExpressionF32 op)
+    {
+        loadDouble(temporaryAddress(m_tempStackTop - 2), FPRInfo::fpRegT0);
+        loadDouble(temporaryAddress(m_tempStackTop - 1), FPRInfo::fpRegT1);
+        convertFloatToDouble(FPRInfo::fpRegT0, FPRInfo::fpRegT0);
+        convertFloatToDouble(FPRInfo::fpRegT1, FPRInfo::fpRegT1);
+        switch (op) {
+        case WASMOpExpressionF32::Add:
+            addDouble(FPRInfo::fpRegT1, FPRInfo::fpRegT0);
+            break;
+        case WASMOpExpressionF32::Sub:
+            subDouble(FPRInfo::fpRegT1, FPRInfo::fpRegT0);
+            break;
+        case WASMOpExpressionF32::Mul:
+            mulDouble(FPRInfo::fpRegT1, FPRInfo::fpRegT0);
+            break;
+        case WASMOpExpressionF32::Div:
+            divDouble(FPRInfo::fpRegT1, FPRInfo::fpRegT0);
+            break;
+        default:
+            RELEASE_ASSERT_NOT_REACHED();
+        }
+        convertDoubleToFloat(FPRInfo::fpRegT0, FPRInfo::fpRegT0);
+        m_tempStackTop--;
+        storeDouble(FPRInfo::fpRegT0, temporaryAddress(m_tempStackTop - 1));
+        return UNUSED;
+    }
+
</ins><span class="cx">     int buildRelationalI32(int, int, WASMOpExpressionI32 op)
</span><span class="cx">     {
</span><span class="cx">         load32(temporaryAddress(m_tempStackTop - 2), GPRInfo::regT0);
</span><span class="lines">@@ -787,6 +841,12 @@
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    void callOperation(float JIT_OPERATION (*operation)(float), FPRegisterID src, FPRegisterID dst)
+    {
+        setupArguments(src);
+        appendCallSetResult(operation, dst);
+    }
+
</ins><span class="cx">     void callOperation(int32_t JIT_OPERATION (*operation)(int32_t, int32_t), GPRReg src1, GPRReg src2, GPRReg dst)
</span><span class="cx">     {
</span><span class="cx">         setupArguments(src1, src2);
</span><span class="lines">@@ -855,7 +915,7 @@
</span><span class="cx">         m_callCompilationInfo.last().callReturnLocation = emitNakedCall(m_vm-&gt;getCTIStub(linkCallThunkGenerator).code());
</span><span class="cx"> 
</span><span class="cx">         end.link(this);
</span><del>-        addPtr(TrustedImm32(-WTF::roundUpToMultipleOf(stackAlignmentRegisters(), m_stackHeight) * sizeof(StackSlot)), GPRInfo::callFrameRegister, stackPointerRegister);
</del><ins>+        addPtr(TrustedImm32(-WTF::roundUpToMultipleOf(stackAlignmentRegisters(), m_stackHeight) * sizeof(StackSlot) - maxFrameExtentForSlowPathCall), GPRInfo::callFrameRegister, stackPointerRegister);
</ins><span class="cx">         checkStackPointerAlignment();
</span><span class="cx"> 
</span><span class="cx">         switch (returnType) {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWASMFunctionParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WASMFunctionParser.cpp (189743 => 189744)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WASMFunctionParser.cpp        2015-09-14 17:58:11 UTC (rev 189743)
+++ trunk/Source/JavaScriptCore/wasm/WASMFunctionParser.cpp        2015-09-14 18:30:08 UTC (rev 189744)
</span><span class="lines">@@ -750,6 +750,17 @@
</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::Negate:
+        case WASMOpExpressionF32::Abs:
+        case WASMOpExpressionF32::Ceil:
+        case WASMOpExpressionF32::Floor:
+        case WASMOpExpressionF32::Sqrt:
+            return parseUnaryExpressionF32(context, op);
+        case WASMOpExpressionF32::Add:
+        case WASMOpExpressionF32::Sub:
+        case WASMOpExpressionF32::Mul:
+        case WASMOpExpressionF32::Div:
+            return parseBinaryExpressionF32(context, op);
</ins><span class="cx">         case WASMOpExpressionF32::SetLocal:
</span><span class="cx">         case WASMOpExpressionF32::SetGlobal:
</span><span class="cx">         case WASMOpExpressionF32::Load:
</span><span class="lines">@@ -763,15 +774,6 @@
</span><span class="cx">         case WASMOpExpressionF32::FromS32:
</span><span class="cx">         case WASMOpExpressionF32::FromU32:
</span><span class="cx">         case WASMOpExpressionF32::FromF64:
</span><del>-        case WASMOpExpressionF32::Negate:
-        case WASMOpExpressionF32::Add:
-        case WASMOpExpressionF32::Sub:
-        case WASMOpExpressionF32::Mul:
-        case WASMOpExpressionF32::Div:
-        case WASMOpExpressionF32::Abs:
-        case WASMOpExpressionF32::Ceil:
-        case WASMOpExpressionF32::Floor:
-        case WASMOpExpressionF32::Sqrt:
</del><span class="cx">             // FIXME: Implement these instructions.
</span><span class="cx">             FAIL_WITH_MESSAGE(&quot;Unsupported instruction.&quot;);
</span><span class="cx">         default:
</span><span class="lines">@@ -840,6 +842,24 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template &lt;class Context&gt;
</span><ins>+ContextExpression WASMFunctionParser::parseUnaryExpressionF32(Context&amp; context, WASMOpExpressionF32 op)
+{
+    ContextExpression expression = parseExpressionF32(context);
+    PROPAGATE_ERROR();
+    return context.buildUnaryF32(expression, op);
+}
+
+template &lt;class Context&gt;
+ContextExpression WASMFunctionParser::parseBinaryExpressionF32(Context&amp; context, WASMOpExpressionF32 op)
+{
+    ContextExpression left = parseExpressionF32(context);
+    PROPAGATE_ERROR();
+    ContextExpression right = parseExpressionF32(context);
+    PROPAGATE_ERROR();
+    return context.buildBinaryF32(left, right, op);
+}
+
+template &lt;class Context&gt;
</ins><span class="cx"> ContextExpression WASMFunctionParser::parseExpressionF64(Context&amp; context)
</span><span class="cx"> {
</span><span class="cx">     bool hasImmediate;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWASMFunctionParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WASMFunctionParser.h (189743 => 189744)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WASMFunctionParser.h        2015-09-14 17:58:11 UTC (rev 189743)
+++ trunk/Source/JavaScriptCore/wasm/WASMFunctionParser.h        2015-09-14 18:30:08 UTC (rev 189744)
</span><span class="lines">@@ -103,6 +103,8 @@
</span><span class="cx">     template &lt;class Context&gt; ContextExpression parseGetLocalExpressionF32(Context&amp;, uint32_t localIndex);
</span><span class="cx">     template &lt;class Context&gt; ContextExpression parseGetLocalExpressionF32(Context&amp;);
</span><span class="cx">     template &lt;class Context&gt; ContextExpression parseGetGlobalExpressionF32(Context&amp;);
</span><ins>+    template &lt;class Context&gt; ContextExpression parseUnaryExpressionF32(Context&amp;, WASMOpExpressionF32);
+    template &lt;class Context&gt; ContextExpression parseBinaryExpressionF32(Context&amp;, WASMOpExpressionF32);
</ins><span class="cx"> 
</span><span class="cx">     template &lt;class Context&gt; ContextExpression parseExpressionF64(Context&amp;);
</span><span class="cx">     template &lt;class Context&gt; ContextExpression parseConstantPoolIndexExpressionF64(Context&amp;, uint32_t constantIndex);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWASMFunctionSyntaxCheckerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WASMFunctionSyntaxChecker.h (189743 => 189744)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WASMFunctionSyntaxChecker.h        2015-09-14 17:58:11 UTC (rev 189743)
+++ trunk/Source/JavaScriptCore/wasm/WASMFunctionSyntaxChecker.h        2015-09-14 18:30:08 UTC (rev 189744)
</span><span class="lines">@@ -106,12 +106,23 @@
</span><span class="cx">         return UNUSED;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    int buildUnaryF32(int, WASMOpExpressionF32)
+    {
+        return UNUSED;
+    }
+
</ins><span class="cx">     int buildBinaryI32(int, int, WASMOpExpressionI32)
</span><span class="cx">     {
</span><span class="cx">         m_tempStackTop--;
</span><span class="cx">         return UNUSED;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    int buildBinaryF32(int, int, WASMOpExpressionF32)
+    {
+        m_tempStackTop--;
+        return UNUSED;
+    }
+
</ins><span class="cx">     int buildRelationalI32(int, int, WASMOpExpressionI32)
</span><span class="cx">     {
</span><span class="cx">         m_tempStackTop--;
</span></span></pre>
</div>
</div>

</body>
</html>