Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: test/cctest/wasm/test-run-wasm.cc

Issue 1716243002: [wasm] Added I64Ior to the Int64Lowering. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int64-lowering-unittest
Patch Set: rebase Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/wasm/test-run-wasm-64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "test/cctest/cctest.h" 11 #include "test/cctest/cctest.h"
12 #include "test/cctest/compiler/value-helper.h" 12 #include "test/cctest/compiler/value-helper.h"
13 #include "test/cctest/wasm/test-signatures.h" 13 #include "test/cctest/wasm/test-signatures.h"
14 #include "test/cctest/wasm/wasm-run-utils.h" 14 #include "test/cctest/wasm/wasm-run-utils.h"
15 15
16 using namespace v8::base; 16 using namespace v8::base;
17 using namespace v8::internal; 17 using namespace v8::internal;
18 using namespace v8::internal::compiler; 18 using namespace v8::internal::compiler;
19 using namespace v8::internal::wasm; 19 using namespace v8::internal::wasm;
20 20
21 #define BUILD(r, ...) \
22 do { \
23 byte code[] = {__VA_ARGS__}; \
24 r.Build(code, code + arraysize(code)); \
25 } while (false)
26
27
28 TEST(Run_WasmInt8Const) { 21 TEST(Run_WasmInt8Const) {
29 WasmRunner<int32_t> r; 22 WasmRunner<int32_t> r;
30 const byte kExpectedValue = 121; 23 const byte kExpectedValue = 121;
31 // return(kExpectedValue) 24 // return(kExpectedValue)
32 BUILD(r, WASM_I8(kExpectedValue)); 25 BUILD(r, WASM_I8(kExpectedValue));
33 CHECK_EQ(kExpectedValue, r.Call()); 26 CHECK_EQ(kExpectedValue, r.Call());
34 } 27 }
35 28
36 29
37 TEST(Run_WasmInt8Const_fallthru1) { 30 TEST(Run_WasmInt8Const_fallthru1) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 WasmRunner<int64_t> r; 101 WasmRunner<int64_t> r;
109 const int64_t kExpectedValue = (static_cast<int64_t>(*i) << 32) | cntr; 102 const int64_t kExpectedValue = (static_cast<int64_t>(*i) << 32) | cntr;
110 // return(kExpectedValue) 103 // return(kExpectedValue)
111 BUILD(r, WASM_I64(kExpectedValue)); 104 BUILD(r, WASM_I64(kExpectedValue));
112 CHECK_EQ(kExpectedValue, r.Call()); 105 CHECK_EQ(kExpectedValue, r.Call());
113 cntr++; 106 cntr++;
114 } 107 }
115 } 108 }
116 #endif 109 #endif
117 110
118 TEST(Run_WasmI32ConvertI64) {
119 FOR_INT64_INPUTS(i) {
120 WasmRunner<int32_t> r;
121 BUILD(r, WASM_I32_CONVERT_I64(WASM_I64(*i)));
122 CHECK_EQ(static_cast<int32_t>(*i), r.Call());
123 }
124 }
125
126 TEST(Run_WasmI64AndConstants) {
127 FOR_INT64_INPUTS(i) {
128 FOR_INT64_INPUTS(j) {
129 WasmRunner<int32_t> r;
130 BUILD(r, WASM_I32_CONVERT_I64(WASM_I64_AND(WASM_I64(*i), WASM_I64(*j))));
131 CHECK_EQ(static_cast<int32_t>(*i & *j), r.Call());
132 }
133 }
134 }
135 111
136 TEST(Run_WasmInt32Param0) { 112 TEST(Run_WasmInt32Param0) {
137 WasmRunner<int32_t> r(MachineType::Int32()); 113 WasmRunner<int32_t> r(MachineType::Int32());
138 // return(local[0]) 114 // return(local[0])
139 BUILD(r, WASM_GET_LOCAL(0)); 115 BUILD(r, WASM_GET_LOCAL(0));
140 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } 116 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); }
141 } 117 }
142 118
143 119
144 TEST(Run_WasmInt32Param0_fallthru) { 120 TEST(Run_WasmInt32Param0_fallthru) {
(...skipping 2284 matching lines...) Expand 10 before | Expand all | Expand 10 after
2429 WASM_F64(32.0), WASM_F64(64.0), WASM_F64(128.0), 2405 WASM_F64(32.0), WASM_F64(64.0), WASM_F64(128.0),
2430 WASM_F64(256.0), WASM_F64(1.5), WASM_F64(2.5), 2406 WASM_F64(256.0), WASM_F64(1.5), WASM_F64(2.5),
2431 WASM_F64(4.5), WASM_F64(8.5), WASM_F64(16.5), 2407 WASM_F64(4.5), WASM_F64(8.5), WASM_F64(16.5),
2432 WASM_F64(32.5), WASM_F64(64.5), WASM_F64(128.5), 2408 WASM_F64(32.5), WASM_F64(64.5), WASM_F64(128.5),
2433 WASM_F64(256.5), WASM_F64(512.5))); 2409 WASM_F64(256.5), WASM_F64(512.5)));
2434 2410
2435 float result = r.Call(); 2411 float result = r.Call();
2436 CHECK_EQ(256.5, result); 2412 CHECK_EQ(256.5, result);
2437 } 2413 }
2438 2414
2439 TEST(Run_WasmCallI64Parameter) {
2440 // Build the target function.
2441 LocalType param_types[20];
2442 for (int i = 0; i < 20; i++) param_types[i] = kAstI64;
2443 param_types[3] = kAstI32;
2444 param_types[4] = kAstI32;
2445 FunctionSig sig(1, 19, param_types);
2446 for (int i = 0; i < 19; i++) {
2447 TestingModule module;
2448 WasmFunctionCompiler t(&sig, &module);
2449 if (i == 2 || i == 3) {
2450 continue;
2451 } else {
2452 BUILD(t, WASM_GET_LOCAL(i));
2453 }
2454 uint32_t index = t.CompileAndAdd();
2455
2456 // Build the calling function.
2457 WasmRunner<int32_t> r;
2458 r.env()->module = &module;
2459 BUILD(r,
2460 WASM_I32_CONVERT_I64(WASM_CALL_FUNCTION(
2461 index, WASM_I64(0xbcd12340000000b), WASM_I64(0xbcd12340000000c),
2462 WASM_I32(0xd), WASM_I32_CONVERT_I64(WASM_I64(0xbcd12340000000e)),
2463 WASM_I64(0xbcd12340000000f), WASM_I64(0xbcd1234000000010),
2464 WASM_I64(0xbcd1234000000011), WASM_I64(0xbcd1234000000012),
2465 WASM_I64(0xbcd1234000000013), WASM_I64(0xbcd1234000000014),
2466 WASM_I64(0xbcd1234000000015), WASM_I64(0xbcd1234000000016),
2467 WASM_I64(0xbcd1234000000017), WASM_I64(0xbcd1234000000018),
2468 WASM_I64(0xbcd1234000000019), WASM_I64(0xbcd123400000001a),
2469 WASM_I64(0xbcd123400000001b), WASM_I64(0xbcd123400000001c),
2470 WASM_I64(0xbcd123400000001d))));
2471
2472 CHECK_EQ(i + 0xb, r.Call());
2473 }
2474 }
2475
2476 TEST(Run_WasmI64And) {
2477 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64());
2478 BUILD(r, WASM_I64_AND(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
2479 FOR_INT64_INPUTS(i) {
2480 FOR_INT64_INPUTS(j) { CHECK_EQ((*i) & (*j), r.Call(*i, *j)); }
2481 }
2482 }
2483
2484 TEST(Run_WasmCallVoid) { 2415 TEST(Run_WasmCallVoid) {
2485 const byte kMemOffset = 8; 2416 const byte kMemOffset = 8;
2486 const int32_t kElemNum = kMemOffset / sizeof(int32_t); 2417 const int32_t kElemNum = kMemOffset / sizeof(int32_t);
2487 const int32_t kExpected = -414444; 2418 const int32_t kExpected = -414444;
2488 // Build the target function. 2419 // Build the target function.
2489 TestSignatures sigs; 2420 TestSignatures sigs;
2490 TestingModule module; 2421 TestingModule module;
2491 module.AddMemory(16); 2422 module.AddMemory(16);
2492 module.RandomizeMemory(); 2423 module.RandomizeMemory();
2493 WasmFunctionCompiler t(sigs.v_v(), &module); 2424 WasmFunctionCompiler t(sigs.v_v(), &module);
(...skipping 26 matching lines...) Expand all
2520 2451
2521 FOR_INT32_INPUTS(i) { 2452 FOR_INT32_INPUTS(i) {
2522 FOR_INT32_INPUTS(j) { 2453 FOR_INT32_INPUTS(j) {
2523 int32_t expected = static_cast<int32_t>(static_cast<uint32_t>(*i) + 2454 int32_t expected = static_cast<int32_t>(static_cast<uint32_t>(*i) +
2524 static_cast<uint32_t>(*j)); 2455 static_cast<uint32_t>(*j));
2525 CHECK_EQ(expected, r.Call(*i, *j)); 2456 CHECK_EQ(expected, r.Call(*i, *j));
2526 } 2457 }
2527 } 2458 }
2528 } 2459 }
2529 2460
2530
2531 #if WASM_64 2461 #if WASM_64
2532 TEST(Run_WasmCall_Int64Sub) { 2462 TEST(Run_WasmCall_Int64Sub) {
2533 // Build the target function. 2463 // Build the target function.
2534 TestSignatures sigs; 2464 TestSignatures sigs;
2535 TestingModule module; 2465 TestingModule module;
2536 WasmFunctionCompiler t(sigs.l_ll(), &module); 2466 WasmFunctionCompiler t(sigs.l_ll(), &module);
2537 BUILD(t, WASM_I64_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 2467 BUILD(t, WASM_I64_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
2538 uint32_t index = t.CompileAndAdd(); 2468 uint32_t index = t.CompileAndAdd();
2539 2469
2540 // Build the caller function. 2470 // Build the caller function.
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
3451 3381
3452 #if WASM_64 3382 #if WASM_64
3453 TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kAstI64); } 3383 TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kAstI64); }
3454 #endif 3384 #endif
3455 3385
3456 3386
3457 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); } 3387 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); }
3458 3388
3459 3389
3460 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); } 3390 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); }
OLDNEW
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/wasm/test-run-wasm-64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698