Skip to content
Merged
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions wasmtime-jit/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,18 @@ impl Compiler {
})
}

/// Create and publish a trampoline for invoking a function.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment to get_trampoline mentioning that the code it returns needs to be published (with publish_compiled_code) before it can be executed, and pointing to get_published_trampoline as a way to have this done automatically?

And, we should mention that calling get_published_trampoline many times will use memory inefficiently, because publishing between each trampoline creation means we'll use a whole page for each trampoline. When feasible, it's preferable to create all the trampolines (with get_trampoline) first, and then call publish_compiled_code once.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, looking at this more, get_trampoline and publish_compiled_code are not public functions, so these comments wouldn't immediately make sense. I think this is a symptom of cranelift-jit not being entirely clear about what level of API it wants to be. Hopefully we'll sort all this out with the new APIs.

pub fn get_published_trampoline(
&mut self,
callee_address: *const VMFunctionBody,
signature: &ir::Signature,
value_size: usize,
) -> Result<*const VMFunctionBody, SetupError> {
let result = self.get_trampoline(callee_address, signature, value_size)?;
self.publish_compiled_code();
Ok(result)
}

/// Make memory containing compiled code executable.
pub(crate) fn publish_compiled_code(&mut self) {
self.code_memory.publish();
Expand Down