| 115 | } |
| 116 | |
| 117 | pub fn compile<C: bytecode::Constant>( |
| 118 | bytecode: &bytecode::CodeObject<C>, |
| 119 | args: &[JitType], |
| 120 | ret: Option<JitType>, |
| 121 | ) -> Result<CompiledCode, JitCompileError> { |
| 122 | let mut jit = Jit::new(); |
| 123 | |
| 124 | let (id, sig) = jit.build_function(bytecode, args, ret)?; |
| 125 | |
| 126 | jit.module.finalize_definitions()?; |
| 127 | |
| 128 | let code = jit.module.get_finalized_function(id); |
| 129 | Ok(CompiledCode { |
| 130 | sig, |
| 131 | code, |
| 132 | module: ManuallyDrop::new(jit.module), |
| 133 | }) |
| 134 | } |
| 135 | |
| 136 | pub struct CompiledCode { |
| 137 | sig: JitSig, |