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 IntTest() { | 7 function IntTest() { |
8 "use asm"; | 8 "use asm"; |
9 function sum(a, b) { | 9 function sum(a, b) { |
10 a = a|0; | 10 a = a|0; |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 var i = 0; | 631 var i = 0; |
632 for (i=1; i < 45 ; i = (i+1)|0) { | 632 for (i=1; i < 45 ; i = (i+1)|0) { |
633 } | 633 } |
634 return i|0; | 634 return i|0; |
635 } | 635 } |
636 | 636 |
637 return {caller:caller}; | 637 return {caller:caller}; |
638 } | 638 } |
639 | 639 |
640 assertEquals(45, WASM.asmCompileRun(TestForLoopWithoutBody.toString())); | 640 assertEquals(45, WASM.asmCompileRun(TestForLoopWithoutBody.toString())); |
| 641 |
| 642 function TestDoWhile() { |
| 643 "use asm" |
| 644 |
| 645 function caller() { |
| 646 var i = 0; |
| 647 var ret = 21; |
| 648 do { |
| 649 ret = (ret + ret)|0; |
| 650 i = (i + 1)|0; |
| 651 } while (i < 2); |
| 652 return ret|0; |
| 653 } |
| 654 |
| 655 return {caller:caller}; |
| 656 } |
| 657 |
| 658 assertEquals(84, WASM.asmCompileRun(TestDoWhile.toString())); |
| 659 |
| 660 function TestConditional() { |
| 661 "use asm" |
| 662 |
| 663 function caller() { |
| 664 var x = 1; |
| 665 return ((x > 0) ? 41 : 71)|0; |
| 666 } |
| 667 |
| 668 return {caller:caller}; |
| 669 } |
| 670 |
| 671 assertEquals(41, WASM.asmCompileRun(TestConditional.toString())); |
OLD | NEW |