Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
87bf2d4
executor: Use non wasmi-specific execution in tests.
jimpo Oct 18, 2019
f37b9d8
executor: Move all runtime execution tests into tests file.
jimpo Oct 18, 2019
36bdc5c
executor: Use test_case macro to easily execute tests with different
jimpo Oct 18, 2019
727ce43
executor: Convert errors to strings with Display, not Debug.
jimpo Oct 21, 2019
1bcb472
node-executor: Rewrite benchmarks with criterion.
jimpo Oct 21, 2019
3908f76
executor: Begin implementation of Wasm runtime.
jimpo Oct 21, 2019
447c31a
executor: Define and implement basic FunctionExecutor.
jimpo Oct 21, 2019
828fbf0
executor: Implement host function trampoline generation.
jimpo Oct 21, 2019
81535c5
executor: Instantiate and link runtime module to env module.
jimpo Oct 21, 2019
a3d2b35
executor: Provide input data during wasmtime execution.
jimpo Oct 21, 2019
a7bb759
executor: Implement SandboxCapabilites::invoke for wasmtime executor.
jimpo Oct 21, 2019
9076ca0
executor: Integrate and test wasmtime execution method.
jimpo Oct 21, 2019
5a903a8
executor: Improve FunctionExecution error messages.
jimpo Oct 21, 2019
a77e9bd
Scope the unsafe blocks to be smaller.
jimpo Oct 23, 2019
c964753
Rename TrampolineState to EnvState.
jimpo Oct 23, 2019
5e0d828
Let EnvState own its own compiler instead of unsafe lifetime cast.
jimpo Oct 24, 2019
7623f12
Refactor out some common wasmi/wasmtime logic.
jimpo Oct 25, 2019
7467e35
Typos and cosmetic changes.
jimpo Oct 25, 2019
b73465c
More trampoline comments.
jimpo Oct 25, 2019
d5b72c6
Cargo.lock update.
jimpo Oct 28, 2019
779d4b4
cli: CLI option for running Substrate with compiled Wasm execution.
jimpo Oct 25, 2019
5ffda81
executor: Switch dependency from fork to official wasmtime repo.
jimpo Oct 28, 2019
70896c0
Quiet down cranelift logs.
jimpo Oct 28, 2019
4b0cdc8
Explicitly catch panics during host calls.
jimpo Oct 30, 2019
28f7c11
Additional checks and clarifications in make_trampoline.
jimpo Oct 30, 2019
f4016dd
Merge branch 'master' into wasmtime-real
jimpo Oct 31, 2019
b76f733
Fixes after merge from master and panic safety for wasmtime
jimpo Oct 31, 2019
0ec6caf
Merge branch 'master' into wasmtime-real
jimpo Nov 1, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
More trampoline comments.
  • Loading branch information
jimpo committed Oct 28, 2019
commit b73465c7443e27d75afa41e2160abb5e66bcdacb
15 changes: 14 additions & 1 deletion core/executor/src/wasmtime/trampoline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,16 @@ unsafe fn stub_fn_inner(

/// Create a trampoline for invoking a host function.
///
/// This code is mostly copied from wasmtime's wasmtime-api/src/trampoline/func.rs.
/// The trampoline is a dynamically generated entry point to a runtime host call. The function is
/// generated by manually constructing Cranelift IR and using the Cranelift compiler. The
/// trampoline embeds the function index (the `call_id` parameter) as a constant and delegates to
/// a stub function in Rust, which takes the function index and a memory reference to the stack
/// arguments and return value slots.
///
/// This code is taken entirely from wasmtime's wasmtime-api/src/trampoline/func.rs. It is
/// deliberately not modified to improve readability in this code base in order to simplify diffs
/// with the upstream code and updates. We do, however, insert additional comments beginning with
/// "NOTE:" for clarity when helpful.
pub fn make_trampoline(
isa: &dyn isa::TargetIsa,
code_memory: &mut CodeMemory,
Expand Down Expand Up @@ -152,6 +161,10 @@ pub fn make_trampoline(
// Add error/trap return.
stub_sig.returns.push(ir::AbiParam::new(ir::types::I32));

// NOTE: Each parameter and return value gets a 64-bit (8-byte) wide slot on the stack, as that
// is large enough to fit all Wasm primitive types. The `VMContext` pointer, which is a
// parameter the function signature, is excluded as it is passed directly to the stub function,
// rather than being looked up on the caller stack from the `values_vec` pointer.
let values_vec_len = 8 * cmp::max(signature.params.len() - 1, signature.returns.len()) as u32;

let mut context = Context::new();
Expand Down