Skip to content

Commit

Permalink
Implement dynamic runtime for pedersen with jit
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianGCalderon committed Jan 14, 2025
1 parent 5826296 commit 76e49df
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/executor/jit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,24 @@ impl<'m> JitNativeExecutor<'m> {
mut metadata,
} = native_module;

Ok(Self {
let executor = Self {
engine: create_engine(&module, &metadata, opt_level),
module,
registry,
gas_metadata: metadata.remove().ok_or(Error::MissingMetadata)?,
dict_overrides: metadata.remove().unwrap_or_default(),
})
};

if let Some(pedersen_global) = executor.find_symbol_ptr("cairo_native_2_libfunc__pedersen")
{
let pedersen_global = pedersen_global.cast::<*const ()>();
unsafe {
*pedersen_global =
cairo_native_runtime::cairo_native__libfunc__pedersen as *const ()
};
}

Ok(executor)
}

pub const fn program_registry(&self) -> &ProgramRegistry<CoreType, CoreLibfunc> {
Expand Down
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ pub fn register_runtime_symbols(engine: &ExecutionEngine) {
);

engine.register_symbol(
"cairo_native__libfunc__pedersen",
"cairo_native_2_libfunc__pedersen",
cairo_native_runtime::cairo_native__libfunc__pedersen
as *const fn(*mut u8, *mut u8, *mut u8) -> () as *mut (),
);
Expand Down

0 comments on commit 76e49df

Please sign in to comment.