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

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

Issue 2134333003: V8. ASM-2-WASM. Migrates asm-wasm-builder to the new asm-typer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addresses comments. Created 4 years, 5 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/regress/regress-599717.js ('k') | test/mjsunit/wasm/asm-wasm-stdlib.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 2015 the V8 project authors. All rights reserved. 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 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 assertWasm(expected, func, ffi) { 7 function assertWasm(expected, func, ffi) {
8 print("Testing " + func.name + "..."); 8 print("Testing " + func.name + "...");
9 assertEquals(expected, Wasm.instantiateModuleFromAsm( 9 assertEquals(expected, Wasm.instantiateModuleFromAsm(
10 func.toString(), ffi).caller()); 10 func.toString(), ffi).caller());
(...skipping 25 matching lines...) Expand all
36 return {caller: caller}; 36 return {caller: caller};
37 } 37 }
38 38
39 assertWasm(19, VoidReturnTest); 39 assertWasm(19, VoidReturnTest);
40 40
41 function IntTest() { 41 function IntTest() {
42 "use asm"; 42 "use asm";
43 function sum(a, b) { 43 function sum(a, b) {
44 a = a|0; 44 a = a|0;
45 b = b|0; 45 b = b|0;
46 var c = (b + 1)|0 46 var c = 0;
47 var d = 3.0; 47 var d = 3.0;
48 var e = ~~d; // double conversion 48 var e = 0;
49 e = ~~d; // double conversion
50 c = (b + 1)|0
49 return (a + c + 1)|0; 51 return (a + c + 1)|0;
50 } 52 }
51 53
52 function caller() { 54 function caller() {
53 return sum(77,22) | 0; 55 return sum(77,22) | 0;
54 } 56 }
55 57
56 return {caller: caller}; 58 return {caller: caller};
57 } 59 }
58 60
59 assertWasm(101,IntTest); 61 assertWasm(101,IntTest);
60 62
61 63
62 function Float64Test() { 64 function Float64Test() {
63 "use asm"; 65 "use asm";
64 function sum(a, b) { 66 function sum(a, b) {
65 a = +a; 67 a = +a;
66 b = +b; 68 b = +b;
67 return +(a + b); 69 return +(a + b);
68 } 70 }
69 71
70 function caller() { 72 function caller() {
71 var a = +sum(70.1,10.2); 73 var a = 0.0;
72 var ret = 0|0; 74 var ret = 0|0;
75 a = +sum(70.1,10.2);
73 if (a == 80.3) { 76 if (a == 80.3) {
74 ret = 1|0; 77 ret = 1|0;
75 } else { 78 } else {
76 ret = 0|0; 79 ret = 0|0;
77 } 80 }
78 return ret|0; 81 return ret|0;
79 } 82 }
80 83
81 return {caller: caller}; 84 return {caller: caller};
82 } 85 }
83 86
84 assertWasm(1, Float64Test); 87 assertWasm(1, Float64Test);
85 88
86 89
87 function BadModule() { 90 function BadModule() {
88 "use asm"; 91 "use asm";
89 function caller(a, b) { 92 function caller(a, b) {
90 a = a|0; 93 a = a|0;
91 b = b+0; 94 b = b+0;
92 var c = (b + 1)|0 95 var c = 0;
96 c = (b + 1)|0
93 return (a + c + 1)|0; 97 return (a + c + 1)|0;
94 } 98 }
95 99
96 function caller() { 100 function caller() {
97 return call(1, 2)|0; 101 return call(1, 2)|0;
98 } 102 }
99 103
100 return {caller: caller}; 104 return {caller: caller};
101 } 105 }
102 106
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 return {caller: caller}; 290 return {caller: caller};
287 } 291 }
288 292
289 assertWasm(8, TestBreakInIfInWhile); 293 assertWasm(8, TestBreakInIfInWhile);
290 294
291 function TestBreakInNestedWhile() { 295 function TestBreakInNestedWhile() {
292 "use asm"; 296 "use asm";
293 297
294 function caller() { 298 function caller() {
295 var x = 1.0; 299 var x = 1.0;
300 var ret = 0;
296 while(x < 1.5) { 301 while(x < 1.5) {
297 while(1) 302 while(1)
298 break; 303 break;
299 x = +(x + 0.25); 304 x = +(x + 0.25);
300 } 305 }
301 var ret = 0;
302 if (x == 1.5) { 306 if (x == 1.5) {
303 ret = 9; 307 ret = 9;
304 } 308 }
305 return ret|0; 309 return ret|0;
306 } 310 }
307 311
308 return {caller: caller}; 312 return {caller: caller};
309 } 313 }
310 314
311 assertWasm(9, TestBreakInNestedWhile); 315 assertWasm(9, TestBreakInNestedWhile);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 return {caller: caller}; 402 return {caller: caller};
399 } 403 }
400 404
401 assertWasm(20, TestContinueInNamedWhile); 405 assertWasm(20, TestContinueInNamedWhile);
402 406
403 407
404 function TestNot() { 408 function TestNot() {
405 "use asm"; 409 "use asm";
406 410
407 function caller() { 411 function caller() {
408 var a = !(2 > 3); 412 var a = 0;
413 a = !(2 > 3);
409 return a | 0; 414 return a | 0;
410 } 415 }
411 416
412 return {caller:caller}; 417 return {caller:caller};
413 } 418 }
414 419
415 assertWasm(1, TestNot); 420 assertWasm(1, TestNot);
416 421
417 422
418 function TestNotEquals() { 423 function TestNotEquals() {
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 })(); 884 })();
880 885
881 function TestFunctionTableSingleFunction() { 886 function TestFunctionTableSingleFunction() {
882 "use asm"; 887 "use asm";
883 888
884 function dummy() { 889 function dummy() {
885 return 71; 890 return 71;
886 } 891 }
887 892
888 function caller() { 893 function caller() {
889 return function_table[0&0]() | 0; 894 // TODO(jpp): the parser optimizes function_table[0&0] to function table[0].
895 var v = 0;
896 return function_table[v&0]() | 0;
890 } 897 }
891 898
892 var function_table = [dummy] 899 var function_table = [dummy]
893 900
894 return {caller:caller}; 901 return {caller:caller};
895 } 902 }
896 903
897 assertWasm(71, TestFunctionTableSingleFunction); 904 assertWasm(71, TestFunctionTableSingleFunction);
898 905
899 906
900 function TestFunctionTableMultipleFunctions() { 907 function TestFunctionTableMultipleFunctions() {
901 "use asm"; 908 "use asm";
902 909
903 function inc1(x) { 910 function inc1(x) {
904 x = x|0; 911 x = x|0;
905 return (x+1)|0; 912 return (x+1)|0;
906 } 913 }
907 914
908 function inc2(x) { 915 function inc2(x) {
909 x = x|0; 916 x = x|0;
910 return (x+2)|0; 917 return (x+2)|0;
911 } 918 }
912 919
913 function caller() { 920 function caller() {
914 if ((function_table[0&1](50)|0) == 51) { 921 var i = 0, j = 1;
915 if ((function_table[1&1](60)|0) == 62) { 922 if ((function_table[i&1](50)|0) == 51) {
923 if ((function_table[j&1](60)|0) == 62) {
916 return 73; 924 return 73;
917 } 925 }
918 } 926 }
919 return 0; 927 return 0;
920 } 928 }
921 929
922 var function_table = [inc1, inc2] 930 var function_table = [inc1, inc2]
923 931
924 return {caller:caller}; 932 return {caller:caller};
925 } 933 }
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 var m = Wasm.instantiateModuleFromAsm(Module.toString()); 1351 var m = Wasm.instantiateModuleFromAsm(Module.toString());
1344 assertEquals(1.23, m.func()); 1352 assertEquals(1.23, m.func());
1345 }); 1353 });
1346 1354
1347 1355
1348 (function TestIntegerMultiplyBothWays() { 1356 (function TestIntegerMultiplyBothWays() {
1349 function Module(stdlib, foreign, heap) { 1357 function Module(stdlib, foreign, heap) {
1350 "use asm"; 1358 "use asm";
1351 function func() { 1359 function func() {
1352 var a = 1; 1360 var a = 1;
1353 return ((a * 3) + (4 * a)) | 0; 1361 return (((a * 3)|0) + ((4 * a)|0)) | 0;
1354 } 1362 }
1355 return {func: func}; 1363 return {func: func};
1356 } 1364 }
1357 1365
1358 var m = Wasm.instantiateModuleFromAsm(Module.toString()); 1366 var m = Wasm.instantiateModuleFromAsm(Module.toString());
1359 assertEquals(7, m.func()); 1367 assertEquals(7, m.func());
1360 })(); 1368 })();
1361 1369
1362 1370
1363 (function TestBadAssignDoubleFromIntish() { 1371 (function TestBadAssignDoubleFromIntish() {
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1586 if ((val>>>0) == 2147483668) { 1594 if ((val>>>0) == 2147483668) {
1587 return 323; 1595 return 323;
1588 } 1596 }
1589 return 0; 1597 return 0;
1590 } 1598 }
1591 return {main:main}; 1599 return {main:main};
1592 } 1600 }
1593 var wasm = Wasm.instantiateModuleFromAsm(asmModule.toString()); 1601 var wasm = Wasm.instantiateModuleFromAsm(asmModule.toString());
1594 assertEquals(323, wasm.main()); 1602 assertEquals(323, wasm.main());
1595 })(); 1603 })();
OLDNEW
« no previous file with comments | « test/mjsunit/regress/regress-599717.js ('k') | test/mjsunit/wasm/asm-wasm-stdlib.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698