Short version: What is the overhead of a cranelift::JITModule ? Can we afford to have one per function ?
I'm referring to wasmtime/backend.rs at e6f399419c60c0306d13e39c2f955090f7da943f · bytecodealliance/wasmtime · GitHub , but size-of may not be accurate as there may be dynamically allocated stuff JITModule::new() creates
When we use cranelift as a JIT backend, we need to call
get_finalized_function to get the actual function. I believe this results in a memory leak unless we call JITModule::free_memory. See: wasmtime/backend.rs at e6f399419c60c0306d13e39c2f955090f7da943f · bytecodealliance/wasmtime · GitHub
The issue here is that JITModule::free_memory appears to nuke the entire module, and there is no way to free an individual function.
Therefore, I am considering having a JITModule per JIT-ted function. Thus, the question: how expensive is as JITModule, and can we afford to have one per JIT-ted function ?