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

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

Issue 2264913002: [wasm] asm.js - Remove Wasm.instantiateModuleFromAsm, use asm.js directly. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 4 years, 4 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-deopt.js ('k') | test/mjsunit/wasm/asm-wasm-f64.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: --validate-asm --allow-natives-syntax
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 fround = stdlib.Math.fround; 10 var fround = stdlib.Math.fround;
11 var Math_ceil = stdlib.Math.ceil; 11 var Math_ceil = stdlib.Math.ceil;
12 var Math_floor = stdlib.Math.floor; 12 var Math_floor = stdlib.Math.floor;
13 var Math_sqrt = stdlib.Math.sqrt; 13 var Math_sqrt = stdlib.Math.sqrt;
14 var Math_abs = stdlib.Math.abs; 14 var Math_abs = stdlib.Math.abs;
15 var Math_min = stdlib.Math.min; 15 var Math_min = stdlib.Math.min;
16 var Math_max = stdlib.Math.max; 16 var Math_max = stdlib.Math.max;
17 17
18 FUNC_BODY 18 FUNC_BODY
19 return {main: FUNC_NAME}; 19 return {main: FUNC_NAME};
20 } 20 }
21 21
22 var source = MODULE_NAME.toString() 22 var source = MODULE_NAME.toString()
23 .replace(/MODULE_NAME/g, func.name + "_module") 23 .replace(/MODULE_NAME/g, func.name + "_module")
24 .replace(/FUNC_BODY/g, func.toString()) 24 .replace(/FUNC_BODY/g, func.toString())
25 .replace(/FUNC_NAME/g, func.name); 25 .replace(/FUNC_NAME/g, func.name);
26 return eval("(" + source + ")"); 26 return eval("(" + source + ")");
27 } 27 }
28 28
29 function RunThreeWayTest(asmfunc, expect) { 29 function RunAsmJsTest(asmfunc, expect) {
30 var asm_source = asmfunc.toString(); 30 var asm_source = asmfunc.toString();
31 var nonasm_source = asm_source.replace(new RegExp("use asm"), ""); 31 var nonasm_source = asm_source.replace(new RegExp("use asm"), "");
32 var stdlib = {Math: Math}; 32 var stdlib = {Math: Math};
33 33
34 print("Testing " + asmfunc.name + " (js)...");
34 var js_module = eval("(" + nonasm_source + ")")(stdlib); 35 var js_module = eval("(" + nonasm_source + ")")(stdlib);
35 print("Testing " + asmfunc.name + " (js)...");
36 expect(js_module); 36 expect(js_module);
37 37
38 print("Testing " + asmfunc.name + " (asm.js)..."); 38 print("Testing " + asmfunc.name + " (asm.js)...");
39 var asm_module = asmfunc(stdlib); 39 var asm_module = asmfunc(stdlib);
40 assertTrue(%IsAsmWasmCode(asmfunc));
40 expect(asm_module); 41 expect(asm_module);
41
42 print("Testing " + asmfunc.name + " (wasm)...");
43 var wasm_module = Wasm.instantiateModuleFromAsm(asm_source, stdlib);
44 expect(wasm_module);
45 } 42 }
46 43
47 const fround = Math.fround; 44 const fround = Math.fround;
48 const Math_ceil = Math.ceil; 45 const Math_ceil = Math.ceil;
49 const Math_floor = Math.floor; 46 const Math_floor = Math.floor;
50 const Math_sqrt = Math.sqrt; 47 const Math_sqrt = Math.sqrt;
51 const Math_abs = Math.abs; 48 const Math_abs = Math.abs;
52 const Math_min = Math.min; 49 const Math_min = Math.min;
53 const Math_max = Math.max; 50 const Math_max = Math.max;
54 51
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 f32_eq, 208 f32_eq,
212 f32_ne, 209 f32_ne,
213 f32_lt, 210 f32_lt,
214 f32_lteq, 211 f32_lteq,
215 f32_gt, 212 f32_gt,
216 f32_gteq, 213 f32_gteq,
217 ]; 214 ];
218 215
219 (function () { 216 (function () {
220 for (func of funcs) { 217 for (func of funcs) {
221 RunThreeWayTest(WrapInAsmModule(func), function (module) { 218 RunAsmJsTest(WrapInAsmModule(func), function (module) {
222 if (func.length == 1) { 219 if (func.length == 1) {
223 for (a of inputs) { 220 for (a of inputs) {
224 assertEquals(func(a), module.main(a)); 221 assertEquals(func(a), module.main(a));
225 assertEquals(func(a / 11), module.main(a / 11)); 222 assertEquals(func(a / 11), module.main(a / 11));
226 assertEquals(func(a / 430.9), module.main(a / 430.9)); 223 assertEquals(func(a / 430.9), module.main(a / 430.9));
227 assertEquals(func(a / -31.1), module.main(a / -31.1)); 224 assertEquals(func(a / -31.1), module.main(a / -31.1));
228 } 225 }
229 } else { 226 } else {
230 for (a of inputs) { 227 for (a of inputs) {
231 for (b of inputs) { 228 for (b of inputs) {
232 assertEquals(func(a, b), module.main(a, b)); 229 assertEquals(func(a, b), module.main(a, b));
233 assertEquals(func(a / 11, b), module.main(a / 11, b)); 230 assertEquals(func(a / 11, b), module.main(a / 11, b));
234 assertEquals(func(a, b / 420.9), module.main(a, b / 420.9)); 231 assertEquals(func(a, b / 420.9), module.main(a, b / 420.9));
235 assertEquals(func(a / -31.1, b), module.main(a / -31.1, b)); 232 assertEquals(func(a / -31.1, b), module.main(a / -31.1, b));
236 } 233 }
237 } 234 }
238 } 235 }
239 }); 236 });
240 } 237 }
241 238
242 })(); 239 })();
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/asm-wasm-deopt.js ('k') | test/mjsunit/wasm/asm-wasm-f64.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698