| OLD | NEW |
| 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 "test/unittests/test-utils.h" | 5 #include "test/unittests/test-utils.h" |
| 6 | 6 |
| 7 #include "src/v8.h" | 7 #include "src/v8.h" |
| 8 | 8 |
| 9 #include "test/cctest/wasm/test-signatures.h" | 9 #include "test/cctest/wasm/test-signatures.h" |
| 10 | 10 |
| (...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 // A helper for tests that require a module environment for functions and | 1182 // A helper for tests that require a module environment for functions and |
| 1183 // globals. | 1183 // globals. |
| 1184 class TestModuleEnv : public ModuleEnv { | 1184 class TestModuleEnv : public ModuleEnv { |
| 1185 public: | 1185 public: |
| 1186 TestModuleEnv() { | 1186 TestModuleEnv() { |
| 1187 mem_start = 0; | 1187 mem_start = 0; |
| 1188 mem_end = 0; | 1188 mem_end = 0; |
| 1189 module = &mod; | 1189 module = &mod; |
| 1190 linker = nullptr; | 1190 linker = nullptr; |
| 1191 function_code = nullptr; | 1191 function_code = nullptr; |
| 1192 mod.globals = &globals; | 1192 mod.globals = new std::vector<WasmGlobal>; |
| 1193 mod.signatures = &signatures; | 1193 mod.signatures = new std::vector<FunctionSig*>; |
| 1194 mod.functions = &functions; | 1194 mod.functions = new std::vector<WasmFunction>; |
| 1195 } | 1195 } |
| 1196 byte AddGlobal(MachineType mem_type) { | 1196 byte AddGlobal(MachineType mem_type) { |
| 1197 globals.push_back({0, mem_type, 0, false}); | 1197 mod.globals->push_back({0, mem_type, 0, false}); |
| 1198 CHECK(globals.size() <= 127); | 1198 CHECK(mod.globals->size() <= 127); |
| 1199 return static_cast<byte>(globals.size() - 1); | 1199 return static_cast<byte>(mod.globals->size() - 1); |
| 1200 } | 1200 } |
| 1201 byte AddSignature(FunctionSig* sig) { | 1201 byte AddSignature(FunctionSig* sig) { |
| 1202 signatures.push_back(sig); | 1202 mod.signatures->push_back(sig); |
| 1203 CHECK(signatures.size() <= 127); | 1203 CHECK(mod.signatures->size() <= 127); |
| 1204 return static_cast<byte>(signatures.size() - 1); | 1204 return static_cast<byte>(mod.signatures->size() - 1); |
| 1205 } | 1205 } |
| 1206 byte AddFunction(FunctionSig* sig) { | 1206 byte AddFunction(FunctionSig* sig) { |
| 1207 functions.push_back({sig, 0, 0, 0, 0, 0, 0, 0, false, false}); | 1207 mod.functions->push_back({sig, 0, 0, 0, 0, 0, 0, 0, false, false}); |
| 1208 CHECK(functions.size() <= 127); | 1208 CHECK(mod.functions->size() <= 127); |
| 1209 return static_cast<byte>(functions.size() - 1); | 1209 return static_cast<byte>(mod.functions->size() - 1); |
| 1210 } | 1210 } |
| 1211 | 1211 |
| 1212 private: | 1212 private: |
| 1213 WasmModule mod; | 1213 WasmModule mod; |
| 1214 std::vector<WasmGlobal> globals; | |
| 1215 std::vector<FunctionSig*> signatures; | |
| 1216 std::vector<WasmFunction> functions; | |
| 1217 }; | 1214 }; |
| 1218 } // namespace | 1215 } // namespace |
| 1219 | 1216 |
| 1220 | 1217 |
| 1221 TEST_F(WasmDecoderTest, SimpleCalls) { | 1218 TEST_F(WasmDecoderTest, SimpleCalls) { |
| 1222 FunctionEnv* env = &env_i_i; | 1219 FunctionEnv* env = &env_i_i; |
| 1223 TestModuleEnv module_env; | 1220 TestModuleEnv module_env; |
| 1224 env->module = &module_env; | 1221 env->module = &module_env; |
| 1225 | 1222 |
| 1226 module_env.AddFunction(sigs.i_v()); | 1223 module_env.AddFunction(sigs.i_v()); |
| (...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2378 EXPECT_ARITY(1, kExprF64SConvertI64); | 2375 EXPECT_ARITY(1, kExprF64SConvertI64); |
| 2379 EXPECT_ARITY(1, kExprF64UConvertI64); | 2376 EXPECT_ARITY(1, kExprF64UConvertI64); |
| 2380 EXPECT_ARITY(1, kExprF64ConvertF32); | 2377 EXPECT_ARITY(1, kExprF64ConvertF32); |
| 2381 EXPECT_ARITY(1, kExprF64ReinterpretI64); | 2378 EXPECT_ARITY(1, kExprF64ReinterpretI64); |
| 2382 EXPECT_ARITY(1, kExprI32ReinterpretF32); | 2379 EXPECT_ARITY(1, kExprI32ReinterpretF32); |
| 2383 EXPECT_ARITY(1, kExprI64ReinterpretF64); | 2380 EXPECT_ARITY(1, kExprI64ReinterpretF64); |
| 2384 } | 2381 } |
| 2385 } // namespace wasm | 2382 } // namespace wasm |
| 2386 } // namespace internal | 2383 } // namespace internal |
| 2387 } // namespace v8 | 2384 } // namespace v8 |
| OLD | NEW |