This resolves the work started in https://github.com/bytecodealliance/cranelift/pull/1231 and https://github.com/bytecodealliance/wasmtime/pull/1436. Cranelift filetests currently have the ability to run CLIF functions with a signature like `() -> b*` and check that the result is true under the `test run` directive. This PR adds the ability to call functions with arbitrary arguments and non-boolean returns and either print the result or check against a list of expected results: - `run` commands look like `; run: %add(2, 2) == 4` or `; run: %add(2, 2) != 5` and verify that the executed CLIF function returns the expected value - `print` commands look like `; print: %add(2, 2)` and print the result of the function to stdout To make this work, this PR compiles a single Cranelift `Function` into a `CompiledFunction` using a `SingleFunctionCompiler`. Because we will not know the signature of the function until runtime, we use a `Trampoline` to place the values in the appropriate location for the calling convention; this should look a lot like what @alexcrichton is doing with `VMTrampoline` in wasmtime (see3b7cb6ee64/crates/api/src/func.rs (L510-L526),3b7cb6ee64/crates/jit/src/compiler.rs (L260)). To avoid re-compiling `Trampoline`s for the same function signatures, `Trampoline`s are cached in the `SingleFunctionCompiler`.
28 lines
1.0 KiB
TOML
28 lines
1.0 KiB
TOML
[package]
|
|
name = "cranelift-filetests"
|
|
authors = ["The Cranelift Project Developers"]
|
|
version = "0.63.0"
|
|
description = "Test driver and implementations of the filetest commands"
|
|
license = "Apache-2.0 WITH LLVM-exception"
|
|
documentation = "https://docs.rs/cranelift-filetests"
|
|
repository = "https://github.com/bytecodealliance/wasmtime"
|
|
publish = false
|
|
edition = "2018"
|
|
|
|
[dependencies]
|
|
cranelift-codegen = { path = "../codegen", version = "0.63.0", features = ["testing_hooks"] }
|
|
cranelift-frontend = { path = "../frontend", version = "0.63.0" }
|
|
cranelift-native = { path = "../native", version = "0.63.0" }
|
|
cranelift-reader = { path = "../reader", version = "0.63.0" }
|
|
cranelift-preopt = { path = "../preopt", version = "0.63.0" }
|
|
byteorder = { version = "1.3.2", default-features = false }
|
|
file-per-thread-logger = "0.1.2"
|
|
filecheck = "0.5.0"
|
|
gimli = { version = "0.20.0", default-features = false, features = ["read"] }
|
|
log = "0.4.6"
|
|
memmap = "0.7.0"
|
|
num_cpus = "1.8.0"
|
|
region = "2.1.2"
|
|
target-lexicon = "0.10"
|
|
thiserror = "1.0.15"
|