Restore compatibility with upstream disas tests #135
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It recently became necessary to regenerate the expected output of most (all?) of the files in tests/disas. Concretely, we were generating slightly different CLIF than upstream even on modules not involving any WasmFX instructions.
This PR rectifies this situation, making sure that we generate identical CLIF again. This required two changes:
Global CLIF variable for runtime limits pointer
Since #99, we called the function
wasmtime_cranelift::func_environ::FuncEnvironment::declare_vmruntime_limits_ptr
unconditionally for every compiled function, meaning that every function prelude now contained a definition of the corresponding global variable.This PR changes this behavior: I restored the original logic for when to call
declare_vmruntime_limits_ptr
. Instead of using the global variablevmruntime_limits
to access theVMRuntimeLimits
, we now load this pointer ourselves once perresume
instruction. Since the load instruction is marked asreadonly
, it should be coalesced into a single load, even if multipleresume
s appear in the same function.I've benchmarked this, using a micro-benchmark with 2 resume instructions in the same function, and as expected there is no observable difference in performance.
Order of libcall declarations
In
builtin.rs
, we put the declarations of our own libcalls into the middle of the list of all libcalls in theforeach_builtin_function
macro. This shifted the indices of some existing libcalls, which caused the CLIF to differ when using these. I've moved all thetc_
libcalls to the end of the list, thus leaving the indices of existing libcalls unchanged.As a result, I've replaced all files in tests/disas with the versions from upstream (bytecodealliance/wasmtime@afaf1c7, the most recent upstream commit that we've merged)