[wasm][fuzzer] Fix return value of interpreter
Bring the return value of {InterpretWasmModule} in sync with {CallWasmFunctionForTesting}, because the fuzzers now compare the two. R=ahaas@chromium.org Bug: chromium:1115431 Change-Id: I0abf79c4418a4e6cc7365a78148e5e71cf32231b Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2351678 Commit-Queue: Clemens Backes <clemensb@chromium.org> Reviewed-by: Andreas Haas <ahaas@chromium.org> Cr-Commit-Position: refs/heads/master@{#69374}
This commit is contained in:
parent
5fdc951df3
commit
833662c74a
@ -100,12 +100,13 @@ WasmInterpretationResult InterpretWasmModule(
|
||||
|
||||
Zone zone(isolate->allocator(), ZONE_NAME);
|
||||
v8::internal::HandleScope scope(isolate);
|
||||
const WasmFunction* func = &instance->module()->functions[function_index];
|
||||
|
||||
WasmInterpreter interpreter{
|
||||
isolate, instance->module(),
|
||||
ModuleWireBytes{instance->module_object().native_module()->wire_bytes()},
|
||||
instance};
|
||||
interpreter.InitFrame(&instance->module()->functions[function_index], args);
|
||||
interpreter.InitFrame(func, args);
|
||||
WasmInterpreter::State interpreter_result = interpreter.Run(kMaxNumSteps);
|
||||
|
||||
bool stack_overflow = isolate->has_pending_exception();
|
||||
@ -119,9 +120,30 @@ WasmInterpretationResult InterpretWasmModule(
|
||||
}
|
||||
|
||||
if (interpreter_result == WasmInterpreter::FINISHED) {
|
||||
// Get the result as an {int32_t}. Keep this in sync with
|
||||
// {CallWasmFunctionForTesting}, because fuzzers will compare the results.
|
||||
int32_t result = -1;
|
||||
if (func->sig->return_count() > 0) {
|
||||
WasmValue return_value = interpreter.GetReturnValue();
|
||||
switch (func->sig->GetReturn(0).kind()) {
|
||||
case ValueType::kI32:
|
||||
result = return_value.to<int32_t>();
|
||||
break;
|
||||
case ValueType::kI64:
|
||||
result = static_cast<int32_t>(return_value.to<int64_t>());
|
||||
break;
|
||||
case ValueType::kF32:
|
||||
result = static_cast<int32_t>(return_value.to<float>());
|
||||
break;
|
||||
case ValueType::kF64:
|
||||
result = static_cast<int32_t>(return_value.to<double>());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return WasmInterpretationResult::Finished(
|
||||
interpreter.GetReturnValue().to<int32_t>(),
|
||||
interpreter.PossibleNondeterminism());
|
||||
result, interpreter.PossibleNondeterminism());
|
||||
}
|
||||
|
||||
// The interpreter did not finish within the limited number of steps, so it
|
||||
|
BIN
test/fuzzer/wasm_async/regress-1115431.wasm
Normal file
BIN
test/fuzzer/wasm_async/regress-1115431.wasm
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user