Log Message
Implement the relational instructions for doubles in WebAssembly https://bugs.webkit.org/show_bug.cgi?id=148999
Patch by Sukolsak Sakshuwong <sukol...@gmail.com> on 2015-09-09 Reviewed by Filip Pizlo. Implements the relational instructions for doubles (float64) in WebAssembly. Also pass the values into the test functions as Mark Lam suggested in https://bugs.webkit.org/show_bug.cgi?id=148882#c3 * tests/stress/wasm-relational.js: * tests/stress/wasm/relational.wasm: * wasm/WASMFunctionCompiler.h: (JSC::WASMFunctionCompiler::buildRelationalF64): * wasm/WASMFunctionParser.cpp: (JSC::WASMFunctionParser::parseExpressionI32): (JSC::WASMFunctionParser::parseRelationalF64ExpressionI32): * wasm/WASMFunctionParser.h: * wasm/WASMFunctionSyntaxChecker.h: (JSC::WASMFunctionSyntaxChecker::buildRelationalI32): (JSC::WASMFunctionSyntaxChecker::buildRelationalF64):
Modified Paths
- trunk/Source/_javascript_Core/ChangeLog
- trunk/Source/_javascript_Core/tests/stress/wasm/relational.wasm
- trunk/Source/_javascript_Core/tests/stress/wasm-relational.js
- trunk/Source/_javascript_Core/wasm/WASMFunctionCompiler.h
- trunk/Source/_javascript_Core/wasm/WASMFunctionParser.cpp
- trunk/Source/_javascript_Core/wasm/WASMFunctionParser.h
- trunk/Source/_javascript_Core/wasm/WASMFunctionSyntaxChecker.h
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (189548 => 189549)
--- trunk/Source/_javascript_Core/ChangeLog 2015-09-09 20:58:44 UTC (rev 189548)
+++ trunk/Source/_javascript_Core/ChangeLog 2015-09-09 21:01:03 UTC (rev 189549)
@@ -1,3 +1,26 @@
+2015-09-09 Sukolsak Sakshuwong <sukol...@gmail.com>
+
+ Implement the relational instructions for doubles in WebAssembly
+ https://bugs.webkit.org/show_bug.cgi?id=148999
+
+ Reviewed by Filip Pizlo.
+
+ Implements the relational instructions for doubles (float64) in
+ WebAssembly. Also pass the values into the test functions as Mark Lam
+ suggested in https://bugs.webkit.org/show_bug.cgi?id=148882#c3
+
+ * tests/stress/wasm-relational.js:
+ * tests/stress/wasm/relational.wasm:
+ * wasm/WASMFunctionCompiler.h:
+ (JSC::WASMFunctionCompiler::buildRelationalF64):
+ * wasm/WASMFunctionParser.cpp:
+ (JSC::WASMFunctionParser::parseExpressionI32):
+ (JSC::WASMFunctionParser::parseRelationalF64ExpressionI32):
+ * wasm/WASMFunctionParser.h:
+ * wasm/WASMFunctionSyntaxChecker.h:
+ (JSC::WASMFunctionSyntaxChecker::buildRelationalI32):
+ (JSC::WASMFunctionSyntaxChecker::buildRelationalF64):
+
2015-09-09 Saam barati <sbar...@apple.com>
DFG should have a debugging option that runs a phase that flushes all locals
Modified: trunk/Source/_javascript_Core/tests/stress/wasm/relational.wasm (189548 => 189549)
--- trunk/Source/_javascript_Core/tests/stress/wasm/relational.wasm 2015-09-09 20:58:44 UTC (rev 189548)
+++ trunk/Source/_javascript_Core/tests/stress/wasm/relational.wasm 2015-09-09 21:01:03 UTC (rev 189549)
@@ -1,3 +1,3 @@
-wasmc\xFF\xFF\xFF\xFF\x80.\xA1\xA1\x80.\xA1\xA2\x801\xA1\xA2\x801\xA1\xA1\x804\x80\xA2\x804\xA1\xA1\x808\xA1\xA1\x808\xA2\xA1\x80<\xA2\x80\x80<\xA1\xA1\x80@\xA1\xA1\x80@\xA1\xA2\x805\xA2\x80\x805\x80\xA2\x809\xA2\x80\x809\x80\xA2\x80=\x80\xA2\x80=\xA2\x80\x80A\x80\xA2\x80A\xA2\x80equalTrueequalFalsenotEqualTruenotEqualFalselessThanTruelessThanFalselessThanOrEqualTruelessThanOrEqualFalsegreaterThanTruegreaterThanFalse greaterThanOrEqualTrue
-greaterThanOrEqualFalseunsignedLessThanTrueunsignedLessThanFalse-unsignedLessThanOrEqualTrueunsignedLessThanOrEqualFalseunsignedGreaterThanTrueunsignedGreaterThanFalseunsignedGreaterThanOrEqualTrueunsignedGreaterThanOrEqualFalse
\ No newline at end of file
+wasmE\x80.\xC0\xC1\x801\xC0\xC1\x804\xC0\xC1\x808\xC0\xC1\x80<\xC0\xC1\x80@\xC0\xC1\x805\xC0\xC1\x809\xC0\xC1\x80=\xC0\xC1\x80A\xC0\xC1\x800\xA0\xA1\x803\xA0\xA1\x807\xA0\xA1\x80;\xA0\xA1\x80?\xA0\xA1\x80C\xA0\xA1equalnotEquallessThanlessThanOrEqualgreaterThangreaterThanOrEqualunsignedLessThanunsignedLessThanOrEqualunsignedGreaterThanunsignedGreaterThanOrEqual doubleEqual
+doubleNotEqualdoubleLessThandoubleLessThanOrEqual+doubleGreaterThandoubleGreaterThanOrEqual
\ No newline at end of file
Modified: trunk/Source/_javascript_Core/tests/stress/wasm-relational.js (189548 => 189549)
--- trunk/Source/_javascript_Core/tests/stress/wasm-relational.js 2015-09-09 20:58:44 UTC (rev 189548)
+++ trunk/Source/_javascript_Core/tests/stress/wasm-relational.js 2015-09-09 21:01:03 UTC (rev 189549)
@@ -11,130 +11,165 @@
function asmModule(global, env, buffer) {
"use asm";
- function equalTrue() {
- return 1 == 1;
+ function equal(x, y) {
+ x = x | 0;
+ y = y | 0;
+ return (x == y) | 0;
}
- function equalFalse() {
- return 1 == 2;
+ function notEqual(x, y) {
+ x = x | 0;
+ y = y | 0;
+ return (x != y) | 0;
}
- function notEqualTrue() {
- return 1 != 2;
+ function lessThan(x, y) {
+ x = x | 0;
+ y = y | 0;
+ return ((x | 0) < (y | 0)) | 0;
}
- function notEqualFalse() {
- return 1 != 1;
+ function lessThanOrEqual(x, y) {
+ x = x | 0;
+ y = y | 0;
+ return ((x | 0) <= (y | 0)) | 0;
}
- function lessThanTrue() {
- return -1 < 2;
+ function greaterThan(x, y) {
+ x = x | 0;
+ y = y | 0;
+ return ((x | 0) > (y | 0)) | 0;
}
- function lessThanFalse() {
- return 1 < 1;
+ function greaterThanOrEqual(x, y) {
+ x = x | 0;
+ y = y | 0;
+ return ((x | 0) >= (y | 0)) | 0;
}
- function lessThanOrEqualTrue() {
- return 1 <= 1;
+ function unsignedLessThan(x, y) {
+ x = x | 0;
+ y = y | 0;
+ return ((x >>> 0) < (y >>> 0)) | 0;
}
- function lessThanOrEqualFalse() {
- return 2 <= 1;
+ function unsignedLessThanOrEqual(x, y) {
+ x = x | 0;
+ y = y | 0;
+ return ((x >>> 0) <= (y >>> 0)) | 0;
}
- function greaterThanTrue() {
- return 2 > -1;
+ function unsignedGreaterThan(x, y) {
+ x = x | 0;
+ y = y | 0;
+ return ((x >>> 0) > (y >>> 0)) | 0;
}
- function greaterThanFalse() {
- return 1 > 1;
+ function unsignedGreaterThanOrEqual(x, y) {
+ x = x | 0;
+ y = y | 0;
+ return ((x >>> 0) >= (y >>> 0)) | 0;
}
- function greaterThanOrEqualTrue() {
- return 1 >= 1;
+ function doubleEqual(x, y) {
+ x = +x;
+ y = +y;
+ return (x == y) | 0;
}
- function greaterThanOrEqualFalse() {
- return 1 >= 2;
+ function doubleNotEqual(x, y) {
+ x = +x;
+ y = +y;
+ return (x != y) | 0;
}
- function unsignedLessThanTrue() {
- return (2 >>> 0) < (-1 >>> 0);
+ function doubleLessThan(x, y) {
+ x = +x;
+ y = +y;
+ return (x < y) | 0;
}
- function unsignedLessThanFalse() {
- return (-1 >>> 0) < (2 >>> 0);
+ function doubleLessThanOrEqual(x, y) {
+ x = +x;
+ y = +y;
+ return (x <= y) | 0;
}
- function unsignedLessThanOrEqualTrue() {
- return (2 >>> 0) <= (-1 >>> 0);
+ function doubleGreaterThan(x, y) {
+ x = +x;
+ y = +y;
+ return (x > y) | 0;
}
- function unsignedLessThanOrEqualFalse() {
- return (-1 >>> 0) <= (2 >>> 0);
+ function doubleGreaterThanOrEqual(x, y) {
+ x = +x;
+ y = +y;
+ return (x >= y) | 0;
}
- function unsignedGreaterThanTrue() {
- return (-1 >>> 0) > (2 >>> 0);
- }
+ return {
+ equal: equal,
+ notEqual: notEqual,
+ lessThan: lessThan,
+ lessThanOrEqual: lessThanOrEqual,
+ greaterThan: greaterThan,
+ greaterThanOrEqual: greaterThanOrEqual,
+ unsignedLessThan: unsignedLessThan,
+ unsignedLessThanOrEqual: unsignedLessThanOrEqual,
+ unsignedGreaterThan: unsignedGreaterThan,
+ unsignedGreaterThanOrEqual: unsignedGreaterThanOrEqual,
- function unsignedGreaterThanFalse() {
- return (2 >>> 0) > (-1 >>> 0);
- }
-
- function unsignedGreaterThanOrEqualTrue() {
- return (-1 >>> 0) >= (2 >>> 0);
- }
-
- function unsignedGreaterThanOrEqualFalse() {
- return (2 >>> 0) >= (-1 >>> 0);
- }
-
- return {
- equalTrue: equalTrue,
- equalFalse: equalFalse,
- notEqualTrue: notEqualTrue,
- notEqualFalse: notEqualFalse,
- lessThanTrue: lessThanTrue,
- lessThanFalse: lessThanFalse,
- lessThanOrEqualTrue: lessThanOrEqualTrue,
- lessThanOrEqualFalse: lessThanOrEqualFalse,
- greaterThanTrue: greaterThanTrue,
- greaterThanFalse: greaterThanFalse,
- greaterThanOrEqualTrue: greaterThanOrEqualTrue,
- greaterThanOrEqualFalse: greaterThanOrEqualFalse,
- unsignedLessThanTrue: unsignedLessThanTrue,
- unsignedLessThanFalse: unsignedLessThanFalse,
- unsignedLessThanOrEqualTrue: unsignedLessThanOrEqualTrue,
- unsignedLessThanOrEqualFalse: unsignedLessThanOrEqualFalse,
- unsignedGreaterThanTrue: unsignedGreaterThanTrue,
- unsignedGreaterThanFalse: unsignedGreaterThanFalse,
- unsignedGreaterThanOrEqualTrue: unsignedGreaterThanOrEqualTrue,
- unsignedGreaterThanOrEqualFalse: unsignedGreaterThanOrEqualFalse,
+ doubleEqual: doubleEqual,
+ doubleNotEqual: doubleNotEqual,
+ doubleLessThan: doubleLessThan,
+ doubleLessThanOrEqual: doubleLessThanOrEqual,
+ doubleGreaterThan: doubleGreaterThan,
+ doubleGreaterThanOrEqual: doubleGreaterThanOrEqual,
};
}
*/
var module = loadWebAssembly("wasm/relational.wasm");
-shouldBe(module.equalTrue(), 1);
-shouldBe(module.equalFalse(), 0);
-shouldBe(module.notEqualTrue(), 1);
-shouldBe(module.notEqualFalse(), 0);
-shouldBe(module.lessThanTrue(), 1);
-shouldBe(module.lessThanFalse(), 0);
-shouldBe(module.lessThanOrEqualTrue(), 1);
-shouldBe(module.lessThanOrEqualFalse(), 0);
-shouldBe(module.greaterThanTrue(), 1);
-shouldBe(module.greaterThanFalse(), 0);
-shouldBe(module.greaterThanOrEqualTrue(), 1);
-shouldBe(module.greaterThanOrEqualFalse(), 0);
-shouldBe(module.unsignedLessThanTrue(), 1);
-shouldBe(module.unsignedLessThanFalse(), 0);
-shouldBe(module.unsignedLessThanOrEqualTrue(), 1);
-shouldBe(module.unsignedLessThanOrEqualFalse(), 0);
-shouldBe(module.unsignedGreaterThanTrue(), 1);
-shouldBe(module.unsignedGreaterThanFalse(), 0);
-shouldBe(module.unsignedGreaterThanOrEqualTrue(), 1);
-shouldBe(module.unsignedGreaterThanOrEqualFalse(), 0);
+shouldBe(module.equal(1, 1), 1);
+shouldBe(module.equal(1, 2), 0);
+shouldBe(module.notEqual(1, 2), 1);
+shouldBe(module.notEqual(1, 1), 0);
+shouldBe(module.lessThan(-1, 2), 1);
+shouldBe(module.lessThan(1, 1), 0);
+shouldBe(module.lessThanOrEqual(1, 1), 1);
+shouldBe(module.lessThanOrEqual(2, 1), 0);
+shouldBe(module.greaterThan(2, -1), 1);
+shouldBe(module.greaterThan(1, 1), 0);
+shouldBe(module.greaterThanOrEqual(1, 1), 1);
+shouldBe(module.greaterThanOrEqual(1, 2), 0);
+shouldBe(module.unsignedLessThan(2, -1), 1);
+shouldBe(module.unsignedLessThan(-1, 2), 0);
+shouldBe(module.unsignedLessThanOrEqual(2, -1), 1);
+shouldBe(module.unsignedLessThanOrEqual(-1, 2), 0);
+shouldBe(module.unsignedGreaterThan(-1, 2), 1);
+shouldBe(module.unsignedGreaterThan(2, -1), 0);
+shouldBe(module.unsignedGreaterThanOrEqual(-1, 2), 1);
+shouldBe(module.unsignedGreaterThanOrEqual(2, -1), 0);
+
+shouldBe(module.doubleEqual(0.1, 0.1), 1);
+shouldBe(module.doubleEqual(0.1, 0.2), 0);
+shouldBe(module.doubleNotEqual(0.1, 0.2), 1);
+shouldBe(module.doubleNotEqual(0.1, 0.1), 0);
+shouldBe(module.doubleLessThan(-0.1, 0.2), 1);
+shouldBe(module.doubleLessThan(0.1, 0.1), 0);
+shouldBe(module.doubleLessThanOrEqual(0.1, 0.1), 1);
+shouldBe(module.doubleLessThanOrEqual(0.2, 0.1), 0);
+shouldBe(module.doubleGreaterThan(0.2, -0.1), 1);
+shouldBe(module.doubleGreaterThan(0.1, 0.1), 0);
+shouldBe(module.doubleGreaterThanOrEqual(0.1, 0.1), 1);
+shouldBe(module.doubleGreaterThanOrEqual(0.1, 0.2), 0);
+shouldBe(module.doubleEqual(NaN, NaN), 0);
+shouldBe(module.doubleNotEqual(NaN, NaN), 0);
+shouldBe(module.doubleNotEqual(NaN, 0.1), 0);
+shouldBe(module.doubleGreaterThan(NaN, 0.1), 0);
+shouldBe(module.doubleLessThan(NaN, 0.1), 0);
+shouldBe(module.doubleEqual(Infinity, Infinity), 1);
+shouldBe(module.doubleGreaterThan(Infinity, 0.1), 1);
+shouldBe(module.doubleGreaterThan(Infinity, NaN), 0);
+shouldBe(module.doubleLessThan(Infinity, NaN), 0);
Modified: trunk/Source/_javascript_Core/wasm/WASMFunctionCompiler.h (189548 => 189549)
--- trunk/Source/_javascript_Core/wasm/WASMFunctionCompiler.h 2015-09-09 20:58:44 UTC (rev 189548)
+++ trunk/Source/_javascript_Core/wasm/WASMFunctionCompiler.h 2015-09-09 21:01:03 UTC (rev 189549)
@@ -438,6 +438,43 @@
return UNUSED;
}
+ int buildRelationalF64(int, int, WASMOpExpressionI32 op)
+ {
+ loadDouble(temporaryAddress(m_tempStackTop - 2), FPRInfo::fpRegT0);
+ loadDouble(temporaryAddress(m_tempStackTop - 1), FPRInfo::fpRegT1);
+ DoubleCondition condition;
+ switch (op) {
+ case WASMOpExpressionI32::EqualF64:
+ condition = DoubleEqual;
+ break;
+ case WASMOpExpressionI32::NotEqualF64:
+ condition = DoubleNotEqual;
+ break;
+ case WASMOpExpressionI32::LessThanF64:
+ condition = DoubleLessThan;
+ break;
+ case WASMOpExpressionI32::LessThanOrEqualF64:
+ condition = DoubleLessThanOrEqual;
+ break;
+ case WASMOpExpressionI32::GreaterThanF64:
+ condition = DoubleGreaterThan;
+ break;
+ case WASMOpExpressionI32::GreaterThanOrEqualF64:
+ condition = DoubleGreaterThanOrEqual;
+ break;
+ default:
+ RELEASE_ASSERT_NOT_REACHED();
+ }
+ m_tempStackTop--;
+ Jump trueCase = branchDouble(condition, FPRInfo::fpRegT0, FPRInfo::fpRegT1);
+ store32(TrustedImm32(0), temporaryAddress(m_tempStackTop - 1));
+ Jump end = jump();
+ trueCase.link(this);
+ store32(TrustedImm32(1), temporaryAddress(m_tempStackTop - 1));
+ end.link(this);
+ return UNUSED;
+ }
+
void linkTarget(JumpTarget& target)
{
target.label = label();
Modified: trunk/Source/_javascript_Core/wasm/WASMFunctionParser.cpp (189548 => 189549)
--- trunk/Source/_javascript_Core/wasm/WASMFunctionParser.cpp 2015-09-09 20:58:44 UTC (rev 189548)
+++ trunk/Source/_javascript_Core/wasm/WASMFunctionParser.cpp 2015-09-09 21:01:03 UTC (rev 189549)
@@ -505,6 +505,13 @@
case WASMOpExpressionI32::SGreaterThanOrEqualI32:
case WASMOpExpressionI32::UGreaterThanOrEqualI32:
return parseRelationalI32ExpressionI32(context, op);
+ case WASMOpExpressionI32::EqualF64:
+ case WASMOpExpressionI32::NotEqualF64:
+ case WASMOpExpressionI32::LessThanF64:
+ case WASMOpExpressionI32::LessThanOrEqualF64:
+ case WASMOpExpressionI32::GreaterThanF64:
+ case WASMOpExpressionI32::GreaterThanOrEqualF64:
+ return parseRelationalF64ExpressionI32(context, op);
case WASMOpExpressionI32::GetGlobal:
case WASMOpExpressionI32::SetLocal:
case WASMOpExpressionI32::SetGlobal:
@@ -532,17 +539,11 @@
case WASMOpExpressionI32::FromF32:
case WASMOpExpressionI32::FromF64:
case WASMOpExpressionI32::EqualF32:
- case WASMOpExpressionI32::EqualF64:
case WASMOpExpressionI32::NotEqualF32:
- case WASMOpExpressionI32::NotEqualF64:
case WASMOpExpressionI32::LessThanF32:
- case WASMOpExpressionI32::LessThanF64:
case WASMOpExpressionI32::LessThanOrEqualF32:
- case WASMOpExpressionI32::LessThanOrEqualF64:
case WASMOpExpressionI32::GreaterThanF32:
- case WASMOpExpressionI32::GreaterThanF64:
case WASMOpExpressionI32::GreaterThanOrEqualF32:
- case WASMOpExpressionI32::GreaterThanOrEqualF64:
case WASMOpExpressionI32::SMin:
case WASMOpExpressionI32::UMin:
case WASMOpExpressionI32::SMax:
@@ -641,6 +642,16 @@
}
template <class Context>
+ContextExpression WASMFunctionParser::parseRelationalF64ExpressionI32(Context& context, WASMOpExpressionI32 op)
+{
+ ContextExpression left = parseExpressionF64(context);
+ PROPAGATE_ERROR();
+ ContextExpression right = parseExpressionF64(context);
+ PROPAGATE_ERROR();
+ return context.buildRelationalF64(left, right, op);
+}
+
+template <class Context>
ContextExpression WASMFunctionParser::parseExpressionF64(Context& context)
{
bool hasImmediate;
Modified: trunk/Source/_javascript_Core/wasm/WASMFunctionParser.h (189548 => 189549)
--- trunk/Source/_javascript_Core/wasm/WASMFunctionParser.h 2015-09-09 20:58:44 UTC (rev 189548)
+++ trunk/Source/_javascript_Core/wasm/WASMFunctionParser.h 2015-09-09 21:01:03 UTC (rev 189549)
@@ -88,6 +88,7 @@
template <class Context> ContextExpression parseUnaryExpressionI32(Context&, WASMOpExpressionI32);
template <class Context> ContextExpression parseBinaryExpressionI32(Context&, WASMOpExpressionI32);
template <class Context> ContextExpression parseRelationalI32ExpressionI32(Context&, WASMOpExpressionI32);
+ template <class Context> ContextExpression parseRelationalF64ExpressionI32(Context&, WASMOpExpressionI32);
template <class Context> ContextExpression parseExpressionF64(Context&);
template <class Context> ContextExpression parseConstantPoolIndexExpressionF64(Context&, uint32_t constantIndex);
Modified: trunk/Source/_javascript_Core/wasm/WASMFunctionSyntaxChecker.h (189548 => 189549)
--- trunk/Source/_javascript_Core/wasm/WASMFunctionSyntaxChecker.h 2015-09-09 20:58:44 UTC (rev 189548)
+++ trunk/Source/_javascript_Core/wasm/WASMFunctionSyntaxChecker.h 2015-09-09 21:01:03 UTC (rev 189549)
@@ -98,6 +98,12 @@
return UNUSED;
}
+ int buildRelationalF64(int, int, WASMOpExpressionI32)
+ {
+ m_tempStackTop--;
+ return UNUSED;
+ }
+
void linkTarget(const int&) { }
void jumpToTarget(const int&) { }
void jumpToTargetIf(JumpCondition, int, const int&)
_______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes