Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Unified Diff: test/mjsunit/wasm/params.js

Issue 1504713014: Initial import of v8-native WASM. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/wasm/module-memory.js ('k') | test/mjsunit/wasm/stackwalk.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/wasm/params.js
diff --git a/test/mjsunit/wasm/params.js b/test/mjsunit/wasm/params.js
new file mode 100644
index 0000000000000000000000000000000000000000..148544601ec807729122f471e4fc14774877ab61
--- /dev/null
+++ b/test/mjsunit/wasm/params.js
@@ -0,0 +1,137 @@
+// Copyright 2015 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.
+
+load("test/mjsunit/wasm/wasm-constants.js");
+
+function runSelect2(module, which, a, b) {
+ assertEquals(which == 0 ? a : b, module.select(a, b));
+}
+
+function testSelect2(type) {
+ var kBodySize = 2;
+ var kNameOffset = 21 + kBodySize + 1;
+
+ for (var which = 0; which < 2; which++) {
+ print("type = " + type + ", which = " + which);
+
+ var data = bytes(
+ // -- memory
+ kDeclMemory,
+ 12, 12, 1, // memory
+ // -- signatures
+ kDeclSignatures, 1,
+ 2, type, type, type, // signature: (t,t)->t
+ // -- select
+ kDeclFunctions, 1,
+ kDeclFunctionName | kDeclFunctionExport,
+ 0, 0,
+ kNameOffset, 0, 0, 0, // name offset
+ kBodySize, 0, // body size
+ kExprGetLocal, which, // --
+ kDeclEnd,
+ 's','e','l','e','c','t',0 // name
+ );
+
+ var module = WASM.instantiateModule(data);
+
+ assertEquals("function", typeof module.select);
+ runSelect2(module, which, 99, 97);
+ runSelect2(module, which, -99, -97);
+
+ if (type != kAstF32) {
+ runSelect2(module, which, 0x80000000 | 0, 0x7fffffff | 0);
+ runSelect2(module, which, 0x80000001 | 0, 0x7ffffffe | 0);
+ runSelect2(module, which, 0xffffffff | 0, 0xfffffffe | 0);
+ runSelect2(module, which, -2147483647, 2147483646);
+ runSelect2(module, which, -2147483646, 2147483645);
+ runSelect2(module, which, -2147483648, 2147483647);
+ }
+
+ if (type != kAstI32 && type != kAstI64) {
+ runSelect2(module, which, -1.25, 5.25);
+ runSelect2(module, which, Infinity, -Infinity);
+ }
+ }
+}
+
+
+testSelect2(kAstI32);
+testSelect2(kAstF32);
+testSelect2(kAstF64);
+
+
+function runSelect10(module, which, a, b) {
+ var x = -1;
+
+ var result = [
+ module.select(a, b, x, x, x, x, x, x, x, x),
+ module.select(x, a, b, x, x, x, x, x, x, x),
+ module.select(x, x, a, b, x, x, x, x, x, x),
+ module.select(x, x, x, a, b, x, x, x, x, x),
+ module.select(x, x, x, x, a, b, x, x, x, x),
+ module.select(x, x, x, x, x, a, b, x, x, x),
+ module.select(x, x, x, x, x, x, a, b, x, x),
+ module.select(x, x, x, x, x, x, x, a, b, x),
+ module.select(x, x, x, x, x, x, x, x, a, b),
+ module.select(x, x, x, x, x, x, x, x, x, a)
+ ];
+
+ for (var i = 0; i < 10; i++) {
+ if (which == i) assertEquals(a, result[i]);
+ else if (which == i+1) assertEquals(b, result[i]);
+ else assertEquals(x, result[i]);
+ }
+}
+
+function testSelect10(type) {
+ var kBodySize = 2;
+ var kNameOffset = 29 + kBodySize + 1;
+
+ for (var which = 0; which < 10; which++) {
+ print("type = " + type + ", which = " + which);
+
+ var t = type;
+ var data = bytes(
+ kDeclMemory,
+ 12, 12, 1, // memory
+ // signatures
+ kDeclSignatures, 1,
+ 10, t,t,t,t,t,t,t,t,t,t,t, // (tx10)->t
+ // main function
+ kDeclFunctions, 1,
+ kDeclFunctionName | kDeclFunctionExport,
+ 0, 0,
+ kNameOffset, 0, 0, 0, // name offset
+ kBodySize, 0, // body size
+ kExprGetLocal, which, // --
+ kDeclEnd,
+ 's','e','l','e','c','t',0 // name
+ );
+
+ var module = WASM.instantiateModule(data);
+
+ assertEquals("function", typeof module.select);
+ runSelect10(module, which, 99, 97);
+ runSelect10(module, which, -99, -97);
+
+ if (type != kAstF32) {
+ runSelect10(module, which, 0x80000000 | 0, 0x7fffffff | 0);
+ runSelect10(module, which, 0x80000001 | 0, 0x7ffffffe | 0);
+ runSelect10(module, which, 0xffffffff | 0, 0xfffffffe | 0);
+ runSelect10(module, which, -2147483647, 2147483646);
+ runSelect10(module, which, -2147483646, 2147483645);
+ runSelect10(module, which, -2147483648, 2147483647);
+ }
+
+ if (type != kAstI32 && type != kAstI64) {
+ runSelect10(module, which, -1.25, 5.25);
+ runSelect10(module, which, Infinity, -Infinity);
+ }
+ }
+}
+
+
+testSelect10(kAstI32);
+testSelect10(kAstF32);
+testSelect10(kAstF64);
« no previous file with comments | « test/mjsunit/wasm/module-memory.js ('k') | test/mjsunit/wasm/stackwalk.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698