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 #include "test/unittests/test-utils.h" | 5 #include "test/unittests/test-utils.h" |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #include "test/cctest/wasm/test-signatures.h" | 9 #include "test/cctest/wasm/test-signatures.h" |
10 | 10 |
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1251 | 1251 |
1252 TEST_F(AstDecoderTest, SimpleIndirectCalls) { | 1252 TEST_F(AstDecoderTest, SimpleIndirectCalls) { |
1253 FunctionSig* sig = sigs.i_i(); | 1253 FunctionSig* sig = sigs.i_i(); |
1254 TestModuleEnv module_env; | 1254 TestModuleEnv module_env; |
1255 module = &module_env; | 1255 module = &module_env; |
1256 | 1256 |
1257 byte f0 = module_env.AddSignature(sigs.i_v()); | 1257 byte f0 = module_env.AddSignature(sigs.i_v()); |
1258 byte f1 = module_env.AddSignature(sigs.i_i()); | 1258 byte f1 = module_env.AddSignature(sigs.i_i()); |
1259 byte f2 = module_env.AddSignature(sigs.i_ii()); | 1259 byte f2 = module_env.AddSignature(sigs.i_ii()); |
1260 | 1260 |
1261 EXPECT_VERIFIES_INLINE(sig, WASM_CALL_INDIRECT0(f0, WASM_ZERO)); | 1261 EXPECT_VERIFIES_INLINE(sig, WASM_CALL_INDIRECT0(f0, 0, WASM_ZERO)); |
1262 EXPECT_VERIFIES_INLINE(sig, WASM_CALL_INDIRECT1(f1, WASM_ZERO, WASM_I8(22))); | 1262 EXPECT_VERIFIES_INLINE(sig, |
| 1263 WASM_CALL_INDIRECT1(f1, 0, WASM_ZERO, WASM_I8(22))); |
1263 EXPECT_VERIFIES_INLINE( | 1264 EXPECT_VERIFIES_INLINE( |
1264 sig, WASM_CALL_INDIRECT2(f2, WASM_ZERO, WASM_I8(32), WASM_I8(72))); | 1265 sig, WASM_CALL_INDIRECT2(f2, 0, WASM_ZERO, WASM_I8(32), WASM_I8(72))); |
1265 } | 1266 } |
1266 | 1267 |
1267 TEST_F(AstDecoderTest, IndirectCallsOutOfBounds) { | 1268 TEST_F(AstDecoderTest, IndirectCallsOutOfBounds) { |
1268 FunctionSig* sig = sigs.i_i(); | 1269 FunctionSig* sig = sigs.i_i(); |
1269 TestModuleEnv module_env; | 1270 TestModuleEnv module_env; |
1270 module = &module_env; | 1271 module = &module_env; |
1271 | 1272 |
1272 EXPECT_FAILURE_INLINE(sig, WASM_CALL_INDIRECT0(0, WASM_ZERO)); | 1273 EXPECT_FAILURE_INLINE(sig, WASM_CALL_INDIRECT0(0, 0, WASM_ZERO)); |
1273 module_env.AddSignature(sigs.i_v()); | 1274 module_env.AddSignature(sigs.i_v()); |
1274 EXPECT_VERIFIES_INLINE(sig, WASM_CALL_INDIRECT0(0, WASM_ZERO)); | 1275 EXPECT_VERIFIES_INLINE(sig, WASM_CALL_INDIRECT0(0, 0, WASM_ZERO)); |
1275 | 1276 |
1276 EXPECT_FAILURE_INLINE(sig, WASM_CALL_INDIRECT1(1, WASM_ZERO, WASM_I8(22))); | 1277 EXPECT_FAILURE_INLINE(sig, WASM_CALL_INDIRECT1(1, 0, WASM_ZERO, WASM_I8(22))); |
1277 module_env.AddSignature(sigs.i_i()); | 1278 module_env.AddSignature(sigs.i_i()); |
1278 EXPECT_VERIFIES_INLINE(sig, WASM_CALL_INDIRECT1(1, WASM_ZERO, WASM_I8(27))); | 1279 EXPECT_VERIFIES_INLINE(sig, |
| 1280 WASM_CALL_INDIRECT1(1, 0, WASM_ZERO, WASM_I8(27))); |
1279 | 1281 |
1280 EXPECT_FAILURE_INLINE(sig, WASM_CALL_INDIRECT1(2, WASM_ZERO, WASM_I8(27))); | 1282 EXPECT_FAILURE_INLINE(sig, WASM_CALL_INDIRECT1(2, 0, WASM_ZERO, WASM_I8(27))); |
1281 } | 1283 } |
1282 | 1284 |
1283 TEST_F(AstDecoderTest, IndirectCallsWithMismatchedSigs3) { | 1285 TEST_F(AstDecoderTest, IndirectCallsWithMismatchedSigs3) { |
1284 FunctionSig* sig = sigs.i_i(); | 1286 FunctionSig* sig = sigs.i_i(); |
1285 TestModuleEnv module_env; | 1287 TestModuleEnv module_env; |
1286 module = &module_env; | 1288 module = &module_env; |
1287 | 1289 |
1288 byte f0 = module_env.AddFunction(sigs.i_f()); | 1290 byte f0 = module_env.AddFunction(sigs.i_f()); |
1289 | 1291 |
1290 EXPECT_FAILURE_INLINE(sig, WASM_CALL_INDIRECT1(f0, WASM_ZERO, WASM_I8(17))); | |
1291 EXPECT_FAILURE_INLINE(sig, | 1292 EXPECT_FAILURE_INLINE(sig, |
1292 WASM_CALL_INDIRECT1(f0, WASM_ZERO, WASM_I64V_1(27))); | 1293 WASM_CALL_INDIRECT1(f0, 0, WASM_ZERO, WASM_I8(17))); |
1293 EXPECT_FAILURE_INLINE(sig, | 1294 EXPECT_FAILURE_INLINE(sig, |
1294 WASM_CALL_INDIRECT1(f0, WASM_ZERO, WASM_F64(37.2))); | 1295 WASM_CALL_INDIRECT1(f0, 0, WASM_ZERO, WASM_I64V_1(27))); |
| 1296 EXPECT_FAILURE_INLINE(sig, |
| 1297 WASM_CALL_INDIRECT1(f0, 0, WASM_ZERO, WASM_F64(37.2))); |
1295 | 1298 |
1296 EXPECT_FAILURE_INLINE(sig, WASM_CALL_INDIRECT0(f0, WASM_I8(17))); | 1299 EXPECT_FAILURE_INLINE(sig, WASM_CALL_INDIRECT0(f0, 0, WASM_I8(17))); |
1297 EXPECT_FAILURE_INLINE(sig, WASM_CALL_INDIRECT0(f0, WASM_I64V_1(27))); | 1300 EXPECT_FAILURE_INLINE(sig, WASM_CALL_INDIRECT0(f0, 0, WASM_I64V_1(27))); |
1298 EXPECT_FAILURE_INLINE(sig, WASM_CALL_INDIRECT0(f0, WASM_F64(37.2))); | 1301 EXPECT_FAILURE_INLINE(sig, WASM_CALL_INDIRECT0(f0, 0, WASM_F64(37.2))); |
1299 | 1302 |
1300 byte f1 = module_env.AddFunction(sigs.i_d()); | 1303 byte f1 = module_env.AddFunction(sigs.i_d()); |
1301 | 1304 |
1302 EXPECT_FAILURE_INLINE(sig, WASM_CALL_INDIRECT1(f1, WASM_ZERO, WASM_I8(16))); | |
1303 EXPECT_FAILURE_INLINE(sig, | 1305 EXPECT_FAILURE_INLINE(sig, |
1304 WASM_CALL_INDIRECT1(f1, WASM_ZERO, WASM_I64V_1(16))); | 1306 WASM_CALL_INDIRECT1(f1, 0, WASM_ZERO, WASM_I8(16))); |
1305 EXPECT_FAILURE_INLINE(sig, | 1307 EXPECT_FAILURE_INLINE(sig, |
1306 WASM_CALL_INDIRECT1(f1, WASM_ZERO, WASM_F32(17.6))); | 1308 WASM_CALL_INDIRECT1(f1, 0, WASM_ZERO, WASM_I64V_1(16))); |
| 1309 EXPECT_FAILURE_INLINE(sig, |
| 1310 WASM_CALL_INDIRECT1(f1, 0, WASM_ZERO, WASM_F32(17.6))); |
1307 } | 1311 } |
1308 | 1312 |
1309 TEST_F(AstDecoderTest, SimpleImportCalls) { | 1313 TEST_F(AstDecoderTest, SimpleImportCalls) { |
1310 FunctionSig* sig = sigs.i_i(); | 1314 FunctionSig* sig = sigs.i_i(); |
1311 TestModuleEnv module_env; | 1315 TestModuleEnv module_env; |
1312 module = &module_env; | 1316 module = &module_env; |
1313 | 1317 |
1314 byte f0 = module_env.AddImport(sigs.i_v()); | 1318 byte f0 = module_env.AddImport(sigs.i_v()); |
1315 byte f1 = module_env.AddImport(sigs.i_i()); | 1319 byte f1 = module_env.AddImport(sigs.i_i()); |
1316 byte f2 = module_env.AddImport(sigs.i_ii()); | 1320 byte f2 = module_env.AddImport(sigs.i_ii()); |
(...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2464 iter.next(); | 2468 iter.next(); |
2465 EXPECT_TRUE(iter.has_next()); | 2469 EXPECT_TRUE(iter.has_next()); |
2466 EXPECT_EQ(kExprI8Const, iter.current()); | 2470 EXPECT_EQ(kExprI8Const, iter.current()); |
2467 iter.next(); | 2471 iter.next(); |
2468 EXPECT_FALSE(iter.has_next()); | 2472 EXPECT_FALSE(iter.has_next()); |
2469 } | 2473 } |
2470 | 2474 |
2471 } // namespace wasm | 2475 } // namespace wasm |
2472 } // namespace internal | 2476 } // namespace internal |
2473 } // namespace v8 | 2477 } // namespace v8 |
OLD | NEW |