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

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

Issue 2042773002: [wasm] Move 64-bit call tests into test-run-wasm-64.cc so they also run on 32-bit platforms. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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 | « no previous file | 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/base/platform/elapsed-timer.h" 9 #include "src/base/platform/elapsed-timer.h"
10 10
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 CHECK_EQ(i == 0 ? kWritten : 77777777, memory[1]); 1492 CHECK_EQ(i == 0 ? kWritten : 77777777, memory[1]);
1493 CHECK_EQ(i == 1 ? kWritten : 88888888, memory[2]); 1493 CHECK_EQ(i == 1 ? kWritten : 88888888, memory[2]);
1494 CHECK_EQ(i == 2 ? kWritten : 99999999, memory[3]); 1494 CHECK_EQ(i == 2 ? kWritten : 99999999, memory[3]);
1495 } 1495 }
1496 } 1496 }
1497 1497
1498 WASM_EXEC_TEST(StoreMem_offset_oob) { 1498 WASM_EXEC_TEST(StoreMem_offset_oob) {
1499 TestingModule module(execution_mode); 1499 TestingModule module(execution_mode);
1500 byte* memory = module.AddMemoryElems<byte>(32); 1500 byte* memory = module.AddMemoryElems<byte>(32);
1501 1501
1502 #if WASM_64 1502 // 64-bit cases are handled in test-run-wasm-64.cc
1503 static const MachineType machineTypes[] = {
1504 MachineType::Int8(), MachineType::Uint8(), MachineType::Int16(),
1505 MachineType::Uint16(), MachineType::Int32(), MachineType::Uint32(),
1506 MachineType::Int64(), MachineType::Uint64(), MachineType::Float32(),
1507 MachineType::Float64()};
1508 #else
1509 static const MachineType machineTypes[] = { 1503 static const MachineType machineTypes[] = {
1510 MachineType::Int8(), MachineType::Uint8(), MachineType::Int16(), 1504 MachineType::Int8(), MachineType::Uint8(), MachineType::Int16(),
1511 MachineType::Uint16(), MachineType::Int32(), MachineType::Uint32(), 1505 MachineType::Uint16(), MachineType::Int32(), MachineType::Uint32(),
1512 MachineType::Float32(), MachineType::Float64()}; 1506 MachineType::Float32(), MachineType::Float64()};
1513 #endif
1514 1507
1515 for (size_t m = 0; m < arraysize(machineTypes); m++) { 1508 for (size_t m = 0; m < arraysize(machineTypes); m++) {
1516 module.RandomizeMemory(1119 + static_cast<int>(m)); 1509 module.RandomizeMemory(1119 + static_cast<int>(m));
1517 WasmRunner<int32_t> r(&module, MachineType::Uint32()); 1510 WasmRunner<int32_t> r(&module, MachineType::Uint32());
1518 1511
1519 BUILD(r, WASM_STORE_MEM_OFFSET(machineTypes[m], 8, WASM_GET_LOCAL(0), 1512 BUILD(r, WASM_STORE_MEM_OFFSET(machineTypes[m], 8, WASM_GET_LOCAL(0),
1520 WASM_LOAD_MEM(machineTypes[m], WASM_ZERO)), 1513 WASM_LOAD_MEM(machineTypes[m], WASM_ZERO)),
1521 WASM_ZERO); 1514 WASM_ZERO);
1522 1515
1523 byte memsize = WasmOpcodes::MemSize(machineTypes[m]); 1516 byte memsize = WasmOpcodes::MemSize(machineTypes[m]);
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
2138 do { \ 2131 do { \
2139 byte __buf[] = {__VA_ARGS__}; \ 2132 byte __buf[] = {__VA_ARGS__}; \
2140 for (size_t i = 0; i < sizeof(__buf); i++) vec.push_back(__buf[i]); \ 2133 for (size_t i = 0; i < sizeof(__buf); i++) vec.push_back(__buf[i]); \
2141 } while (false) 2134 } while (false)
2142 2135
2143 static void Run_WasmMixedCall_N(WasmExecutionMode execution_mode, int start) { 2136 static void Run_WasmMixedCall_N(WasmExecutionMode execution_mode, int start) {
2144 const int kExpected = 6333; 2137 const int kExpected = 6333;
2145 const int kElemSize = 8; 2138 const int kElemSize = 8;
2146 TestSignatures sigs; 2139 TestSignatures sigs;
2147 2140
2148 #if WASM_64 2141 // 64-bit cases handled in test-run-wasm-64.cc.
2149 static MachineType mixed[] = {
2150 MachineType::Int32(), MachineType::Float32(), MachineType::Int64(),
2151 MachineType::Float64(), MachineType::Float32(), MachineType::Int64(),
2152 MachineType::Int32(), MachineType::Float64(), MachineType::Float32(),
2153 MachineType::Float64(), MachineType::Int32(), MachineType::Int64(),
2154 MachineType::Int32(), MachineType::Int32()};
2155 #else
2156 static MachineType mixed[] = { 2142 static MachineType mixed[] = {
2157 MachineType::Int32(), MachineType::Float32(), MachineType::Float64(), 2143 MachineType::Int32(), MachineType::Float32(), MachineType::Float64(),
2158 MachineType::Float32(), MachineType::Int32(), MachineType::Float64(), 2144 MachineType::Float32(), MachineType::Int32(), MachineType::Float64(),
2159 MachineType::Float32(), MachineType::Float64(), MachineType::Int32(), 2145 MachineType::Float32(), MachineType::Float64(), MachineType::Int32(),
2160 MachineType::Int32(), MachineType::Int32()}; 2146 MachineType::Int32(), MachineType::Int32()};
2161 #endif
2162 2147
2163 int num_params = static_cast<int>(arraysize(mixed)) - start; 2148 int num_params = static_cast<int>(arraysize(mixed)) - start;
2164 for (int which = 0; which < num_params; which++) { 2149 for (int which = 0; which < num_params; which++) {
2165 v8::base::AccountingAllocator allocator; 2150 v8::base::AccountingAllocator allocator;
2166 Zone zone(&allocator); 2151 Zone zone(&allocator);
2167 TestingModule module(execution_mode); 2152 TestingModule module(execution_mode);
2168 module.AddMemory(1024); 2153 module.AddMemory(1024);
2169 MachineType* memtypes = &mixed[start]; 2154 MachineType* memtypes = &mixed[start];
2170 MachineType result = memtypes[which]; 2155 MachineType result = memtypes[which];
2171 2156
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
2782 WASM_EXEC_TEST(F32CopySign) { 2767 WASM_EXEC_TEST(F32CopySign) {
2783 WasmRunner<float> r(execution_mode, MachineType::Float32(), 2768 WasmRunner<float> r(execution_mode, MachineType::Float32(),
2784 MachineType::Float32()); 2769 MachineType::Float32());
2785 BUILD(r, WASM_F32_COPYSIGN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 2770 BUILD(r, WASM_F32_COPYSIGN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
2786 2771
2787 FOR_FLOAT32_INPUTS(i) { 2772 FOR_FLOAT32_INPUTS(i) {
2788 FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(copysignf(*i, *j), r.Call(*i, *j)); } 2773 FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(copysignf(*i, *j), r.Call(*i, *j)); }
2789 } 2774 }
2790 } 2775 }
2791 2776
2792 void CompileCallIndirectMany(LocalType param) { 2777 static void CompileCallIndirectMany(LocalType param) {
2793 // Make sure we don't run out of registers when compiling indirect calls 2778 // Make sure we don't run out of registers when compiling indirect calls
2794 // with many many parameters. 2779 // with many many parameters.
2795 TestSignatures sigs; 2780 TestSignatures sigs;
2796 for (byte num_params = 0; num_params < 40; num_params++) { 2781 for (byte num_params = 0; num_params < 40; num_params++) {
2797 v8::base::AccountingAllocator allocator; 2782 v8::base::AccountingAllocator allocator;
2798 Zone zone(&allocator); 2783 Zone zone(&allocator);
2799 HandleScope scope(CcTest::InitIsolateOnce()); 2784 HandleScope scope(CcTest::InitIsolateOnce());
2800 TestingModule module(kExecuteCompiled); 2785 TestingModule module(kExecuteCompiled);
2801 FunctionSig* sig = sigs.many(&zone, kAstStmt, param, num_params); 2786 FunctionSig* sig = sigs.many(&zone, kAstStmt, param, num_params);
2802 2787
(...skipping 10 matching lines...) Expand all
2813 } 2798 }
2814 ADD_CODE(code, kExprCallIndirect, static_cast<byte>(num_params), 1); 2799 ADD_CODE(code, kExprCallIndirect, static_cast<byte>(num_params), 1);
2815 2800
2816 t.Build(&code[0], &code[0] + code.size()); 2801 t.Build(&code[0], &code[0] + code.size());
2817 t.Compile(); 2802 t.Compile();
2818 } 2803 }
2819 } 2804 }
2820 2805
2821 TEST(Compile_Wasm_CallIndirect_Many_i32) { CompileCallIndirectMany(kAstI32); } 2806 TEST(Compile_Wasm_CallIndirect_Many_i32) { CompileCallIndirectMany(kAstI32); }
2822 2807
2823 #if WASM_64
2824 TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kAstI64); }
2825 #endif
2826
2827 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); } 2808 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); }
2828 2809
2829 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); } 2810 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); }
2830 2811
2831 WASM_EXEC_TEST(Int32RemS_dead) { 2812 WASM_EXEC_TEST(Int32RemS_dead) {
2832 WasmRunner<int32_t> r(execution_mode, MachineType::Int32(), 2813 WasmRunner<int32_t> r(execution_mode, MachineType::Int32(),
2833 MachineType::Int32()); 2814 MachineType::Int32());
2834 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_ZERO); 2815 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_ZERO);
2835 const int32_t kMin = std::numeric_limits<int32_t>::min(); 2816 const int32_t kMin = std::numeric_limits<int32_t>::min();
2836 CHECK_EQ(0, r.Call(133, 100)); 2817 CHECK_EQ(0, r.Call(133, 100));
2837 CHECK_EQ(0, r.Call(kMin, -1)); 2818 CHECK_EQ(0, r.Call(kMin, -1));
2838 CHECK_EQ(0, r.Call(0, 1)); 2819 CHECK_EQ(0, r.Call(0, 1));
2839 CHECK_TRAP(r.Call(100, 0)); 2820 CHECK_TRAP(r.Call(100, 0));
2840 CHECK_TRAP(r.Call(-1001, 0)); 2821 CHECK_TRAP(r.Call(-1001, 0));
2841 CHECK_TRAP(r.Call(kMin, 0)); 2822 CHECK_TRAP(r.Call(kMin, 0));
2842 } 2823 }
OLDNEW
« no previous file with comments | « no previous file | test/cctest/wasm/test-run-wasm-64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698