wareya opened issue #6677:
Feature
I want
get_finalized_function
in cranelift_jit's JITModule to return both the pointer and size to JIT'd functions, likeget_finalized_data
does for data object.Benefit
This would allow me to disassemble individual compiled functions without having to guess at their size, making it easier for me to debug my compiler. Right now I dump them to standard output one byte at a time until my test program segfaults and manually locate the true end of the function code, which is unsustainable.
Implementation
get_finalized_data
already works this way and seems to deal with the same type (CompiledBlob
), so it should basically amount to copying that.Alternatives
Adding a second function for getting the size would also work, but then the API would be inconsistent with itself.
cfallin commented on issue #6677:
cc @bjorn3 for more thoughts, but on the surface this seems totally reasonable to me...
bjorn3 commented on issue #6677:
Right after calling
.define_function()
you can usecontext.compiled_code().unwrap().disassemble()
to get a disassembled version of the function. You can also usecontext.compiled_code().unwrap().code_info().total_size
to get the function length if you want to disassemble yourself.If that isn't enough for your use case, adding a length return value to get_finalized_function should be fine I guess. It would just be a bit noisy for the common case as you almost never need to know the size of a function. Just the address where you can call it.
wareya commented on issue #6677:
That works, thank you. It's strange, though, I wouldn't have been able to figure that out on my own - I can't find CompiledCodeBase in the documentation, neither on docs.rs nor on docs.wasmtime.dev. Is something keeping it from showing up?
bjorn3 commented on issue #6677:
While
CompiledCodeBase
is marked as public, it is in a private module and not directly re-exported, so rustdoc doesn't render it.
wareya commented on issue #6677:
Makes sense. Thanks!
Last updated: Nov 22 2024 at 16:03 UTC