pub fn new(
        canister_root: PathBuf,
        wasm_binary: Arc<WasmBinary>,
        exports: ExportedFunctions,
        wasm_memory: Memory,
        stable_memory: Memory,
        exported_globals: Vec<Global>,
    ) -> Self {
        let cow_mem_mgr = Arc::new(CowMemoryManagerImpl::open_readwrite(canister_root.clone()));
        if cow_state_feature::is_enabled(cow_state_feature::cow_state) {
            let mapped_state = cow_mem_mgr.get_map();
            let mut updated_pages = Vec::new();

            for i in wasm_memory.page_map.host_pages_iter() {
                let page_idx = i.0;
                updated_pages.push(page_idx.get());
                mapped_state
                    .update_heap_page(page_idx.get(), wasm_memory.page_map.get_page(page_idx));
            }
            mapped_state.soft_commit(&updated_pages);
        }
        let mapped_state = if cow_mem_mgr.is_valid() {
            Some(Arc::new(cow_mem_mgr.get_map()))
        } else {
            None
        };

        Self {
            canister_root,
            session_nonce: None,
            wasm_binary,
            exports,
            wasm_memory,
            stable_memory,
            exported_globals,
            metadata: WasmMetadata::default(),
            last_executed_round: ExecutionRound::from(0),
            cow_mem_mgr,
            mapped_state,
        }
    }
/// Initializes a new execution state for a canister.
/// The state will be created with empty stable memory, but may have wasm
/// memory from data sections in the wasm module.
Initializes a new execution state for a canister.
The state will be created with empty stable memory, but may have wasm
memory from data sections in the wasm module.
Initializes a new execution state for a canister . The state will be created with empty stable memory but may have wasm memory from data sections in the wasm module .
pub fn new(
        canister_root: PathBuf,
        wasm_binary: Arc<WasmBinary>,
        exports: ExportedFunctions,
        wasm_memory: Memory,
        stable_memory: Memory,
        exported_globals: Vec<Global>,
    ) -> Self {
        let cow_mem_mgr = Arc::new(CowMemoryManagerImpl::open_readwrite(canister_root.clone()));
        if cow_state_feature::is_enabled(cow_state_feature::cow_state) {
            let mapped_state = cow_mem_mgr.get_map();
            let mut updated_pages = Vec::new();
            for i in wasm_memory.page_map.host_pages_iter() {
                let page_idx = i.0;
                updated_pages.push(page_idx.get());
                mapped_state
                    .update_heap_page(page_idx.get(), wasm_memory.page_map.get_page(page_idx));
            }
            mapped_state.soft_commit(&updated_pages);
        }
        let mapped_state = if cow_mem_mgr.is_valid() {
            Some(Arc::new(cow_mem_mgr.get_map()))
        } else {
            None
        };
        Self {
            canister_root,
            session_nonce: None,
            wasm_binary,
            exports,
            wasm_memory,
            stable_memory,
            exported_globals,
            metadata: WasmMetadata::default(),
            last_executed_round: ExecutionRound::from(0),
            cow_mem_mgr,
            mapped_state,
        }
    }
pub fn new ( canister_root : PathBuf , wasm_binary : Arc < WasmBinary > , exports : ExportedFunctions , wasm_memory : Memory , stable_memory : Memory , exported_globals : Vec < Global > , ) -> Self { let cow_mem_mgr = Arc :: new ( CowMemoryManagerImpl :: open_readwrite ( canister_root . clone ( ) ) ) ; if cow_state_feature :: is_enabled ( cow_state_feature :: cow_state ) { let mapped_state = cow_mem_mgr . get_map ( ) ; let mut updated_pages = Vec :: new ( ) ; for i in wasm_memory . page_map . host_pages_iter ( ) { let page_idx = i . 0 ; updated_pages . push ( page_idx . get ( ) ) ; mapped_state . update_heap_page ( page_idx . get ( ) , wasm_memory . page_map . get_page ( page_idx ) ) ; } mapped_state . soft_commit ( & updated_pages ) ; } let mapped_state = if cow_mem_mgr . is_valid ( ) { Some ( Arc :: new ( cow_mem_mgr . get_map ( ) ) ) } else { None } ; Self { canister_root , session_nonce : None , wasm_binary , exports , wasm_memory , stable_memory , exported_globals , metadata : WasmMetadata :: default ( ) , last_executed_round : ExecutionRound :: from ( 0 ) , cow_mem_mgr , mapped_state , } }
Initializes a new execution state for a canister.
Initializes a new execution state for a canister .
canister_root
PathBuf
wasm_binary
Arc<WasmBinary>
exports
ExportedFunctions
wasm_memory
Memory
stable_memory
Memory
exported_globals
Vec<Global>
canister_root
PathBuf
wasm_binary
Arc<WasmBinary>
exports
ExportedFunctions
wasm_memory
Memory
stable_memory
Memory
exported_globals
Vec<Global>