summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/asm
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/mjsunit/asm')
-rw-r--r--deps/v8/test/mjsunit/asm/asm-validation.js82
-rw-r--r--deps/v8/test/mjsunit/asm/b5528-comma.js31
-rw-r--r--deps/v8/test/mjsunit/asm/regress-660813.js12
3 files changed, 125 insertions, 0 deletions
diff --git a/deps/v8/test/mjsunit/asm/asm-validation.js b/deps/v8/test/mjsunit/asm/asm-validation.js
index eae282ca57..06799dab67 100644
--- a/deps/v8/test/mjsunit/asm/asm-validation.js
+++ b/deps/v8/test/mjsunit/asm/asm-validation.js
@@ -8,6 +8,76 @@ function assertValidAsm(func) {
assertTrue(%IsAsmWasmCode(func));
}
+(function TestConst() {
+ function Module(s) {
+ "use asm";
+ var fround = s.Math.fround;
+ // Global constants. These are treated just like numeric literals.
+ const fConst = fround(-3.0);
+ const dConst = -3.0;
+ const iConst = -3;
+
+ // consts can be used to initialize other consts.
+ const fPrime = fConst;
+
+ // The following methods verify that return statements with global constants
+ // do not need type annotations.
+ function f() {
+ return fPrime;
+ }
+ function d() {
+ return dConst;
+ }
+ function i() {
+ return iConst;
+ }
+
+ // The following methods verify that locals initialized with global
+ // constants do not need type annotations.
+ function fVar() {
+ var v = fPrime;
+ return fround(v);
+ }
+ function iVar() {
+ var v = iConst;
+ return v|0;
+ }
+ function dVar() {
+ var v = dConst;
+ return +v;
+ }
+
+ return {
+ f: f, d: d, i: i,
+ fVar: fVar, dVar: dVar, iVar: iVar,
+ };
+ }
+
+ function DisallowAssignToConstGlobal() {
+ const constant = 0;
+ function invalid(i) {
+ i = i|0;
+ constant = i;
+ return constant;
+ }
+ return invalid;
+ }
+
+ var m = Module(this);
+ assertValidAsm(Module);
+
+ assertEquals(-3, m.i());
+ assertEquals(-3.0, m.d());
+ assertEquals(Math.fround(-3.0), m.f());
+
+ assertEquals(-3, m.iVar());
+ assertEquals(-3.0, m.dVar());
+ assertEquals(Math.fround(-3.0), m.fVar());
+
+ var m = DisallowAssignToConstGlobal();
+ assertTrue(%IsNotAsmWasmCode(DisallowAssignToConstGlobal));
+})();
+
(function TestModuleArgs() {
function Module1(stdlib) {
"use asm";
@@ -213,3 +283,15 @@ function assertValidAsm(func) {
assertValidAsm(Module);
assertEquals(123, m.foo());
})();
+
+(function TestBadConstUnsignedReturn() {
+ function Module() {
+ "use asm";
+ const i = 0xffffffff;
+ function foo() { return i; }
+ return { foo: foo };
+ }
+ var m = Module();
+ assertTrue(%IsNotAsmWasmCode(Module));
+ assertEquals(0xffffffff, m.foo());
+})();
diff --git a/deps/v8/test/mjsunit/asm/b5528-comma.js b/deps/v8/test/mjsunit/asm/b5528-comma.js
new file mode 100644
index 0000000000..a6eab6d2ea
--- /dev/null
+++ b/deps/v8/test/mjsunit/asm/b5528-comma.js
@@ -0,0 +1,31 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+function Module(stdlib, env, heap) {
+ "use asm";
+
+ var a = new stdlib.Int32Array(heap);
+ var b = new stdlib.Float32Array(heap);
+ var fround = stdlib.Math.fround;
+ var value = env.value|0;
+
+ function foo() {
+ var x = fround(0.0);
+ x = (a[0]=value|0,fround(b[0]));
+ return fround(x);
+ }
+
+ return { foo: foo };
+}
+
+var buffer = new ArrayBuffer(32);
+assertEquals(0.0, Module(this, {value: 0x00000000}, buffer).foo());
+assertEquals(-0.0, Module(this, {value: 0x80000000}, buffer).foo());
+assertEquals(5.0, Module(this, {value: 0x40a00000}, buffer).foo());
+assertEquals(-5.0, Module(this, {value: 0xc0a00000}, buffer).foo());
+assertEquals(129.375, Module(this, {value: 0x43016000}, buffer).foo());
+assertEquals(-129.375, Module(this, {value: 0xc3016000}, buffer).foo());
+assertEquals(Infinity, Module(this, {value: 0x7f800000}, buffer).foo());
+assertEquals(-Infinity, Module(this, {value: 0xff800000}, buffer).foo());
+assertEquals(NaN, Module(this, {value: 0x7fffffff}, buffer).foo());
diff --git a/deps/v8/test/mjsunit/asm/regress-660813.js b/deps/v8/test/mjsunit/asm/regress-660813.js
new file mode 100644
index 0000000000..e9bf5797c7
--- /dev/null
+++ b/deps/v8/test/mjsunit/asm/regress-660813.js
@@ -0,0 +1,12 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+function Module() {
+ "use asm";
+ const i = 0xffffffff;
+ function foo() {
+ return i;
+ }
+}
+Module();