@@ -2,7 +2,11 @@ use std::borrow::Cow;
22use std:: ops:: Deref ;
33use std:: sync:: Arc ;
44
5- use cairo_native:: executor:: AotContractExecutor ;
5+ #[ cfg( feature = "with-libfunc-profiling" ) ]
6+ use cairo_native:: executor:: AotWithProgram ;
7+ #[ cfg( feature = "sierra-emu" ) ]
8+ use cairo_native:: executor:: EmuContractInfo ;
9+ use cairo_native:: executor:: { AotContractExecutor , ContractExecutor } ;
610use starknet_api:: contract_class:: compiled_class_hash:: HashableCompiledClass ;
711use starknet_api:: core:: EntryPointSelector ;
812use starknet_types_core:: felt:: Felt ;
@@ -30,7 +34,28 @@ impl NativeCompiledClassV1 {
3034 /// executor must be derived from sierra_program which in turn must be derived from
3135 /// sierra_contract_class.
3236 pub fn new ( executor : AotContractExecutor , casm : CompiledClassV1 ) -> NativeCompiledClassV1 {
33- let contract = NativeCompiledClassV1Inner :: new ( executor, casm) ;
37+ let contract = NativeCompiledClassV1Inner :: new ( executor. into ( ) , casm) ;
38+
39+ Self ( Arc :: new ( contract) )
40+ }
41+
42+ /// Initialize a compiled class backed by the sierra-emu interpreter instead of the AOT
43+ /// executor. Used by benchmarking / replay tooling that wants to execute through the emu
44+ /// VM while reusing the rest of the blockifier pipeline.
45+ #[ cfg( feature = "sierra-emu" ) ]
46+ pub fn new_from_emu ( info : EmuContractInfo , casm : CompiledClassV1 ) -> NativeCompiledClassV1 {
47+ let contract = NativeCompiledClassV1Inner :: new ( info. into ( ) , casm) ;
48+
49+ Self ( Arc :: new ( contract) )
50+ }
51+
52+ /// Like [`Self::new`], but also stores the Sierra `Program` (via the cairo-native
53+ /// [`AotWithProgram`] pairing) so [`cairo_native::ContractExecutor::run_with_profile`]
54+ /// can resolve libfunc samples. Only callable when the `with-libfunc-profiling`
55+ /// feature is enabled.
56+ #[ cfg( feature = "with-libfunc-profiling" ) ]
57+ pub fn new_with_program ( info : AotWithProgram , casm : CompiledClassV1 ) -> NativeCompiledClassV1 {
58+ let contract = NativeCompiledClassV1Inner :: new ( info. into ( ) , casm) ;
3459
3560 Self ( Arc :: new ( contract) )
3661 }
@@ -71,12 +96,12 @@ impl HashableCompiledClass<EntryPointV1, NestedFeltCounts> for NativeCompiledCla
7196
7297#[ derive( Debug ) ]
7398pub struct NativeCompiledClassV1Inner {
74- pub executor : AotContractExecutor ,
99+ pub executor : ContractExecutor ,
75100 casm : CompiledClassV1 ,
76101}
77102
78103impl NativeCompiledClassV1Inner {
79- fn new ( executor : AotContractExecutor , casm : CompiledClassV1 ) -> Self {
104+ fn new ( executor : ContractExecutor , casm : CompiledClassV1 ) -> Self {
80105 NativeCompiledClassV1Inner { executor, casm }
81106 }
82107}
0 commit comments