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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 load("test/mjsunit/wasm/wasm-constants.js");
6
7 function runSelect2(module, which, a, b) {
8 assertEquals(which == 0 ? a : b, module.select(a, b));
9 }
10
11 function testSelect2(type) {
12 var kBodySize = 2;
13 var kNameOffset = 21 + kBodySize + 1;
14
15 for (var which = 0; which < 2; which++) {
16 print("type = " + type + ", which = " + which);
17
18 var data = bytes(
19 // -- memory
20 kDeclMemory,
21 12, 12, 1, // memory
22 // -- signatures
23 kDeclSignatures, 1,
24 2, type, type, type, // signature: (t,t)->t
25 // -- select
26 kDeclFunctions, 1,
27 kDeclFunctionName | kDeclFunctionExport,
28 0, 0,
29 kNameOffset, 0, 0, 0, // name offset
30 kBodySize, 0, // body size
31 kExprGetLocal, which, // --
32 kDeclEnd,
33 's','e','l','e','c','t',0 // name
34 );
35
36 var module = WASM.instantiateModule(data);
37
38 assertEquals("function", typeof module.select);
39 runSelect2(module, which, 99, 97);
40 runSelect2(module, which, -99, -97);
41
42 if (type != kAstF32) {
43 runSelect2(module, which, 0x80000000 | 0, 0x7fffffff | 0);
44 runSelect2(module, which, 0x80000001 | 0, 0x7ffffffe | 0);
45 runSelect2(module, which, 0xffffffff | 0, 0xfffffffe | 0);
46 runSelect2(module, which, -2147483647, 2147483646);
47 runSelect2(module, which, -2147483646, 2147483645);
48 runSelect2(module, which, -2147483648, 2147483647);
49 }
50
51 if (type != kAstI32 && type != kAstI64) {
52 runSelect2(module, which, -1.25, 5.25);
53 runSelect2(module, which, Infinity, -Infinity);
54 }
55 }
56 }
57
58
59 testSelect2(kAstI32);
60 testSelect2(kAstF32);
61 testSelect2(kAstF64);
62
63
64 function runSelect10(module, which, a, b) {
65 var x = -1;
66
67 var result = [
68 module.select(a, b, x, x, x, x, x, x, x, x),
69 module.select(x, a, b, x, x, x, x, x, x, x),
70 module.select(x, x, a, b, x, x, x, x, x, x),
71 module.select(x, x, x, a, b, x, x, x, x, x),
72 module.select(x, x, x, x, a, b, x, x, x, x),
73 module.select(x, x, x, x, x, a, b, x, x, x),
74 module.select(x, x, x, x, x, x, a, b, x, x),
75 module.select(x, x, x, x, x, x, x, a, b, x),
76 module.select(x, x, x, x, x, x, x, x, a, b),
77 module.select(x, x, x, x, x, x, x, x, x, a)
78 ];
79
80 for (var i = 0; i < 10; i++) {
81 if (which == i) assertEquals(a, result[i]);
82 else if (which == i+1) assertEquals(b, result[i]);
83 else assertEquals(x, result[i]);
84 }
85 }
86
87 function testSelect10(type) {
88 var kBodySize = 2;
89 var kNameOffset = 29 + kBodySize + 1;
90
91 for (var which = 0; which < 10; which++) {
92 print("type = " + type + ", which = " + which);
93
94 var t = type;
95 var data = bytes(
96 kDeclMemory,
97 12, 12, 1, // memory
98 // signatures
99 kDeclSignatures, 1,
100 10, t,t,t,t,t,t,t,t,t,t,t, // (tx10)->t
101 // main function
102 kDeclFunctions, 1,
103 kDeclFunctionName | kDeclFunctionExport,
104 0, 0,
105 kNameOffset, 0, 0, 0, // name offset
106 kBodySize, 0, // body size
107 kExprGetLocal, which, // --
108 kDeclEnd,
109 's','e','l','e','c','t',0 // name
110 );
111
112 var module = WASM.instantiateModule(data);
113
114 assertEquals("function", typeof module.select);
115 runSelect10(module, which, 99, 97);
116 runSelect10(module, which, -99, -97);
117
118 if (type != kAstF32) {
119 runSelect10(module, which, 0x80000000 | 0, 0x7fffffff | 0);
120 runSelect10(module, which, 0x80000001 | 0, 0x7ffffffe | 0);
121 runSelect10(module, which, 0xffffffff | 0, 0xfffffffe | 0);
122 runSelect10(module, which, -2147483647, 2147483646);
123 runSelect10(module, which, -2147483646, 2147483645);
124 runSelect10(module, which, -2147483648, 2147483647);
125 }
126
127 if (type != kAstI32 && type != kAstI64) {
128 runSelect10(module, which, -1.25, 5.25);
129 runSelect10(module, which, Infinity, -Infinity);
130 }
131 }
132 }
133
134
135 testSelect10(kAstI32);
136 testSelect10(kAstF32);
137 testSelect10(kAstF64);
OLDNEW
« 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