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

Unified Diff: test/cctest/wasm/test-run-wasm-module.cc

Issue 2345593003: [wasm] Master CL for Binary 0xC changes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix test failures and TSAN races. Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/wasm/test-run-wasm-js.cc ('k') | test/cctest/wasm/test-run-wasm-relocation.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 27ef35632bb277d49889071551441547fd7ed51f..28ba6029405a761e37b440a91e74cd7086464ee7 100644
--- a/test/cctest/wasm/test-run-wasm-module.cc
+++ b/test/cctest/wasm/test-run-wasm-module.cc
@@ -53,9 +53,7 @@ TEST(Run_WasmModule_Return114) {
Zone zone(&allocator);
WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
- uint16_t f_index = builder->AddFunction();
- WasmFunctionBuilder* f = builder->FunctionAt(f_index);
- f->SetSignature(sigs.i_v());
+ WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v());
ExportAsMain(f);
byte code[] = {WASM_I8(kReturnValue)};
f->EmitCode(code, sizeof(code));
@@ -69,21 +67,18 @@ TEST(Run_WasmModule_CallAdd) {
WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
- uint16_t f1_index = builder->AddFunction();
- WasmFunctionBuilder* f = builder->FunctionAt(f1_index);
- f->SetSignature(sigs.i_ii());
+ WasmFunctionBuilder* f1 = builder->AddFunction(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));
+ f1->EmitCode(code1, sizeof(code1));
- uint16_t f2_index = builder->AddFunction();
- f = builder->FunctionAt(f2_index);
- f->SetSignature(sigs.i_v());
+ WasmFunctionBuilder* f2 = builder->AddFunction(sigs.i_v());
- ExportAsMain(f);
- byte code2[] = {WASM_CALL_FUNCTION2(f1_index, WASM_I8(77), WASM_I8(22))};
- f->EmitCode(code2, sizeof(code2));
+ ExportAsMain(f2);
+ byte code2[] = {
+ WASM_CALL_FUNCTION(f1->func_index(), WASM_I8(77), WASM_I8(22))};
+ f2->EmitCode(code2, sizeof(code2));
TestModule(&zone, builder, 99);
}
@@ -94,9 +89,7 @@ TEST(Run_WasmModule_ReadLoadedDataSegment) {
TestSignatures sigs;
WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
- uint16_t f_index = builder->AddFunction();
- WasmFunctionBuilder* f = builder->FunctionAt(f_index);
- f->SetSignature(sigs.i_v());
+ WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v());
ExportAsMain(f);
byte code[] = {
@@ -115,18 +108,16 @@ TEST(Run_WasmModule_CheckMemoryIsZero) {
TestSignatures sigs;
WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
- uint16_t f_index = builder->AddFunction();
- WasmFunctionBuilder* f = builder->FunctionAt(f_index);
- f->SetSignature(sigs.i_v());
+ WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v());
uint16_t localIndex = f->AddLocal(kAstI32);
ExportAsMain(f);
- byte code[] = {WASM_BLOCK(
+ byte code[] = {WASM_BLOCK_I(
WASM_WHILE(
WASM_I32_LTS(WASM_GET_LOCAL(localIndex), WASM_I32V_3(kCheckSize)),
WASM_IF_ELSE(
WASM_LOAD_MEM(MachineType::Int32(), WASM_GET_LOCAL(localIndex)),
- WASM_BRV(2, WASM_I8(-1)), WASM_INC_LOCAL_BY(localIndex, 4))),
+ WASM_BRV(3, WASM_I8(-1)), WASM_INC_LOCAL_BY(localIndex, 4))),
WASM_I8(11))};
f->EmitCode(code, sizeof(code));
TestModule(&zone, builder, 11);
@@ -138,20 +129,18 @@ TEST(Run_WasmModule_CallMain_recursive) {
TestSignatures sigs;
WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
- uint16_t f_index = builder->AddFunction();
- WasmFunctionBuilder* f = builder->FunctionAt(f_index);
- f->SetSignature(sigs.i_v());
+ WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v());
uint16_t localIndex = f->AddLocal(kAstI32);
ExportAsMain(f);
- byte code[] = {WASM_BLOCK(
+ byte code[] = {
WASM_SET_LOCAL(localIndex,
WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO)),
- WASM_IF_ELSE(WASM_I32_LTS(WASM_GET_LOCAL(localIndex), WASM_I8(5)),
- WASM_BLOCK(WASM_STORE_MEM(MachineType::Int32(), WASM_ZERO,
+ WASM_IF_ELSE_I(WASM_I32_LTS(WASM_GET_LOCAL(localIndex), WASM_I8(5)),
+ WASM_SEQ(WASM_STORE_MEM(MachineType::Int32(), WASM_ZERO,
WASM_INC_LOCAL(localIndex)),
- WASM_BRV(1, WASM_CALL_FUNCTION0(0))),
- WASM_BRV(0, WASM_I8(55))))};
+ WASM_CALL_FUNCTION0(0)),
+ WASM_I8(55))};
f->EmitCode(code, sizeof(code));
TestModule(&zone, builder, 55);
}
@@ -164,20 +153,16 @@ TEST(Run_WasmModule_Global) {
WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
uint32_t global1 = builder->AddGlobal(kAstI32, 0);
uint32_t global2 = builder->AddGlobal(kAstI32, 0);
- uint16_t f1_index = builder->AddFunction();
- WasmFunctionBuilder* f = builder->FunctionAt(f1_index);
- f->SetSignature(sigs.i_v());
+ WasmFunctionBuilder* f1 = builder->AddFunction(sigs.i_v());
byte code1[] = {
WASM_I32_ADD(WASM_GET_GLOBAL(global1), WASM_GET_GLOBAL(global2))};
- f->EmitCode(code1, sizeof(code1));
- uint16_t f2_index = builder->AddFunction();
- f = builder->FunctionAt(f2_index);
- f->SetSignature(sigs.i_v());
- ExportAsMain(f);
+ f1->EmitCode(code1, sizeof(code1));
+ WasmFunctionBuilder* f2 = builder->AddFunction(sigs.i_v());
+ ExportAsMain(f2);
byte code2[] = {WASM_SET_GLOBAL(global1, WASM_I32V_1(56)),
WASM_SET_GLOBAL(global2, WASM_I32V_1(41)),
- WASM_RETURN1(WASM_CALL_FUNCTION0(f1_index))};
- f->EmitCode(code2, sizeof(code2));
+ WASM_RETURN1(WASM_CALL_FUNCTION0(f1->func_index()))};
+ f2->EmitCode(code2, sizeof(code2));
TestModule(&zone, builder, 97);
}
@@ -187,11 +172,9 @@ TEST(Run_WasmModule_Serialization) {
Zone zone(&allocator);
WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
- uint16_t f_index = builder->AddFunction();
TestSignatures sigs;
- WasmFunctionBuilder* f = builder->FunctionAt(f_index);
- f->SetSignature(sigs.i_i());
+ WasmFunctionBuilder* f = builder->AddFunction(sigs.i_i());
byte code[] = {WASM_GET_LOCAL(0), kExprI32Const, 1, kExprI32Add};
f->EmitCode(code, sizeof(code));
ExportAs(f, kFunctionName);
@@ -244,7 +227,7 @@ TEST(Run_WasmModule_Serialization) {
Handle<JSObject> module_object =
Handle<JSObject>::cast(v8::Utils::OpenHandle(*compiled_module));
Handle<JSObject> instance =
- WasmModule::Instantiate(isolate, module_object,
+ WasmModule::Instantiate(isolate, &thrower, module_object,
Handle<JSReceiver>::null(),
Handle<JSArrayBuffer>::null())
.ToHandleChecked();
@@ -258,19 +241,16 @@ TEST(Run_WasmModule_Serialization) {
}
TEST(Run_WasmModule_MemSize_GrowMem) {
- static const int kPageSize = 0x10000;
// Initial memory size = 16 + GrowMemory(10)
- static const int kExpectedValue = kPageSize * 26;
+ static const int kExpectedValue = 26;
TestSignatures sigs;
v8::internal::AccountingAllocator allocator;
Zone zone(&allocator);
WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
- uint16_t f_index = builder->AddFunction();
- WasmFunctionBuilder* f = builder->FunctionAt(f_index);
- f->SetSignature(sigs.i_v());
+ WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v());
ExportAsMain(f);
- byte code[] = {WASM_GROW_MEMORY(WASM_I8(10)), WASM_MEMORY_SIZE};
+ byte code[] = {WASM_GROW_MEMORY(WASM_I8(10)), WASM_DROP, WASM_MEMORY_SIZE};
f->EmitCode(code, sizeof(code));
TestModule(&zone, builder, kExpectedValue);
}
@@ -280,12 +260,10 @@ TEST(Run_WasmModule_GrowMemoryInIf) {
v8::internal::AccountingAllocator allocator;
Zone zone(&allocator);
WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
- uint16_t f_index = builder->AddFunction();
- WasmFunctionBuilder* f = builder->FunctionAt(f_index);
- f->SetSignature(sigs.i_v());
+ WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v());
ExportAsMain(f);
- byte code[] = {WASM_IF_ELSE(WASM_I32V(0), WASM_GROW_MEMORY(WASM_I32V(1)),
- WASM_I32V(12))};
+ byte code[] = {WASM_IF_ELSE_I(WASM_I32V(0), WASM_GROW_MEMORY(WASM_I32V(1)),
+ WASM_I32V(12))};
f->EmitCode(code, sizeof(code));
TestModule(&zone, builder, 12);
}
« no previous file with comments | « test/cctest/wasm/test-run-wasm-js.cc ('k') | test/cctest/wasm/test-run-wasm-relocation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698