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

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

Issue 1763433002: [wasm] Rework encoding of local declarations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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 | « src/wasm/wasm-opcodes.h ('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
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 BUILD(r, B2(WASM_SELECT(WASM_SET_LOCAL(0, WASM_I8(0)), 966 BUILD(r, B2(WASM_SELECT(WASM_SET_LOCAL(0, WASM_I8(0)),
967 WASM_SET_LOCAL(0, WASM_I8(1)), 967 WASM_SET_LOCAL(0, WASM_I8(1)),
968 WASM_SET_LOCAL(0, WASM_I8(2))), 968 WASM_SET_LOCAL(0, WASM_I8(2))),
969 WASM_GET_LOCAL(0))); 969 WASM_GET_LOCAL(0)));
970 FOR_INT32_INPUTS(i) { CHECK_EQ(2, r.Call(*i)); } 970 FOR_INT32_INPUTS(i) { CHECK_EQ(2, r.Call(*i)); }
971 } 971 }
972 972
973 973
974 TEST(Run_Wasm_Select_strict2) { 974 TEST(Run_Wasm_Select_strict2) {
975 WasmRunner<int32_t> r(MachineType::Int32()); 975 WasmRunner<int32_t> r(MachineType::Int32());
976 r.env()->AddLocals(kAstI32, 2); 976 r.AllocateLocal(kAstI32);
977 r.AllocateLocal(kAstI32);
977 // select(b=5, c=6, a) 978 // select(b=5, c=6, a)
978 BUILD(r, WASM_SELECT(WASM_SET_LOCAL(1, WASM_I8(5)), 979 BUILD(r, WASM_SELECT(WASM_SET_LOCAL(1, WASM_I8(5)),
979 WASM_SET_LOCAL(2, WASM_I8(6)), WASM_GET_LOCAL(0))); 980 WASM_SET_LOCAL(2, WASM_I8(6)), WASM_GET_LOCAL(0)));
980 FOR_INT32_INPUTS(i) { 981 FOR_INT32_INPUTS(i) {
981 int32_t expected = *i ? 5 : 6; 982 int32_t expected = *i ? 5 : 6;
982 CHECK_EQ(expected, r.Call(*i)); 983 CHECK_EQ(expected, r.Call(*i));
983 } 984 }
984 } 985 }
985 986
986 TEST(Run_Wasm_Select_strict3) { 987 TEST(Run_Wasm_Select_strict3) {
987 WasmRunner<int32_t> r(MachineType::Int32()); 988 WasmRunner<int32_t> r(MachineType::Int32());
988 r.env()->AddLocals(kAstI32, 2); 989 r.AllocateLocal(kAstI32);
990 r.AllocateLocal(kAstI32);
989 // select(b=5, c=6, a=b) 991 // select(b=5, c=6, a=b)
990 BUILD(r, WASM_SELECT(WASM_SET_LOCAL(1, WASM_I8(5)), 992 BUILD(r, WASM_SELECT(WASM_SET_LOCAL(1, WASM_I8(5)),
991 WASM_SET_LOCAL(2, WASM_I8(6)), 993 WASM_SET_LOCAL(2, WASM_I8(6)),
992 WASM_SET_LOCAL(0, WASM_GET_LOCAL(1)))); 994 WASM_SET_LOCAL(0, WASM_GET_LOCAL(1))));
993 FOR_INT32_INPUTS(i) { 995 FOR_INT32_INPUTS(i) {
994 int32_t expected = 5; 996 int32_t expected = 5;
995 CHECK_EQ(expected, r.Call(*i)); 997 CHECK_EQ(expected, r.Call(*i));
996 } 998 }
997 } 999 }
998 1000
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 1227
1226 // Build the test function. 1228 // Build the test function.
1227 TestSignatures sigs; 1229 TestSignatures sigs;
1228 TestingModule module; 1230 TestingModule module;
1229 WasmFunctionCompiler t(sigs.v_v(), &module); 1231 WasmFunctionCompiler t(sigs.v_v(), &module);
1230 BUILD(t, kExprNop); 1232 BUILD(t, kExprNop);
1231 uint32_t index = t.CompileAndAdd(); 1233 uint32_t index = t.CompileAndAdd();
1232 1234
1233 const int32_t kExpected = -414444; 1235 const int32_t kExpected = -414444;
1234 // Build the calling function. 1236 // Build the calling function.
1235 WasmRunner<int32_t> r; 1237 WasmRunner<int32_t> r(&module);
1236 r.env()->module = &module;
1237 BUILD(r, B2(WASM_CALL_FUNCTION0(index), WASM_I32V_3(kExpected))); 1238 BUILD(r, B2(WASM_CALL_FUNCTION0(index), WASM_I32V_3(kExpected)));
1238 1239
1239 int32_t result = r.Call(); 1240 int32_t result = r.Call();
1240 CHECK_EQ(kExpected, result); 1241 CHECK_EQ(kExpected, result);
1241 } 1242 }
1242 1243
1243 1244
1244 TEST(Run_Wasm_VoidReturn2) { 1245 TEST(Run_Wasm_VoidReturn2) {
1245 // We use a wrapper function because WasmRunner<void> does not exist. 1246 // We use a wrapper function because WasmRunner<void> does not exist.
1246 // Build the test function. 1247 // Build the test function.
1247 TestSignatures sigs; 1248 TestSignatures sigs;
1248 TestingModule module; 1249 TestingModule module;
1249 WasmFunctionCompiler t(sigs.v_v(), &module); 1250 WasmFunctionCompiler t(sigs.v_v(), &module);
1250 BUILD(t, WASM_RETURN0); 1251 BUILD(t, WASM_RETURN0);
1251 uint32_t index = t.CompileAndAdd(); 1252 uint32_t index = t.CompileAndAdd();
1252 1253
1253 const int32_t kExpected = -414444; 1254 const int32_t kExpected = -414444;
1254 // Build the calling function. 1255 // Build the calling function.
1255 WasmRunner<int32_t> r; 1256 WasmRunner<int32_t> r(&module);
1256 r.env()->module = &module;
1257 BUILD(r, B2(WASM_CALL_FUNCTION0(index), WASM_I32V_3(kExpected))); 1257 BUILD(r, B2(WASM_CALL_FUNCTION0(index), WASM_I32V_3(kExpected)));
1258 1258
1259 int32_t result = r.Call(); 1259 int32_t result = r.Call();
1260 CHECK_EQ(kExpected, result); 1260 CHECK_EQ(kExpected, result);
1261 } 1261 }
1262 1262
1263 1263
1264 TEST(Run_Wasm_Block_If_P) { 1264 TEST(Run_Wasm_Block_If_P) {
1265 WasmRunner<int32_t> r(MachineType::Int32()); 1265 WasmRunner<int32_t> r(MachineType::Int32());
1266 // { if (p0) return 51; return 52; } 1266 // { if (p0) return 51; return 52; }
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
1999 1999
2000 Zone zone; 2000 Zone zone;
2001 Isolate* isolate = CcTest::InitIsolateOnce(); 2001 Isolate* isolate = CcTest::InitIsolateOnce();
2002 HandleScope scope(isolate); 2002 HandleScope scope(isolate);
2003 // Enable all optional operators. 2003 // Enable all optional operators.
2004 CommonOperatorBuilder common(&zone); 2004 CommonOperatorBuilder common(&zone);
2005 MachineOperatorBuilder machine(&zone, MachineType::PointerRepresentation(), 2005 MachineOperatorBuilder machine(&zone, MachineType::PointerRepresentation(),
2006 MachineOperatorBuilder::kAllOptionalOps); 2006 MachineOperatorBuilder::kAllOptionalOps);
2007 Graph graph(&zone); 2007 Graph graph(&zone);
2008 JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine); 2008 JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine);
2009 FunctionEnv env;
2010 FunctionSig* sig = WasmOpcodes::Signature(opcode); 2009 FunctionSig* sig = WasmOpcodes::Signature(opcode);
2011 init_env(&env, sig);
2012 2010
2013 if (sig->parameter_count() == 1) { 2011 if (sig->parameter_count() == 1) {
2014 byte code[] = {static_cast<byte>(opcode), kExprGetLocal, 0}; 2012 byte code[] = {WASM_NO_LOCALS, static_cast<byte>(opcode), kExprGetLocal, 0};
2015 TestBuildingGraph(&zone, &jsgraph, &env, code, code + arraysize(code)); 2013 TestBuildingGraph(&zone, &jsgraph, nullptr, sig, code,
2014 code + arraysize(code));
2016 } else { 2015 } else {
2017 CHECK_EQ(2, sig->parameter_count()); 2016 CHECK_EQ(2, sig->parameter_count());
2018 byte code[] = {static_cast<byte>(opcode), kExprGetLocal, 0, kExprGetLocal, 2017 byte code[] = {WASM_NO_LOCALS, static_cast<byte>(opcode),
2019 1}; 2018 kExprGetLocal, 0,
2020 TestBuildingGraph(&zone, &jsgraph, &env, code, code + arraysize(code)); 2019 kExprGetLocal, 1};
2020 TestBuildingGraph(&zone, &jsgraph, nullptr, sig, code,
2021 code + arraysize(code));
2021 } 2022 }
2022 } 2023 }
2023 2024
2024 2025
2025 TEST(Build_Wasm_SimpleExprs) { 2026 TEST(Build_Wasm_SimpleExprs) {
2026 // Test that the decoder can build a graph for all supported simple expressions. 2027 // Test that the decoder can build a graph for all supported simple expressions.
2027 #define GRAPH_BUILD_TEST(name, opcode, sig) \ 2028 #define GRAPH_BUILD_TEST(name, opcode, sig) \
2028 TestBuildGraphForSimpleExpression(kExpr##name); 2029 TestBuildGraphForSimpleExpression(kExpr##name);
2029 2030
2030 FOREACH_SIMPLE_OPCODE(GRAPH_BUILD_TEST); 2031 FOREACH_SIMPLE_OPCODE(GRAPH_BUILD_TEST);
(...skipping 1308 matching lines...) Expand 10 before | Expand all | Expand 10 after
3339 3340
3340 #if WASM_64 3341 #if WASM_64
3341 TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kAstI64); } 3342 TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kAstI64); }
3342 #endif 3343 #endif
3343 3344
3344 3345
3345 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); } 3346 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); }
3346 3347
3347 3348
3348 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); } 3349 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); }
OLDNEW
« no previous file with comments | « src/wasm/wasm-opcodes.h ('k') | test/cctest/wasm/test-run-wasm-64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698