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

Side by Side Diff: test/mjsunit/wasm/asm-wasm-u32.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-switch.js ('k') | test/mjsunit/wasm/embenchen/box2d.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 imul = stdlib.Math.imul; 10 var imul = stdlib.Math.imul;
11 11
12 FUNC_BODY 12 FUNC_BODY
13 return {main: FUNC_NAME}; 13 return {main: FUNC_NAME};
14 } 14 }
15 15
16 var source = MODULE_NAME.toString() 16 var source = MODULE_NAME.toString()
17 .replace(/MODULE_NAME/g, func.name + "_module") 17 .replace(/MODULE_NAME/g, func.name + "_module")
18 .replace(/FUNC_BODY/g, func.toString()) 18 .replace(/FUNC_BODY/g, func.toString())
19 .replace(/FUNC_NAME/g, func.name); 19 .replace(/FUNC_NAME/g, func.name);
20 return eval("(" + source + ")"); 20 return eval("(" + source + ")");
21 } 21 }
22 22
23 function RunThreeWayTest(asmfunc, expect) { 23 function RunAsmJsTest(asmfunc, expect) {
24 var asm_source = asmfunc.toString(); 24 var asm_source = asmfunc.toString();
25 var nonasm_source = asm_source.replace(new RegExp("use asm"), ""); 25 var nonasm_source = asm_source.replace(new RegExp("use asm"), "");
26 var stdlib = {Math: Math}; 26 var stdlib = {Math: Math};
27 27
28 print("Testing " + asmfunc.name + " (js)...");
28 var js_module = eval("(" + nonasm_source + ")")(stdlib); 29 var js_module = eval("(" + nonasm_source + ")")(stdlib);
29 print("Testing " + asmfunc.name + " (js)...");
30 expect(js_module); 30 expect(js_module);
31 31
32 print("Testing " + asmfunc.name + " (asm.js)..."); 32 print("Testing " + asmfunc.name + " (asm.js)...");
33 var asm_module = asmfunc(stdlib); 33 var asm_module = asmfunc(stdlib);
34 assertTrue(%IsAsmWasmCode(asmfunc));
34 expect(asm_module); 35 expect(asm_module);
35
36 print("Testing " + asmfunc.name + " (wasm)...");
37 var wasm_module = Wasm.instantiateModuleFromAsm(asm_source, stdlib);
38 expect(wasm_module);
39 } 36 }
40 37
41 const imul = Math.imul; 38 const imul = Math.imul;
42 39
43 function u32_add(a, b) { 40 function u32_add(a, b) {
44 a = a | 0; 41 a = a | 0;
45 b = b | 0; 42 b = b | 0;
46 return +(((a >>> 0) + (b >>> 0)) >>> 0); 43 return +(((a >>> 0) + (b >>> 0)) >>> 0);
47 } 44 }
48 45
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 u32_lteq, 202 u32_lteq,
206 u32_gt, 203 u32_gt,
207 u32_gteq, 204 u32_gteq,
208 // TODO(titzer): u32_min 205 // TODO(titzer): u32_min
209 // TODO(titzer): u32_max 206 // TODO(titzer): u32_max
210 // TODO(titzer): u32_abs 207 // TODO(titzer): u32_abs
211 ]; 208 ];
212 209
213 (function () { 210 (function () {
214 for (func of funcs) { 211 for (func of funcs) {
215 RunThreeWayTest(WrapInAsmModule(func), function (module) { 212 RunAsmJsTest(WrapInAsmModule(func), function (module) {
216 for (a of inputs) { 213 for (a of inputs) {
217 for (b of inputs) { 214 for (b of inputs) {
218 var expected = func(a, b); 215 var expected = func(a, b);
219 assertEquals(expected, module.main(a, b)); 216 assertEquals(expected, module.main(a, b));
220 } 217 }
221 } 218 }
222 }); 219 });
223 } 220 }
224 221
225 })(); 222 })();
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/asm-wasm-switch.js ('k') | test/mjsunit/wasm/embenchen/box2d.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698