| 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(); |
| (...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 | 1035 |
| 1036 var module = _WASMEXP_.instantiateModuleFromAsm(AsmModule.toString(), | 1036 var module = _WASMEXP_.instantiateModuleFromAsm(AsmModule.toString(), |
| 1037 foreign, null); | 1037 foreign, null); |
| 1038 | 1038 |
| 1039 module.__init__(); | 1039 module.__init__(); |
| 1040 assertEquals(103, module.caller(23, 103)); | 1040 assertEquals(103, module.caller(23, 103)); |
| 1041 } | 1041 } |
| 1042 | 1042 |
| 1043 TestForeignFunctions(); | 1043 TestForeignFunctions(); |
| 1044 | 1044 |
| 1045 |
| 1045 function TestForeignFunctionMultipleUse() { | 1046 function TestForeignFunctionMultipleUse() { |
| 1046 function AsmModule(stdlib, foreign, buffer) { | 1047 function AsmModule(stdlib, foreign, buffer) { |
| 1047 "use asm"; | 1048 "use asm"; |
| 1048 | 1049 |
| 1049 var getVal = foreign.getVal; | 1050 var getVal = foreign.getVal; |
| 1050 | 1051 |
| 1051 function caller(int_val, double_val) { | 1052 function caller(int_val, double_val) { |
| 1052 int_val = int_val|0; | 1053 int_val = int_val|0; |
| 1053 double_val = +double_val; | 1054 double_val = +double_val; |
| 1054 if ((getVal()|0) == (int_val|0)) { | 1055 if ((getVal()|0) == (int_val|0)) { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 m.storeb(20, 123); | 1213 m.storeb(20, 123); |
| 1213 m.storeb(21, 42); | 1214 m.storeb(21, 42); |
| 1214 m.storeb(22, 77); | 1215 m.storeb(22, 77); |
| 1215 assertEquals(123, m.load(20)); | 1216 assertEquals(123, m.load(20)); |
| 1216 assertEquals(42, m.load(21)); | 1217 assertEquals(42, m.load(21)); |
| 1217 assertEquals(77, m.load(22)); | 1218 assertEquals(77, m.load(22)); |
| 1218 assertEquals(123, m.iload(0)); | 1219 assertEquals(123, m.iload(0)); |
| 1219 assertEquals(42, m.iload(4)); | 1220 assertEquals(42, m.iload(4)); |
| 1220 assertEquals(77, m.iload(8)); | 1221 assertEquals(77, m.iload(8)); |
| 1221 })(); | 1222 })(); |
| 1223 |
| 1224 |
| 1225 (function TestComma() { |
| 1226 function CommaModule() { |
| 1227 "use asm"; |
| 1228 |
| 1229 function ifunc(a, b) { |
| 1230 a = +a; |
| 1231 b = b | 0; |
| 1232 return (a, b) | 0; |
| 1233 } |
| 1234 |
| 1235 function dfunc(a, b) { |
| 1236 a = a | 0; |
| 1237 b = +b; |
| 1238 return +(a, b); |
| 1239 } |
| 1240 |
| 1241 return {ifunc: ifunc, dfunc: dfunc}; |
| 1242 } |
| 1243 |
| 1244 var m = _WASMEXP_.instantiateModuleFromAsm(CommaModule.toString()); |
| 1245 assertEquals(123, m.ifunc(456.7, 123)); |
| 1246 assertEquals(123.4, m.dfunc(456, 123.4)); |
| 1247 })(); |
| OLD | NEW |