aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2023-12-05 00:55:50 +0100
committerJohannes Stoelp <johannes.stoelp@gmail.com>2023-12-05 00:55:50 +0100
commit4a80838151a9945438739ab937c415939e2ccf5b (patch)
tree6e3fe2a355c2703e1a1401a88c3ee1ebcbb1819a /examples
parent474c2545cbb1af85a326a47e202fe1e6c450b496 (diff)
downloadjuicebox-asm-4a80838151a9945438739ab937c415939e2ccf5b.tar.gz
juicebox-asm-4a80838151a9945438739ab937c415939e2ccf5b.zip
rt: extend runtime to allow adding multiple code blocks
Diffstat (limited to 'examples')
-rw-r--r--examples/add.rs4
-rw-r--r--examples/fib.rs4
2 files changed, 4 insertions, 4 deletions
diff --git a/examples/add.rs b/examples/add.rs
index ef010b6..8cd1984 100644
--- a/examples/add.rs
+++ b/examples/add.rs
@@ -22,8 +22,8 @@ fn main() {
let code = asm.into_code();
std::fs::write("jit.asm", &code).unwrap();
- let rt = Runtime::new(&code);
- let add42 = unsafe { rt.as_fn::<extern "C" fn(u32) -> u32>() };
+ let mut rt = Runtime::new();
+ let add42 = unsafe { rt.add_code::<extern "C" fn(u32) -> u32>(code) };
let res = add42(5);
assert_eq!(res, 47);
diff --git a/examples/fib.rs b/examples/fib.rs
index 7acbb50..534dc13 100644
--- a/examples/fib.rs
+++ b/examples/fib.rs
@@ -62,8 +62,8 @@ fn main() {
std::fs::write("jit.asm", &code).unwrap();
// Move code into executable page and get function pointer to it.
- let rt = Runtime::new(&code);
- let fib = unsafe { rt.as_fn::<extern "C" fn(u64) -> u64>() };
+ let mut rt = Runtime::new();
+ let fib = unsafe { rt.add_code::<extern "C" fn(u64) -> u64>(code) };
for n in 0..15 {
let fib_jit = fib(n);