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

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

Issue 2011873002: [wasm] Check that type intersections don't yield empty. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 4 years, 6 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 | « src/typing-asm.cc ('k') | no next file » | 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 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 return 28; 675 return 28;
676 } 676 }
677 return 0; 677 return 0;
678 } 678 }
679 679
680 return {caller:caller}; 680 return {caller:caller};
681 } 681 }
682 682
683 assertWasm(28, TestModDoubleNegative); 683 assertWasm(28, TestModDoubleNegative);
684 684
685
685 (function () { 686 (function () {
686 function TestNamedFunctions() { 687 function TestNamedFunctions() {
687 "use asm"; 688 "use asm";
688 689
689 var a = 0.0; 690 var a = 0.0;
690 var b = 0.0; 691 var b = 0.0;
691 692
692 function add() { 693 function add() {
693 return +(a + b); 694 return +(a + b);
694 } 695 }
695 696
696 function init() { 697 function init() {
697 a = 43.25; 698 a = 43.25;
698 b = 34.25; 699 b = 34.25;
699 } 700 }
700 701
701 return {init:init, 702 return {init:init,
702 add:add}; 703 add:add};
703 } 704 }
704 705
705 var module = Wasm.instantiateModuleFromAsm(TestNamedFunctions.toString()); 706 var module = Wasm.instantiateModuleFromAsm(TestNamedFunctions.toString());
706 module.init(); 707 module.init();
707 assertEquals(77.5, module.add()); 708 assertEquals(77.5, module.add());
708 })(); 709 })();
709 710
711
710 (function () { 712 (function () {
711 function TestGlobalsWithInit() { 713 function TestGlobalsWithInit() {
712 "use asm"; 714 "use asm";
713 715
714 var a = 43.25; 716 var a = 43.25;
715 var b = 34.25; 717 var b = 34.25;
716 718
717 function add() { 719 function add() {
718 return +(a + b); 720 return +(a + b);
719 } 721 }
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 return ((a * 3) + (4 * a)) | 0; 1353 return ((a * 3) + (4 * a)) | 0;
1352 } 1354 }
1353 return {func: func}; 1355 return {func: func};
1354 } 1356 }
1355 1357
1356 var m = Wasm.instantiateModuleFromAsm(Module.toString()); 1358 var m = Wasm.instantiateModuleFromAsm(Module.toString());
1357 assertEquals(7, m.func()); 1359 assertEquals(7, m.func());
1358 })(); 1360 })();
1359 1361
1360 1362
1363 (function TestBadAssignDoubleFromIntish() {
1364 function Module(stdlib, foreign, heap) {
1365 "use asm";
1366 function func() {
1367 var a = 1;
1368 var b = 3.0;
1369 b = a;
1370 }
1371 return {func: func};
1372 }
1373 assertThrows(function() {
1374 Wasm.instantiateModuleFromAsm(Module.toString());
1375 });
1376 })();
1377
1378
1379 (function TestBadAssignIntFromDouble() {
1380 function Module(stdlib, foreign, heap) {
1381 "use asm";
1382 function func() {
1383 var a = 1;
1384 var b = 3.0;
1385 a = b;
1386 }
1387 return {func: func};
1388 }
1389 assertThrows(function() {
1390 Wasm.instantiateModuleFromAsm(Module.toString());
1391 });
1392 })();
1393
1394
1361 (function TestBadMultiplyIntish() { 1395 (function TestBadMultiplyIntish() {
1362 function Module(stdlib, foreign, heap) { 1396 function Module(stdlib, foreign, heap) {
1363 "use asm"; 1397 "use asm";
1364 function func() { 1398 function func() {
1365 var a = 1; 1399 var a = 1;
1366 return ((a + a) * 4) | 0; 1400 return ((a + a) * 4) | 0;
1367 } 1401 }
1368 return {func: func}; 1402 return {func: func};
1369 } 1403 }
1370 assertThrows(function() { 1404 assertThrows(function() {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1489 u0xffffffff: u0xffffffff, 1523 u0xffffffff: u0xffffffff,
1490 u0x80000000: u0x80000000, 1524 u0x80000000: u0x80000000,
1491 u0x87654321: u0x87654321, 1525 u0x87654321: u0x87654321,
1492 }; 1526 };
1493 } 1527 }
1494 var wasm = Wasm.instantiateModuleFromAsm(asmModule.toString()); 1528 var wasm = Wasm.instantiateModuleFromAsm(asmModule.toString());
1495 assertEquals(0xffffffff, wasm.u0xffffffff()); 1529 assertEquals(0xffffffff, wasm.u0xffffffff());
1496 assertEquals(0x80000000, wasm.u0x80000000()); 1530 assertEquals(0x80000000, wasm.u0x80000000());
1497 assertEquals(0x87654321, wasm.u0x87654321()); 1531 assertEquals(0x87654321, wasm.u0x87654321());
1498 })(); 1532 })();
OLDNEW
« no previous file with comments | « src/typing-asm.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698