| 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 14 matching lines...) Expand all Loading... |
| 1015 return 0; | 1016 return 0; |
| 1016 } | 1017 } |
| 1017 | 1018 |
| 1018 return {caller:caller}; | 1019 return {caller:caller}; |
| 1019 } | 1020 } |
| 1020 | 1021 |
| 1021 function ffi(initial_val) { | 1022 function ffi(initial_val) { |
| 1022 var val = initial_val; | 1023 var val = initial_val; |
| 1023 | 1024 |
| 1024 function getVal() { | 1025 function getVal() { |
| 1026 print("getVal"); |
| 1025 return val; | 1027 return val; |
| 1026 } | 1028 } |
| 1027 | 1029 |
| 1028 function setVal(new_val) { | 1030 function setVal(new_val) { |
| 1031 print("setVal: " + new_val); |
| 1029 val = new_val; | 1032 val = new_val; |
| 1030 } | 1033 } |
| 1031 | 1034 |
| 1032 return {getVal:getVal, setVal:setVal}; | 1035 return {getVal:getVal, setVal:setVal}; |
| 1033 } | 1036 } |
| 1034 | 1037 |
| 1035 var foreign = new ffi(23); | 1038 var foreign = new ffi(23); |
| 1036 | 1039 |
| 1037 var module = AsmModule({Math: Math}, foreign, null); | 1040 var module = AsmModule({Math: Math}, foreign, null); |
| 1038 assertValidAsm(AsmModule); | 1041 assertValidAsm(AsmModule); |
| 1039 | 1042 |
| 1040 assertEquals(103, module.caller(23, 103)); | 1043 assertEquals(103, module.caller(23, 103)); |
| 1041 } | 1044 } |
| 1042 | 1045 |
| 1046 print("TestForeignFunctions..."); |
| 1043 TestForeignFunctions(); | 1047 TestForeignFunctions(); |
| 1044 | 1048 |
| 1045 | 1049 |
| 1046 function TestForeignFunctionMultipleUse() { | 1050 function TestForeignFunctionMultipleUse() { |
| 1047 function AsmModule(stdlib, foreign, buffer) { | 1051 function AsmModule(stdlib, foreign, buffer) { |
| 1048 "use asm"; | 1052 "use asm"; |
| 1049 | 1053 |
| 1050 var getVal = foreign.getVal; | 1054 var getVal = foreign.getVal; |
| 1051 | 1055 |
| 1052 function caller(int_val, double_val) { | 1056 function caller(int_val, double_val) { |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1574 } while (0xffffffff); | 1578 } while (0xffffffff); |
| 1575 if ((val>>>0) == 2147483668) { | 1579 if ((val>>>0) == 2147483668) { |
| 1576 return 323; | 1580 return 323; |
| 1577 } | 1581 } |
| 1578 return 0; | 1582 return 0; |
| 1579 } | 1583 } |
| 1580 return {caller:main}; | 1584 return {caller:main}; |
| 1581 } | 1585 } |
| 1582 | 1586 |
| 1583 assertWasm(323, TestLoopsWithUnsigned); | 1587 assertWasm(323, TestLoopsWithUnsigned); |
| OLD | NEW |