Account for fuel before unconditionally trapping Wasm accesses (#5447)

* Account for fuel before unconditionally trapping Wasm accesses

Fixes #5445

* Add a test for fuel accounting and unconditionally trapping memory accesses
This commit is contained in:
Nick Fitzgerald
2022-12-15 12:18:52 -08:00
committed by GitHub
parent 0a6a28a4fb
commit 1fe56d7efb
5 changed files with 80 additions and 15 deletions

View File

@@ -490,6 +490,18 @@ pub trait FuncEnvironment: TargetEnvironment {
Ok(())
}
/// Optional callback for the `FuncEnvironment` performing this translation
/// to maintain, prepare, or finalize custom, internal state when we
/// statically determine that a Wasm memory access will unconditionally
/// trap, rendering the rest of the block unreachable. Called just before
/// the unconditional trap is emitted.
fn before_unconditionally_trapping_memory_access(
&mut self,
_builder: &mut FunctionBuilder,
) -> WasmResult<()> {
Ok(())
}
/// Optional callback for the `FunctionEnvironment` performing this translation to perform work
/// before the function body is translated.
fn before_translate_function(