| OLD | NEW | 
|---|
| 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 EmptyTest() { | 7 function EmptyTest() { | 
| 8   "use asm"; | 8   "use asm"; | 
| 9   function caller() { | 9   function caller() { | 
| 10     empty(); | 10     empty(); | 
| 11     return 11; | 11     return 11; | 
| 12   } | 12   } | 
| 13   function empty() { | 13   function empty() { | 
| 14   } | 14   } | 
| 15   return {caller: caller}; | 15   return {caller: caller}; | 
| 16 } | 16 } | 
| 17 | 17 | 
| 18 assertEquals(11, WASM.asmCompileRun(EmptyTest.toString())); | 18 assertEquals(11, _WASMEXP_.asmCompileRun(EmptyTest.toString())); | 
| 19 | 19 | 
| 20 function IntTest() { | 20 function IntTest() { | 
| 21   "use asm"; | 21   "use asm"; | 
| 22   function sum(a, b) { | 22   function sum(a, b) { | 
| 23     a = a|0; | 23     a = a|0; | 
| 24     b = b|0; | 24     b = b|0; | 
| 25     var c = (b + 1)|0 | 25     var c = (b + 1)|0 | 
| 26     var d = 3.0; | 26     var d = 3.0; | 
| 27     var e = d | 0;  // double conversion | 27     var e = d | 0;  // double conversion | 
| 28     return (a + c + 1)|0; | 28     return (a + c + 1)|0; | 
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 676   "use asm" | 676   "use asm" | 
| 677 | 677 | 
| 678   function caller() { | 678   function caller() { | 
| 679     var x = 1; | 679     var x = 1; | 
| 680     return ((x > 0) ? 41 : 71)|0; | 680     return ((x > 0) ? 41 : 71)|0; | 
| 681   } | 681   } | 
| 682 | 682 | 
| 683   return {caller:caller}; | 683   return {caller:caller}; | 
| 684 } | 684 } | 
| 685 | 685 | 
| 686 assertEquals(41, WASM.asmCompileRun(TestConditional.toString())); | 686 assertEquals(41, _WASMEXP_.asmCompileRun(TestConditional.toString())); | 
| 687 | 687 | 
| 688 function TestSwitch() { | 688 function TestSwitch() { | 
| 689   "use asm" | 689   "use asm" | 
| 690 | 690 | 
| 691   function caller() { | 691   function caller() { | 
| 692     var ret = 0; | 692     var ret = 0; | 
| 693     var x = 7; | 693     var x = 7; | 
| 694     switch (x) { | 694     switch (x) { | 
| 695       case 1: return 0; | 695       case 1: return 0; | 
| 696       case 7: { | 696       case 7: { | 
| 697         ret = 12; | 697         ret = 12; | 
| 698         break; | 698         break; | 
| 699       } | 699       } | 
| 700       default: return 0; | 700       default: return 0; | 
| 701     } | 701     } | 
| 702     switch (x) { | 702     switch (x) { | 
| 703       case 1: return 0; | 703       case 1: return 0; | 
| 704       case 8: return 0; | 704       case 8: return 0; | 
| 705       default: ret = (ret + 11)|0; | 705       default: ret = (ret + 11)|0; | 
| 706     } | 706     } | 
| 707     return ret|0; | 707     return ret|0; | 
| 708   } | 708   } | 
| 709 | 709 | 
| 710   return {caller:caller}; | 710   return {caller:caller}; | 
| 711 } | 711 } | 
| 712 | 712 | 
| 713 assertEquals(23, WASM.asmCompileRun(TestSwitch.toString())); | 713 assertEquals(23, _WASMEXP_.asmCompileRun(TestSwitch.toString())); | 
| 714 | 714 | 
| 715 function TestSwitchFallthrough() { | 715 function TestSwitchFallthrough() { | 
| 716   "use asm" | 716   "use asm" | 
| 717 | 717 | 
| 718   function caller() { | 718   function caller() { | 
| 719     var x = 17; | 719     var x = 17; | 
| 720     var ret = 0; | 720     var ret = 0; | 
| 721     switch (x) { | 721     switch (x) { | 
| 722       case 17: | 722       case 17: | 
| 723       case 14: ret = 39; | 723       case 14: ret = 39; | 
| 724       case 1: ret = (ret + 3)|0; | 724       case 1: ret = (ret + 3)|0; | 
| 725       case 4: break; | 725       case 4: break; | 
| 726       default: ret = (ret + 1)|0; | 726       default: ret = (ret + 1)|0; | 
| 727     } | 727     } | 
| 728     return ret|0; | 728     return ret|0; | 
| 729   } | 729   } | 
| 730 | 730 | 
| 731   return {caller:caller}; | 731   return {caller:caller}; | 
| 732 } | 732 } | 
| 733 | 733 | 
| 734 assertEquals(42, WASM.asmCompileRun(TestSwitchFallthrough.toString())); | 734 assertEquals(42, _WASMEXP_.asmCompileRun(TestSwitchFallthrough.toString())); | 
| 735 | 735 | 
| 736 function TestNestedSwitch() { | 736 function TestNestedSwitch() { | 
| 737   "use asm" | 737   "use asm" | 
| 738 | 738 | 
| 739   function caller() { | 739   function caller() { | 
| 740     var x = 3; | 740     var x = 3; | 
| 741     var y = -13; | 741     var y = -13; | 
| 742     switch (x) { | 742     switch (x) { | 
| 743       case 1: return 0; | 743       case 1: return 0; | 
| 744       case 3: { | 744       case 3: { | 
| 745         switch (y) { | 745         switch (y) { | 
| 746           case 2: return 0; | 746           case 2: return 0; | 
| 747           case -13: return 43; | 747           case -13: return 43; | 
| 748           default: return 0; | 748           default: return 0; | 
| 749         } | 749         } | 
| 750       } | 750       } | 
| 751       default: return 0; | 751       default: return 0; | 
| 752     } | 752     } | 
| 753     return 0; | 753     return 0; | 
| 754   } | 754   } | 
| 755 | 755 | 
| 756   return {caller:caller}; | 756   return {caller:caller}; | 
| 757 } | 757 } | 
| 758 | 758 | 
| 759 assertEquals(43, WASM.asmCompileRun(TestNestedSwitch.toString())); | 759 assertEquals(43, _WASMEXP_.asmCompileRun(TestNestedSwitch.toString())); | 
| OLD | NEW | 
|---|