OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include <stdint.h> |
| 6 #include <stdlib.h> |
| 7 #include <string.h> |
| 8 |
| 9 #include "src/wasm/wasm-macro-gen.h" |
| 10 |
| 11 #include "test/cctest/cctest.h" |
| 12 #include "test/cctest/compiler/value-helper.h" |
| 13 #include "test/cctest/wasm/wasm-run-utils.h" |
| 14 |
| 15 // using namespace v8::base; |
| 16 // using namespace v8::internal; |
| 17 // using namespace v8::internal::compiler; |
| 18 // using namespace v8::internal::wasm; |
| 19 |
| 20 // todo(ahaas): I added a list of missing instructions here to make merging |
| 21 // easier when I do them one by one. |
| 22 // kExprI64Add: |
| 23 // kExprI64Sub: |
| 24 // kExprI64Mul: |
| 25 // kExprI64DivS: |
| 26 // kExprI64DivU: |
| 27 // kExprI64RemS: |
| 28 // kExprI64RemU: |
| 29 // kExprI64And: |
| 30 TEST(Run_WasmI64And) { |
| 31 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); |
| 32 BUILD(r, WASM_I64_AND(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
| 33 FOR_INT64_INPUTS(i) { |
| 34 FOR_INT64_INPUTS(j) { CHECK_EQ((*i) & (*j), r.Call(*i, *j)); } |
| 35 } |
| 36 } |
| 37 // kExprI64Ior: |
| 38 TEST(Run_WasmI64Ior) { |
| 39 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); |
| 40 BUILD(r, WASM_I64_IOR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
| 41 FOR_INT64_INPUTS(i) { |
| 42 FOR_INT64_INPUTS(j) { CHECK_EQ((*i) | (*j), r.Call(*i, *j)); } |
| 43 } |
| 44 } |
| 45 // kExprI64Xor: |
| 46 // kExprI64Shl: |
| 47 // kExprI64ShrU: |
| 48 // kExprI64ShrS: |
| 49 // kExprI64Eq: |
| 50 // kExprI64Ne: |
| 51 // kExprI64LtS: |
| 52 // kExprI64LeS: |
| 53 // kExprI64LtU: |
| 54 // kExprI64LeU: |
| 55 // kExprI64GtS: |
| 56 // kExprI64GeS: |
| 57 // kExprI64GtU: |
| 58 // kExprI64GeU: |
| 59 |
| 60 // kExprI32ConvertI64: |
| 61 TEST(Run_WasmI32ConvertI64) { |
| 62 FOR_INT64_INPUTS(i) { |
| 63 WasmRunner<int32_t> r; |
| 64 BUILD(r, WASM_I32_CONVERT_I64(WASM_I64(*i))); |
| 65 CHECK_EQ(static_cast<int32_t>(*i), r.Call()); |
| 66 } |
| 67 } |
| 68 // kExprI64SConvertI32: |
| 69 // kExprI64UConvertI32: |
| 70 |
| 71 // kExprF64ReinterpretI64: |
| 72 // kExprI64ReinterpretF64: |
| 73 |
| 74 // kExprI64Clz: |
| 75 // kExprI64Ctz: |
| 76 // kExprI64Popcnt: |
| 77 |
| 78 // kExprF32SConvertI64: |
| 79 // kExprF32UConvertI64: |
| 80 // kExprF64SConvertI64: |
| 81 // kExprF64UConvertI64: |
| 82 // kExprI64SConvertF32: |
| 83 // kExprI64SConvertF64: |
| 84 // kExprI64UConvertF32: |
| 85 // kExprI64UConvertF64: |
| 86 |
| 87 TEST(Run_WasmCallI64Parameter) { |
| 88 // Build the target function. |
| 89 LocalType param_types[20]; |
| 90 for (int i = 0; i < 20; i++) param_types[i] = kAstI64; |
| 91 param_types[3] = kAstI32; |
| 92 param_types[4] = kAstI32; |
| 93 FunctionSig sig(1, 19, param_types); |
| 94 for (int i = 0; i < 19; i++) { |
| 95 TestingModule module; |
| 96 WasmFunctionCompiler t(&sig, &module); |
| 97 if (i == 2 || i == 3) { |
| 98 continue; |
| 99 } else { |
| 100 BUILD(t, WASM_GET_LOCAL(i)); |
| 101 } |
| 102 uint32_t index = t.CompileAndAdd(); |
| 103 |
| 104 // Build the calling function. |
| 105 WasmRunner<int32_t> r; |
| 106 r.env()->module = &module; |
| 107 BUILD(r, |
| 108 WASM_I32_CONVERT_I64(WASM_CALL_FUNCTION( |
| 109 index, WASM_I64(0xbcd12340000000b), WASM_I64(0xbcd12340000000c), |
| 110 WASM_I32(0xd), WASM_I32_CONVERT_I64(WASM_I64(0xbcd12340000000e)), |
| 111 WASM_I64(0xbcd12340000000f), WASM_I64(0xbcd1234000000010), |
| 112 WASM_I64(0xbcd1234000000011), WASM_I64(0xbcd1234000000012), |
| 113 WASM_I64(0xbcd1234000000013), WASM_I64(0xbcd1234000000014), |
| 114 WASM_I64(0xbcd1234000000015), WASM_I64(0xbcd1234000000016), |
| 115 WASM_I64(0xbcd1234000000017), WASM_I64(0xbcd1234000000018), |
| 116 WASM_I64(0xbcd1234000000019), WASM_I64(0xbcd123400000001a), |
| 117 WASM_I64(0xbcd123400000001b), WASM_I64(0xbcd123400000001c), |
| 118 WASM_I64(0xbcd123400000001d)))); |
| 119 |
| 120 CHECK_EQ(i + 0xb, r.Call()); |
| 121 } |
| 122 } |
OLD | NEW |