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 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 } | 981 } |
982 return 0; | 982 return 0; |
983 } | 983 } |
984 | 984 |
985 var funBin = [add, sub, sub, add]; | 985 var funBin = [add, sub, sub, add]; |
986 var fun = [inc]; | 986 var fun = [inc]; |
987 | 987 |
988 return {caller:caller}; | 988 return {caller:caller}; |
989 } | 989 } |
990 | 990 |
| 991 print("TestFunctionTable..."); |
991 var module = TestFunctionTable(stdlib); | 992 var module = TestFunctionTable(stdlib); |
992 assertEquals(55, module.caller(0, 0, 33, 22)); | 993 assertEquals(55, module.caller(0, 0, 33, 22)); |
993 assertEquals(11, module.caller(0, 1, 33, 22)); | 994 assertEquals(11, module.caller(0, 1, 33, 22)); |
994 assertEquals(9, module.caller(0, 2, 54, 45)); | 995 assertEquals(9, module.caller(0, 2, 54, 45)); |
995 assertEquals(99, module.caller(0, 3, 54, 45)); | 996 assertEquals(99, module.caller(0, 3, 54, 45)); |
996 assertEquals(23, module.caller(0, 4, 12, 11)); | 997 assertEquals(23, module.caller(0, 4, 12, 11)); |
997 assertEquals(31, module.caller(1, 0, 30, 11)); | 998 assertEquals(31, module.caller(1, 0, 30, 11)); |
998 })(); | 999 })(); |
999 | 1000 |
1000 | 1001 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1033 } | 1034 } |
1034 | 1035 |
1035 var foreign = new ffi(23); | 1036 var foreign = new ffi(23); |
1036 | 1037 |
1037 var module = AsmModule({Math: Math}, foreign, null); | 1038 var module = AsmModule({Math: Math}, foreign, null); |
1038 assertValidAsm(AsmModule); | 1039 assertValidAsm(AsmModule); |
1039 | 1040 |
1040 assertEquals(103, module.caller(23, 103)); | 1041 assertEquals(103, module.caller(23, 103)); |
1041 } | 1042 } |
1042 | 1043 |
| 1044 print("TestForeignFunctions..."); |
1043 TestForeignFunctions(); | 1045 TestForeignFunctions(); |
1044 | 1046 |
1045 | 1047 |
1046 function TestForeignFunctionMultipleUse() { | 1048 function TestForeignFunctionMultipleUse() { |
1047 function AsmModule(stdlib, foreign, buffer) { | 1049 function AsmModule(stdlib, foreign, buffer) { |
1048 "use asm"; | 1050 "use asm"; |
1049 | 1051 |
1050 var getVal = foreign.getVal; | 1052 var getVal = foreign.getVal; |
1051 | 1053 |
1052 function caller(int_val, double_val) { | 1054 function caller(int_val, double_val) { |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1587 "use asm"; | 1589 "use asm"; |
1588 function add(a, b) { | 1590 function add(a, b) { |
1589 a = a | 0; | 1591 a = a | 0; |
1590 b = b | 0; | 1592 b = b | 0; |
1591 return (a + b) | 0; | 1593 return (a + b) | 0; |
1592 } | 1594 } |
1593 return add; | 1595 return add; |
1594 } | 1596 } |
1595 | 1597 |
1596 assertEquals(7, TestSingleFunctionModule()(3, 4)); | 1598 assertEquals(7, TestSingleFunctionModule()(3, 4)); |
OLD | NEW |