wasmtime
wasmtime copied to clipboard
wasmtime: Consume fuel on all return paths
As far as I can tell, when functions use a return
instruction rather than falling off the end, fuel was not being tracked correctly. The fuel_function_exit
method was only called from
after_translate_function
, which is only called once all the instructions in the function have been translated, not at each return.
In this commit I switched to calling fuel_function_exit
from handle_before_return
instead, alongside some of the wmemcheck
hooks. That should ensure that it happens on every function exit, regardless of what form that exit takes.
I think after_translate_function
is fundamentally difficult to use correctly, and it wasn't used for anything else, so I've also removed it in this commit. And I did a minor cleanup at the site of one of the calls to handle_before_return
while I was looking at it.