From b58d4b034ad372e13384179721fb345a51febfce Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Thu, 19 Dec 2024 18:30:19 +0100 Subject: example: use Runtime::dump rather than writing bytes out by hand --- examples/fib.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'examples/fib.rs') diff --git a/examples/fib.rs b/examples/fib.rs index b495067..c38589f 100644 --- a/examples/fib.rs +++ b/examples/fib.rs @@ -62,14 +62,13 @@ fn main() { asm.bind(&mut end); asm.ret(); - // Write out JIT code for visualization. - // Disassemble for example with `ndisasm -b 64 jit.asm`. - let code = asm.into_code(); - std::fs::write("jit.asm", &code).unwrap(); - // Move code into executable page and get function pointer to it. let mut rt = Runtime::new(); - let fib = unsafe { rt.add_code:: u64>(code) }; + let fib = unsafe { rt.add_code:: u64>(asm.into_code()) }; + + // Write out JIT code for visualization. + // Disassemble for example with `ndisasm -b 64 jit.asm`. + rt.dump(); for n in 0..15 { let fib_jit = fib(n); -- cgit v1.2.3