| Index: test/cctest/wasm/test-run-wasm-module.cc
|
| diff --git a/test/cctest/wasm/test-run-wasm-module.cc b/test/cctest/wasm/test-run-wasm-module.cc
|
| index 335260696567fc8e40653e5ef3f6dec4507550a6..05edd62a1bb485f43a7006db7225bfb1b3000211 100644
|
| --- a/test/cctest/wasm/test-run-wasm-module.cc
|
| +++ b/test/cctest/wasm/test-run-wasm-module.cc
|
| @@ -12,6 +12,7 @@
|
| #include "src/wasm/wasm-opcodes.h"
|
|
|
| #include "test/cctest/cctest.h"
|
| +#include "test/cctest/wasm/test-signatures.h"
|
|
|
| using namespace v8::base;
|
| using namespace v8::internal;
|
| @@ -31,12 +32,14 @@ void TestModule(WasmModuleIndex* module, int32_t expected_result) {
|
|
|
| TEST(Run_WasmModule_Return114) {
|
| static const int32_t kReturnValue = 114;
|
| + TestSignatures sigs;
|
| v8::base::AccountingAllocator allocator;
|
| Zone zone(&allocator);
|
| +
|
| WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
|
| uint16_t f_index = builder->AddFunction();
|
| WasmFunctionBuilder* f = builder->FunctionAt(f_index);
|
| - f->ReturnType(kAstI32);
|
| + f->SetSignature(sigs.i_v());
|
| f->Exported(1);
|
| byte code[] = {WASM_I8(kReturnValue)};
|
| f->EmitCode(code, sizeof(code));
|
| @@ -47,17 +50,22 @@ TEST(Run_WasmModule_Return114) {
|
| TEST(Run_WasmModule_CallAdd) {
|
| v8::base::AccountingAllocator allocator;
|
| Zone zone(&allocator);
|
| + TestSignatures sigs;
|
| +
|
| WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
|
| +
|
| uint16_t f1_index = builder->AddFunction();
|
| WasmFunctionBuilder* f = builder->FunctionAt(f1_index);
|
| - f->ReturnType(kAstI32);
|
| - uint16_t param1 = f->AddParam(kAstI32);
|
| - uint16_t param2 = f->AddParam(kAstI32);
|
| + f->SetSignature(sigs.i_ii());
|
| + uint16_t param1 = 0;
|
| + uint16_t param2 = 1;
|
| byte code1[] = {WASM_I32_ADD(WASM_GET_LOCAL(param1), WASM_GET_LOCAL(param2))};
|
| f->EmitCode(code1, sizeof(code1));
|
| +
|
| uint16_t f2_index = builder->AddFunction();
|
| f = builder->FunctionAt(f2_index);
|
| - f->ReturnType(kAstI32);
|
| + f->SetSignature(sigs.i_v());
|
| +
|
| f->Exported(1);
|
| byte code2[] = {WASM_CALL_FUNCTION2(f1_index, WASM_I8(77), WASM_I8(22))};
|
| f->EmitCode(code2, sizeof(code2));
|
| @@ -69,10 +77,13 @@ TEST(Run_WasmModule_ReadLoadedDataSegment) {
|
| static const byte kDataSegmentDest0 = 12;
|
| v8::base::AccountingAllocator allocator;
|
| Zone zone(&allocator);
|
| + TestSignatures sigs;
|
| +
|
| WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
|
| uint16_t f_index = builder->AddFunction();
|
| WasmFunctionBuilder* f = builder->FunctionAt(f_index);
|
| - f->ReturnType(kAstI32);
|
| + f->SetSignature(sigs.i_v());
|
| +
|
| f->Exported(1);
|
| byte code[] = {
|
| WASM_LOAD_MEM(MachineType::Int32(), WASM_I8(kDataSegmentDest0))};
|
| @@ -88,10 +99,13 @@ TEST(Run_WasmModule_CheckMemoryIsZero) {
|
| static const int kCheckSize = 16 * 1024;
|
| v8::base::AccountingAllocator allocator;
|
| Zone zone(&allocator);
|
| + TestSignatures sigs;
|
| +
|
| WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
|
| uint16_t f_index = builder->AddFunction();
|
| WasmFunctionBuilder* f = builder->FunctionAt(f_index);
|
| - f->ReturnType(kAstI32);
|
| + f->SetSignature(sigs.i_v());
|
| +
|
| uint16_t localIndex = f->AddLocal(kAstI32);
|
| f->Exported(1);
|
| byte code[] = {WASM_BLOCK(
|
| @@ -102,7 +116,7 @@ TEST(Run_WasmModule_CheckMemoryIsZero) {
|
| WASM_LOAD_MEM(MachineType::Int32(), WASM_GET_LOCAL(localIndex)),
|
| WASM_BRV(2, WASM_I8(-1)), WASM_INC_LOCAL_BY(localIndex, 4))),
|
| WASM_I8(11))};
|
| - f->EmitCode(code, sizeof(code), nullptr, 0);
|
| + f->EmitCode(code, sizeof(code));
|
| WasmModuleWriter* writer = builder->Build(&zone);
|
| TestModule(writer->WriteTo(&zone), 11);
|
| }
|
| @@ -110,10 +124,13 @@ TEST(Run_WasmModule_CheckMemoryIsZero) {
|
| TEST(Run_WasmModule_CallMain_recursive) {
|
| v8::base::AccountingAllocator allocator;
|
| Zone zone(&allocator);
|
| + TestSignatures sigs;
|
| +
|
| WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
|
| uint16_t f_index = builder->AddFunction();
|
| WasmFunctionBuilder* f = builder->FunctionAt(f_index);
|
| - f->ReturnType(kAstI32);
|
| + f->SetSignature(sigs.i_v());
|
| +
|
| uint16_t localIndex = f->AddLocal(kAstI32);
|
| f->Exported(1);
|
| byte code[] = {WASM_BLOCK(
|
| @@ -124,7 +141,7 @@ TEST(Run_WasmModule_CallMain_recursive) {
|
| WASM_INC_LOCAL(localIndex)),
|
| WASM_BRV(1, WASM_CALL_FUNCTION0(0))),
|
| WASM_BRV(0, WASM_I8(55))))};
|
| - f->EmitCode(code, sizeof(code), nullptr, 0);
|
| + f->EmitCode(code, sizeof(code));
|
| WasmModuleWriter* writer = builder->Build(&zone);
|
| TestModule(writer->WriteTo(&zone), 55);
|
| }
|
| @@ -132,18 +149,20 @@ TEST(Run_WasmModule_CallMain_recursive) {
|
| TEST(Run_WasmModule_Global) {
|
| v8::base::AccountingAllocator allocator;
|
| Zone zone(&allocator);
|
| + TestSignatures sigs;
|
| +
|
| WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
|
| uint32_t global1 = builder->AddGlobal(MachineType::Int32(), 0);
|
| uint32_t global2 = builder->AddGlobal(MachineType::Int32(), 0);
|
| uint16_t f1_index = builder->AddFunction();
|
| WasmFunctionBuilder* f = builder->FunctionAt(f1_index);
|
| - f->ReturnType(kAstI32);
|
| + f->SetSignature(sigs.i_v());
|
| byte code1[] = {
|
| WASM_I32_ADD(WASM_LOAD_GLOBAL(global1), WASM_LOAD_GLOBAL(global2))};
|
| f->EmitCode(code1, sizeof(code1));
|
| uint16_t f2_index = builder->AddFunction();
|
| f = builder->FunctionAt(f2_index);
|
| - f->ReturnType(kAstI32);
|
| + f->SetSignature(sigs.i_v());
|
| f->Exported(1);
|
| byte code2[] = {WASM_STORE_GLOBAL(global1, WASM_I32V_1(56)),
|
| WASM_STORE_GLOBAL(global2, WASM_I32V_1(41)),
|
|
|