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

Side by Side Diff: test/mjsunit/wasm/asm-wasm-i32.js

Issue 1830703003: [wasm] Enable more ASM->WASM tests. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Enable large unsigned literals test. Created 4 years, 9 months 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/asm-wasm-f64.js ('k') | test/mjsunit/wasm/asm-wasm-literals.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --expose-wasm 5 // Flags: --expose-wasm
6 6
7 function WrapInAsmModule(func) { 7 function WrapInAsmModule(func) {
8 function MODULE_NAME(stdlib) { 8 function MODULE_NAME(stdlib) {
9 "use asm"; 9 "use asm";
10 var imul = stdlib.Math.imul; 10 var imul = stdlib.Math.imul;
11 var Math_max = stdlib.Math.max;
12 var Math_min = stdlib.Math.min;
13 var Math_abs = stdlib.Math.abs;
11 14
12 FUNC_BODY 15 FUNC_BODY
13 return {main: FUNC_NAME}; 16 return {main: FUNC_NAME};
14 } 17 }
15 18
16 var source = MODULE_NAME.toString() 19 var source = MODULE_NAME.toString()
17 .replace(/MODULE_NAME/g, func.name + "_module") 20 .replace(/MODULE_NAME/g, func.name + "_module")
18 .replace(/FUNC_BODY/g, func.toString()) 21 .replace(/FUNC_BODY/g, func.toString())
19 .replace(/FUNC_NAME/g, func.name); 22 .replace(/FUNC_NAME/g, func.name);
20 return eval("(" + source + ")"); 23 return eval("(" + source + ")");
(...skipping 11 matching lines...) Expand all
32 print("Testing " + asmfunc.name + " (asm.js)..."); 35 print("Testing " + asmfunc.name + " (asm.js)...");
33 var asm_module = asmfunc(stdlib); 36 var asm_module = asmfunc(stdlib);
34 expect(asm_module); 37 expect(asm_module);
35 38
36 print("Testing " + asmfunc.name + " (wasm)..."); 39 print("Testing " + asmfunc.name + " (wasm)...");
37 var wasm_module = Wasm.instantiateModuleFromAsm(asm_source, stdlib); 40 var wasm_module = Wasm.instantiateModuleFromAsm(asm_source, stdlib);
38 expect(wasm_module); 41 expect(wasm_module);
39 } 42 }
40 43
41 const imul = Math.imul; 44 const imul = Math.imul;
45 const Math_max = Math.max;
46 const Math_min = Math.min;
47 const Math_abs = Math.abs;
42 48
43 function i32_add(a, b) { 49 function i32_add(a, b) {
44 a = a | 0; 50 a = a | 0;
45 b = b | 0; 51 b = b | 0;
46 return (a + b) | 0; 52 return (a + b) | 0;
47 } 53 }
48 54
49 function i32_sub(a, b) { 55 function i32_sub(a, b) {
50 a = a | 0; 56 a = a | 0;
51 b = b | 0; 57 b = b | 0;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 159
154 function i32_gteq(a, b) { 160 function i32_gteq(a, b) {
155 a = a | 0; 161 a = a | 0;
156 b = b | 0; 162 b = b | 0;
157 if ((a | 0) >= (b | 0)) { 163 if ((a | 0) >= (b | 0)) {
158 return 1; 164 return 1;
159 } 165 }
160 return 0; 166 return 0;
161 } 167 }
162 168
169 function i32_min(a, b) {
170 a = a | 0;
171 b = b | 0;
172 return Math_min(a | 0, b | 0) | 0;
173 }
174
175 function i32_max(a, b) {
176 a = a | 0;
177 b = b | 0;
178 return Math_max(a | 0, b | 0) | 0;
179 }
180
181 function i32_abs(a) {
182 a = a | 0;
183 return Math_abs(a | 0) | 0;
184 }
185
163 var inputs = [ 186 var inputs = [
164 0, 1, 2, 3, 4, 187 0, 1, 2, 3, 4,
165 10, 20, 30, 31, 32, 33, 100, 2000, 188 10, 20, 30, 31, 32, 33, 100, 2000,
166 30000, 400000, 5000000, 189 30000, 400000, 5000000,
167 100000000, 2000000000, 190 100000000, 2000000000,
168 2147483646, 191 2147483646,
169 2147483647, 192 2147483647,
170 2147483648, 193 2147483648,
171 2147483649, 194 2147483649,
172 0x273a798e, 0x187937a3, 0xece3af83, 0x5495a16b, 0x0b668ecc, 0x11223344, 195 0x273a798e, 0x187937a3, 0xece3af83, 0x5495a16b, 0x0b668ecc, 0x11223344,
(...skipping 25 matching lines...) Expand all
198 i32_xor, 221 i32_xor,
199 // TODO(titzer): i32_shl on arm 222 // TODO(titzer): i32_shl on arm
200 // TODO(titzer): i32_shr on arm 223 // TODO(titzer): i32_shr on arm
201 // TODO(titzer): i32_sar on arm 224 // TODO(titzer): i32_sar on arm
202 i32_eq, 225 i32_eq,
203 i32_ne, 226 i32_ne,
204 i32_lt, 227 i32_lt,
205 i32_lteq, 228 i32_lteq,
206 i32_gt, 229 i32_gt,
207 i32_gteq, 230 i32_gteq,
208 // TODO(titzer): i32_min 231 i32_min,
209 // TODO(titzer): i32_max 232 i32_max,
210 // TODO(titzer): i32_abs 233 i32_abs
211 ]; 234 ];
212 235
213 (function () { 236 (function () {
214 for (func of funcs) { 237 for (func of funcs) {
215 RunThreeWayTest(WrapInAsmModule(func), function (module) { 238 RunThreeWayTest(WrapInAsmModule(func), function (module) {
216 for (a of inputs) { 239 if (func.length == 1) {
217 for (b of inputs) { 240 for (a of inputs) {
218 var expected = func(a, b); 241 assertEquals(func(a), module.main(a));
219 assertEquals(expected, module.main(a, b)); 242 }
243 } else {
244 for (a of inputs) {
245 for (b of inputs) {
246 assertEquals(func(a, b), module.main(a, b));
247 }
220 } 248 }
221 } 249 }
222 }); 250 });
223 } 251 }
224 252
225 })(); 253 })();
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/asm-wasm-f64.js ('k') | test/mjsunit/wasm/asm-wasm-literals.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698