diff options
author | Johannes Stoelp <johannes.stoelp@gmail.com> | 2024-12-19 18:30:19 +0100 |
---|---|---|
committer | Johannes Stoelp <johannes.stoelp@gmail.com> | 2024-12-19 18:30:19 +0100 |
commit | b58d4b034ad372e13384179721fb345a51febfce (patch) | |
tree | e84e4707560910b21e0c7262f5fcc654aed6c88b /examples/fib.rs | |
parent | 40bcea9b225cd5936d14715e8f3cb8dc366baece (diff) | |
download | juicebox-asm-b58d4b034ad372e13384179721fb345a51febfce.tar.gz juicebox-asm-b58d4b034ad372e13384179721fb345a51febfce.zip |
example: use Runtime::dump rather than writing bytes out by hand
Diffstat (limited to 'examples/fib.rs')
-rw-r--r-- | examples/fib.rs | 11 |
1 files changed, 5 insertions, 6 deletions
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::<extern "C" fn(u64) -> u64>(code) }; + let fib = unsafe { rt.add_code::<extern "C" fn(u64) -> 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); |