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

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

Issue 2487673004: [wasm] Fix -Wsign-compare warnings. (Closed)
Patch Set: Created 4 years, 1 month 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
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 #include "src/utils.h" 10 #include "src/utils.h"
(...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } 1200 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); }
1201 } 1201 }
1202 1202
1203 WASM_EXEC_TEST(Block_empty_brif1) { 1203 WASM_EXEC_TEST(Block_empty_brif1) {
1204 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 1204 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
1205 BUILD(r, WASM_BLOCK(WASM_BR_IF(0, WASM_ZERO)), WASM_GET_LOCAL(0)); 1205 BUILD(r, WASM_BLOCK(WASM_BR_IF(0, WASM_ZERO)), WASM_GET_LOCAL(0));
1206 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } 1206 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); }
1207 } 1207 }
1208 1208
1209 WASM_EXEC_TEST(Block_empty_brif2) { 1209 WASM_EXEC_TEST(Block_empty_brif2) {
1210 WasmRunner<uint32_t> r(execution_mode, MachineType::Uint32(), 1210 WasmRunner<int32_t> r(execution_mode, MachineType::Uint32(),
ahaas 2016/11/10 09:03:39 I think it would be better to not change the templ
ulan 2016/11/10 12:23:43 Done.
1211 MachineType::Uint32()); 1211 MachineType::Uint32());
1212 BUILD(r, WASM_BLOCK(WASM_BR_IF(0, WASM_GET_LOCAL(1))), WASM_GET_LOCAL(0)); 1212 BUILD(r, WASM_BLOCK(WASM_BR_IF(0, WASM_GET_LOCAL(1))), WASM_GET_LOCAL(0));
1213 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i, *i + 1)); } 1213 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i, *i + 1)); }
1214 } 1214 }
1215 1215
1216 WASM_EXEC_TEST(Block_i) { 1216 WASM_EXEC_TEST(Block_i) {
1217 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 1217 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
1218 BUILD(r, WASM_BLOCK_I(WASM_GET_LOCAL(0))); 1218 BUILD(r, WASM_BLOCK_I(WASM_GET_LOCAL(0)));
1219 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } 1219 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); }
1220 } 1220 }
1221 1221
1222 WASM_EXEC_TEST(Block_f) { 1222 WASM_EXEC_TEST(Block_f) {
1223 WasmRunner<float> r(execution_mode, MachineType::Float32()); 1223 WasmRunner<float> r(execution_mode, MachineType::Float32());
1224 BUILD(r, WASM_BLOCK_F(WASM_GET_LOCAL(0))); 1224 BUILD(r, WASM_BLOCK_F(WASM_GET_LOCAL(0)));
1225 FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(*i, r.Call(*i)); } 1225 FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(*i, r.Call(*i)); }
1226 } 1226 }
1227 1227
1228 WASM_EXEC_TEST(Block_d) { 1228 WASM_EXEC_TEST(Block_d) {
1229 WasmRunner<double> r(execution_mode, MachineType::Float64()); 1229 WasmRunner<double> r(execution_mode, MachineType::Float64());
1230 BUILD(r, WASM_BLOCK_D(WASM_GET_LOCAL(0))); 1230 BUILD(r, WASM_BLOCK_D(WASM_GET_LOCAL(0)));
1231 FOR_FLOAT64_INPUTS(i) { CHECK_FLOAT_EQ(*i, r.Call(*i)); } 1231 FOR_FLOAT64_INPUTS(i) { CHECK_FLOAT_EQ(*i, r.Call(*i)); }
1232 } 1232 }
1233 1233
1234 WASM_EXEC_TEST(Block_br2) { 1234 WASM_EXEC_TEST(Block_br2) {
1235 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 1235 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
1236 BUILD(r, WASM_BLOCK_I(WASM_BRV(0, WASM_GET_LOCAL(0)))); 1236 BUILD(r, WASM_BLOCK_I(WASM_BRV(0, WASM_GET_LOCAL(0))));
1237 FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } 1237 FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, static_cast<uint32_t>(r.Call(*i))); }
1238 } 1238 }
1239 1239
1240 WASM_EXEC_TEST(Block_If_P) { 1240 WASM_EXEC_TEST(Block_If_P) {
1241 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 1241 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
1242 // block { if (p0) break 51; 52; } 1242 // block { if (p0) break 51; 52; }
1243 BUILD(r, WASM_BLOCK_I( // -- 1243 BUILD(r, WASM_BLOCK_I( // --
1244 WASM_IF(WASM_GET_LOCAL(0), // -- 1244 WASM_IF(WASM_GET_LOCAL(0), // --
1245 WASM_BRV(1, WASM_I8(51))), // -- 1245 WASM_BRV(1, WASM_I8(51))), // --
1246 WASM_I8(52))); // -- 1246 WASM_I8(52))); // --
1247 FOR_INT32_INPUTS(i) { 1247 FOR_INT32_INPUTS(i) {
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1589 for (int index = 0; index < kMemSize + 5; ++index) { 1589 for (int index = 0; index < kMemSize + 5; ++index) {
1590 TestingModule module(execution_mode); 1590 TestingModule module(execution_mode);
1591 module.AddMemoryElems<byte>(kMemSize); 1591 module.AddMemoryElems<byte>(kMemSize);
1592 1592
1593 WasmRunner<int32_t> r(&module); 1593 WasmRunner<int32_t> r(&module);
1594 module.RandomizeMemory(); 1594 module.RandomizeMemory();
1595 1595
1596 BUILD(r, 1596 BUILD(r,
1597 WASM_LOAD_MEM_OFFSET(MachineType::Int32(), offset, WASM_I8(index))); 1597 WASM_LOAD_MEM_OFFSET(MachineType::Int32(), offset, WASM_I8(index)));
1598 1598
1599 if ((offset + index) <= (kMemSize - sizeof(int32_t))) { 1599 if ((offset + index) <= static_cast<int>((kMemSize - sizeof(int32_t)))) {
1600 CHECK_EQ(module.raw_val_at<int32_t>(offset + index), r.Call()); 1600 CHECK_EQ(module.raw_val_at<int32_t>(offset + index), r.Call());
1601 } else { 1601 } else {
1602 CHECK_TRAP(r.Call()); 1602 CHECK_TRAP(r.Call());
1603 } 1603 }
1604 } 1604 }
1605 } 1605 }
1606 } 1606 }
1607 1607
1608 WASM_EXEC_TEST(LoadMemI32_const_oob) { 1608 WASM_EXEC_TEST(LoadMemI32_const_oob) {
1609 const int kMemSize = 24; 1609 const int kMemSize = 24;
1610 for (int offset = 0; offset < kMemSize + 5; offset += 4) { 1610 for (int offset = 0; offset < kMemSize + 5; offset += 4) {
1611 for (int index = 0; index < kMemSize + 5; index += 4) { 1611 for (int index = 0; index < kMemSize + 5; index += 4) {
1612 TestingModule module(execution_mode); 1612 TestingModule module(execution_mode);
1613 module.AddMemoryElems<byte>(kMemSize); 1613 module.AddMemoryElems<byte>(kMemSize);
1614 1614
1615 WasmRunner<int32_t> r(&module); 1615 WasmRunner<int32_t> r(&module);
1616 module.RandomizeMemory(); 1616 module.RandomizeMemory();
1617 1617
1618 BUILD(r, 1618 BUILD(r,
1619 WASM_LOAD_MEM_OFFSET(MachineType::Int32(), offset, WASM_I8(index))); 1619 WASM_LOAD_MEM_OFFSET(MachineType::Int32(), offset, WASM_I8(index)));
1620 1620
1621 if ((offset + index) <= (kMemSize - sizeof(int32_t))) { 1621 if ((offset + index) <= static_cast<int>((kMemSize - sizeof(int32_t)))) {
1622 CHECK_EQ(module.raw_val_at<int32_t>(offset + index), r.Call()); 1622 CHECK_EQ(module.raw_val_at<int32_t>(offset + index), r.Call());
1623 } else { 1623 } else {
1624 CHECK_TRAP(r.Call()); 1624 CHECK_TRAP(r.Call());
1625 } 1625 }
1626 } 1626 }
1627 } 1627 }
1628 } 1628 }
1629 1629
1630 WASM_EXEC_TEST(StoreMemI32_alignment) { 1630 WASM_EXEC_TEST(StoreMemI32_alignment) {
1631 TestingModule module(execution_mode); 1631 TestingModule module(execution_mode);
(...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after
2985 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_DROP, 2985 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_DROP,
2986 WASM_ZERO); 2986 WASM_ZERO);
2987 const int32_t kMin = std::numeric_limits<int32_t>::min(); 2987 const int32_t kMin = std::numeric_limits<int32_t>::min();
2988 CHECK_EQ(0, r.Call(133, 100)); 2988 CHECK_EQ(0, r.Call(133, 100));
2989 CHECK_EQ(0, r.Call(kMin, -1)); 2989 CHECK_EQ(0, r.Call(kMin, -1));
2990 CHECK_EQ(0, r.Call(0, 1)); 2990 CHECK_EQ(0, r.Call(0, 1));
2991 CHECK_TRAP(r.Call(100, 0)); 2991 CHECK_TRAP(r.Call(100, 0));
2992 CHECK_TRAP(r.Call(-1001, 0)); 2992 CHECK_TRAP(r.Call(-1001, 0));
2993 CHECK_TRAP(r.Call(kMin, 0)); 2993 CHECK_TRAP(r.Call(kMin, 0));
2994 } 2994 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698