[wasm][fuzzer] Merge redundant functions
Remove the {ErrorThrower} parameter to {CallWasmFunctionForTesting} (it was only populated in a subset of failures anyway), and merge it with {RunWasmModuleForTesting}. R=ahaas@chromium.org Bug: chromium:1113681 Change-Id: I5391e2f911928641a907bc5dad5a54677c90acb6 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2346279 Reviewed-by: Andreas Haas <ahaas@chromium.org> Commit-Queue: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#69327}
This commit is contained in:
parent
b3a6b58630
commit
14e55ad40f
@ -114,7 +114,8 @@ TEST(Run_WasmModule_Buffer_Externalized_GrowMem) {
|
||||
handle(memory_object->array_buffer(), isolate));
|
||||
|
||||
// Grow using an internal Wasm bytecode.
|
||||
result = testing::RunWasmModuleForTesting(isolate, instance, 0, nullptr);
|
||||
result = testing::CallWasmFunctionForTesting(isolate, instance, "main", 0,
|
||||
nullptr);
|
||||
CHECK_EQ(26, result);
|
||||
CHECK(external2.buffer_->was_detached()); // growing always detaches
|
||||
CHECK_EQ(0, external2.buffer_->byte_length());
|
||||
|
@ -137,8 +137,8 @@ TEST(Run_WasmModule_CompilationHintsLazy) {
|
||||
isolate->wasm_engine()->SyncInstantiate(
|
||||
isolate, &thrower, module.ToHandleChecked(), {}, {});
|
||||
CHECK(!instance.is_null());
|
||||
int32_t result = testing::RunWasmModuleForTesting(
|
||||
isolate, instance.ToHandleChecked(), 0, nullptr);
|
||||
int32_t result = testing::CallWasmFunctionForTesting(
|
||||
isolate, instance.ToHandleChecked(), "main", 0, nullptr);
|
||||
CHECK_EQ(kReturnValue, result);
|
||||
|
||||
// Lazy function was invoked and therefore compiled.
|
||||
@ -580,7 +580,7 @@ TEST(TestInterruptLoop) {
|
||||
|
||||
InterruptThread thread(isolate, memory_array);
|
||||
CHECK(thread.Start());
|
||||
testing::RunWasmModuleForTesting(isolate, instance, 0, nullptr);
|
||||
testing::CallWasmFunctionForTesting(isolate, instance, "main", 0, nullptr);
|
||||
Address address = reinterpret_cast<Address>(
|
||||
&memory_array[InterruptThread::interrupt_location_]);
|
||||
CHECK_EQ(InterruptThread::interrupt_value_,
|
||||
@ -662,14 +662,14 @@ TEST(Run_WasmModule_GrowMemOobFixedIndex) {
|
||||
for (uint32_t i = 1; i < 5; i++) {
|
||||
Handle<Object> params[1] = {Handle<Object>(Smi::FromInt(i), isolate)};
|
||||
v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate));
|
||||
testing::RunWasmModuleForTesting(isolate, instance, 1, params);
|
||||
testing::CallWasmFunctionForTesting(isolate, instance, "main", 1, params);
|
||||
CHECK(try_catch.HasCaught());
|
||||
isolate->clear_pending_exception();
|
||||
}
|
||||
|
||||
Handle<Object> params[1] = {Handle<Object>(Smi::FromInt(1), isolate)};
|
||||
int32_t result =
|
||||
testing::RunWasmModuleForTesting(isolate, instance, 1, params);
|
||||
int32_t result = testing::CallWasmFunctionForTesting(isolate, instance,
|
||||
"main", 1, params);
|
||||
CHECK_EQ(0xACED, result);
|
||||
}
|
||||
Cleanup();
|
||||
@ -710,7 +710,7 @@ TEST(Run_WasmModule_GrowMemOobVariableIndex) {
|
||||
Handle<Object> params[1] = {
|
||||
Handle<Object>(Smi::FromInt((16 + i) * kPageSize - 3), isolate)};
|
||||
v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate));
|
||||
testing::RunWasmModuleForTesting(isolate, instance, 1, params);
|
||||
testing::CallWasmFunctionForTesting(isolate, instance, "main", 1, params);
|
||||
CHECK(try_catch.HasCaught());
|
||||
isolate->clear_pending_exception();
|
||||
}
|
||||
@ -718,15 +718,15 @@ TEST(Run_WasmModule_GrowMemOobVariableIndex) {
|
||||
for (int i = 1; i < 5; i++) {
|
||||
Handle<Object> params[1] = {
|
||||
Handle<Object>(Smi::FromInt((20 + i) * kPageSize - 4), isolate)};
|
||||
int32_t result =
|
||||
testing::RunWasmModuleForTesting(isolate, instance, 1, params);
|
||||
int32_t result = testing::CallWasmFunctionForTesting(isolate, instance,
|
||||
"main", 1, params);
|
||||
CHECK_EQ(0xACED, result);
|
||||
}
|
||||
|
||||
v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate));
|
||||
Handle<Object> params[1] = {
|
||||
Handle<Object>(Smi::FromInt(25 * kPageSize), isolate)};
|
||||
testing::RunWasmModuleForTesting(isolate, instance, 1, params);
|
||||
testing::CallWasmFunctionForTesting(isolate, instance, "main", 1, params);
|
||||
CHECK(try_catch.HasCaught());
|
||||
isolate->clear_pending_exception();
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ class WasmSerializationTest {
|
||||
Handle<Object> params[1] = {
|
||||
Handle<Object>(Smi::FromInt(41), CcTest::i_isolate())};
|
||||
int32_t result = testing::CallWasmFunctionForTesting(
|
||||
CcTest::i_isolate(), instance, &thrower, kFunctionName, 1, params);
|
||||
CcTest::i_isolate(), instance, kFunctionName, 1, params);
|
||||
CHECK_EQ(42, result);
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,8 @@ class SharedEngineIsolate {
|
||||
}
|
||||
|
||||
int32_t Run(Handle<WasmInstanceObject> instance) {
|
||||
return testing::RunWasmModuleForTesting(isolate(), instance, 0, nullptr);
|
||||
return testing::CallWasmFunctionForTesting(isolate(), instance, "main", 0,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -132,14 +132,6 @@ WasmInterpretationResult InterpretWasmModuleForTesting(
|
||||
return GetInterpretationResult(isolate, interpreter, interpreter_result);
|
||||
}
|
||||
|
||||
int32_t RunWasmModuleForTesting(Isolate* isolate,
|
||||
Handle<WasmInstanceObject> instance, int argc,
|
||||
Handle<Object> argv[]) {
|
||||
ErrorThrower thrower(isolate, "RunWasmModule");
|
||||
return CallWasmFunctionForTesting(isolate, instance, &thrower, "main", argc,
|
||||
argv);
|
||||
}
|
||||
|
||||
int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start,
|
||||
const byte* module_end) {
|
||||
HandleScope scope(isolate);
|
||||
@ -149,8 +141,8 @@ int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start,
|
||||
if (instance.is_null()) {
|
||||
return -1;
|
||||
}
|
||||
return RunWasmModuleForTesting(isolate, instance.ToHandleChecked(), 0,
|
||||
nullptr);
|
||||
return CallWasmFunctionForTesting(isolate, instance.ToHandleChecked(), "main",
|
||||
0, nullptr);
|
||||
}
|
||||
|
||||
WasmInterpretationResult InterpretWasmModule(
|
||||
@ -191,8 +183,8 @@ MaybeHandle<WasmExportedFunction> GetExportedFunction(
|
||||
|
||||
int32_t CallWasmFunctionForTesting(Isolate* isolate,
|
||||
Handle<WasmInstanceObject> instance,
|
||||
ErrorThrower* thrower, const char* name,
|
||||
int argc, Handle<Object> argv[]) {
|
||||
const char* name, int argc,
|
||||
Handle<Object> argv[]) {
|
||||
MaybeHandle<WasmExportedFunction> maybe_export =
|
||||
GetExportedFunction(isolate, instance, name);
|
||||
Handle<WasmExportedFunction> main_export;
|
||||
@ -209,7 +201,6 @@ int32_t CallWasmFunctionForTesting(Isolate* isolate,
|
||||
if (retval.is_null()) {
|
||||
DCHECK(isolate->has_pending_exception());
|
||||
isolate->clear_pending_exception();
|
||||
thrower->RuntimeError("Calling exported wasm function failed.");
|
||||
return -1;
|
||||
}
|
||||
Handle<Object> result = retval.ToHandleChecked();
|
||||
@ -219,8 +210,6 @@ int32_t CallWasmFunctionForTesting(Isolate* isolate,
|
||||
if (result->IsHeapNumber()) {
|
||||
return static_cast<int32_t>(HeapNumber::cast(*result).value());
|
||||
}
|
||||
thrower->RuntimeError(
|
||||
"Calling exported wasm function failed: Return value should be number");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -34,8 +34,8 @@ MaybeHandle<WasmExportedFunction> GetExportedFunction(
|
||||
// returning.
|
||||
int32_t CallWasmFunctionForTesting(Isolate* isolate,
|
||||
Handle<WasmInstanceObject> instance,
|
||||
ErrorThrower* thrower, const char* name,
|
||||
int argc, Handle<Object> argv[]);
|
||||
const char* name, int argc,
|
||||
Handle<Object> argv[]);
|
||||
|
||||
// Decode, verify, and run the function labeled "main" in the
|
||||
// given encoded module. The module should have no imports.
|
||||
@ -105,11 +105,6 @@ WasmInterpretationResult InterpretWasmModuleForTesting(
|
||||
Isolate* isolate, Handle<WasmInstanceObject> instance, size_t argc,
|
||||
WasmValue* args);
|
||||
|
||||
// Runs the module instance with arguments.
|
||||
int32_t RunWasmModuleForTesting(Isolate* isolate,
|
||||
Handle<WasmInstanceObject> instance, int argc,
|
||||
Handle<Object> argv[]);
|
||||
|
||||
// Install function map, module symbol for testing
|
||||
void SetupIsolateForWasmModule(Isolate* isolate);
|
||||
|
||||
|
@ -71,8 +71,9 @@ void InterpretAndExecuteModule(i::Isolate* isolate,
|
||||
thrower.Reset(); // Ignore errors.
|
||||
return;
|
||||
}
|
||||
int32_t result_compiled =
|
||||
testing::RunWasmModuleForTesting(isolate, instance, 0, nullptr);
|
||||
|
||||
int32_t result_compiled = testing::CallWasmFunctionForTesting(
|
||||
isolate, instance, "main", 0, nullptr);
|
||||
if (interpreter_result.trapped() != isolate->has_pending_exception()) {
|
||||
const char* exception_text[] = {"no exception", "exception"};
|
||||
FATAL("interpreter: %s; compiled: %s",
|
||||
@ -398,11 +399,11 @@ void WasmExecutionFuzzer::FuzzWasmModule(Vector<const uint8_t> data,
|
||||
i_isolate->wasm_engine()->SyncInstantiate(
|
||||
i_isolate, &compiler_thrower, compiled_module.ToHandleChecked(),
|
||||
MaybeHandle<JSReceiver>(), MaybeHandle<JSArrayBuffer>());
|
||||
|
||||
DCHECK(!compiler_thrower.error());
|
||||
|
||||
result_compiled = testing::CallWasmFunctionForTesting(
|
||||
i_isolate, compiled_instance.ToHandleChecked(), &compiler_thrower,
|
||||
"main", num_args, compiler_args.get());
|
||||
i_isolate, compiled_instance.ToHandleChecked(), "main", num_args,
|
||||
compiler_args.get());
|
||||
}
|
||||
|
||||
if (interpreter_result.trapped() != i_isolate->has_pending_exception()) {
|
||||
|
Loading…
Reference in New Issue
Block a user