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 <stdint.h> | 5 #include <stdint.h> |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "src/wasm/wasm-macro-gen.h" | 9 #include "src/wasm/wasm-macro-gen.h" |
10 | 10 |
(...skipping 2455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2466 WASM_F64(32.0), WASM_F64(64.0), WASM_F64(128.0), | 2466 WASM_F64(32.0), WASM_F64(64.0), WASM_F64(128.0), |
2467 WASM_F64(256.0), WASM_F64(1.5), WASM_F64(2.5), | 2467 WASM_F64(256.0), WASM_F64(1.5), WASM_F64(2.5), |
2468 WASM_F64(4.5), WASM_F64(8.5), WASM_F64(16.5), | 2468 WASM_F64(4.5), WASM_F64(8.5), WASM_F64(16.5), |
2469 WASM_F64(32.5), WASM_F64(64.5), WASM_F64(128.5), | 2469 WASM_F64(32.5), WASM_F64(64.5), WASM_F64(128.5), |
2470 WASM_F64(256.5), WASM_F64(512.5))); | 2470 WASM_F64(256.5), WASM_F64(512.5))); |
2471 | 2471 |
2472 float result = r.Call(); | 2472 float result = r.Call(); |
2473 CHECK_EQ(256.5, result); | 2473 CHECK_EQ(256.5, result); |
2474 } | 2474 } |
2475 | 2475 |
| 2476 TEST(Run_WasmCallI64Parameter) { |
| 2477 // Build the target function. |
| 2478 LocalType param_types[20]; |
| 2479 for (int i = 0; i < 20; i++) param_types[i] = kAstI64; |
| 2480 param_types[3] = kAstI32; |
| 2481 param_types[4] = kAstI32; |
| 2482 FunctionSig sig(1, 19, param_types); |
| 2483 for (int i = 0; i < 19; i++) { |
| 2484 TestingModule module; |
| 2485 WasmFunctionCompiler t(&sig); |
| 2486 if (i == 2 || i == 3) { |
| 2487 continue; |
| 2488 } else { |
| 2489 BUILD(t, WASM_GET_LOCAL(i)); |
| 2490 } |
| 2491 uint32_t index = t.CompileAndAdd(&module); |
| 2492 |
| 2493 // Build the calling function. |
| 2494 WasmRunner<int32_t> r; |
| 2495 r.env()->module = &module; |
| 2496 BUILD(r, |
| 2497 WASM_I32_CONVERT_I64(WASM_CALL_FUNCTION( |
| 2498 index, WASM_I64(0xbcd12340000000b), WASM_I64(0xbcd12340000000c), |
| 2499 WASM_I32(0xd), WASM_I32_CONVERT_I64(WASM_I64(0xbcd12340000000e)), |
| 2500 WASM_I64(0xbcd12340000000f), WASM_I64(0xbcd1234000000010), |
| 2501 WASM_I64(0xbcd1234000000011), WASM_I64(0xbcd1234000000012), |
| 2502 WASM_I64(0xbcd1234000000013), WASM_I64(0xbcd1234000000014), |
| 2503 WASM_I64(0xbcd1234000000015), WASM_I64(0xbcd1234000000016), |
| 2504 WASM_I64(0xbcd1234000000017), WASM_I64(0xbcd1234000000018), |
| 2505 WASM_I64(0xbcd1234000000019), WASM_I64(0xbcd123400000001a), |
| 2506 WASM_I64(0xbcd123400000001b), WASM_I64(0xbcd123400000001c), |
| 2507 WASM_I64(0xbcd123400000001d)))); |
| 2508 |
| 2509 CHECK_EQ(i + 0xb, r.Call()); |
| 2510 } |
| 2511 } |
| 2512 |
| 2513 TEST(Run_WasmI64And) { |
| 2514 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); |
| 2515 BUILD(r, WASM_I64_AND(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
| 2516 FOR_INT64_INPUTS(i) { |
| 2517 FOR_INT64_INPUTS(j) { CHECK_EQ((*i) & (*j), r.Call(*i, *j)); } |
| 2518 } |
| 2519 } |
2476 | 2520 |
2477 TEST(Run_WasmCallVoid) { | 2521 TEST(Run_WasmCallVoid) { |
2478 const byte kMemOffset = 8; | 2522 const byte kMemOffset = 8; |
2479 const int32_t kElemNum = kMemOffset / sizeof(int32_t); | 2523 const int32_t kElemNum = kMemOffset / sizeof(int32_t); |
2480 const int32_t kExpected = -414444; | 2524 const int32_t kExpected = -414444; |
2481 // Build the target function. | 2525 // Build the target function. |
2482 TestSignatures sigs; | 2526 TestSignatures sigs; |
2483 TestingModule module; | 2527 TestingModule module; |
2484 module.AddMemory(16); | 2528 module.AddMemory(16); |
2485 module.RandomizeMemory(); | 2529 module.RandomizeMemory(); |
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3435 | 3479 |
3436 #if WASM_64 | 3480 #if WASM_64 |
3437 TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kAstI64); } | 3481 TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kAstI64); } |
3438 #endif | 3482 #endif |
3439 | 3483 |
3440 | 3484 |
3441 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); } | 3485 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); } |
3442 | 3486 |
3443 | 3487 |
3444 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); } | 3488 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); } |
OLD | NEW |