MarinPostma opened PR #9919 from MarinPostma:jit-module-return-code-slice
to bytecodealliance:main
:
It can be usefull to get the compiled function as a slice from a
JITModule
, for example, if one wants to disassemble it, to inspect the assembled code. It is currently possible to get pseudo assembly from the module context, by explicitely requestingctx.want_disasm
, but it is not very practical and it is not the _actual_ machine code.
MarinPostma requested fitzgen for a review on PR #9919.
MarinPostma requested wasmtime-compiler-reviewers for a review on PR #9919.
MarinPostma requested wasmtime-core-reviewers for a review on PR #9919.
MarinPostma updated PR #9919.
MarinPostma updated PR #9919.
MarinPostma updated PR #9919.
If you want the actual machine code you can already find it in
context.compiled_code().unwrap().buffer.data()
after you usedefine_function
. You can also find all relocations incontext.compiled_code().unwrap().buffer.relocs()
to know which functions you are actually calling. cranelift-jit throws all relocations away after applying them as it doesn't need them anymore after applying them.
MarinPostma commented on PR #9919:
@bjorn3 but that's only for the current function no? Is there a way to get the buffer for any function in a module?
Yeah, you have to do that right after calling define_function for the function which you want machine code for.
MarinPostma commented on PR #9919:
I'll close then :+1:
MarinPostma closed without merge PR #9919.
Last updated: Jan 24 2025 at 00:11 UTC