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: --validate-asm --allow-natives-syntax | 5 // Flags: --validate-asm --allow-natives-syntax |
6 | 6 |
7 var stdlib = this; | 7 var stdlib = this; |
8 | 8 |
9 function assertValidAsm(func) { | 9 function assertValidAsm(func) { |
10 assertTrue(%IsAsmWasmCode(func)); | 10 assertTrue(%IsAsmWasmCode(func)); |
(...skipping 1578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1589 "use asm"; | 1589 "use asm"; |
1590 function add(a, b) { | 1590 function add(a, b) { |
1591 a = a | 0; | 1591 a = a | 0; |
1592 b = b | 0; | 1592 b = b | 0; |
1593 return (a + b) | 0; | 1593 return (a + b) | 0; |
1594 } | 1594 } |
1595 return add; | 1595 return add; |
1596 } | 1596 } |
1597 | 1597 |
1598 assertEquals(7, TestSingleFunctionModule()(3, 4)); | 1598 assertEquals(7, TestSingleFunctionModule()(3, 4)); |
| 1599 |
| 1600 |
| 1601 function TestNotZero() { |
| 1602 "use asm"; |
| 1603 function caller() { |
| 1604 if (!0) { |
| 1605 return 44; |
| 1606 } else { |
| 1607 return 55; |
| 1608 } |
| 1609 return 0; |
| 1610 } |
| 1611 return {caller: caller}; |
| 1612 } |
| 1613 |
| 1614 assertWasm(44, TestNotZero); |
| 1615 |
| 1616 |
| 1617 function TestNotOne() { |
| 1618 "use asm"; |
| 1619 function caller() { |
| 1620 if (!1) { |
| 1621 return 44; |
| 1622 } else { |
| 1623 return 55; |
| 1624 } |
| 1625 return 0; |
| 1626 } |
| 1627 return {caller: caller}; |
| 1628 } |
| 1629 |
| 1630 assertWasm(55, TestNotOne); |
OLD | NEW |