diff --git a/rts/motoko-rts/src/persistence.rs b/rts/motoko-rts/src/persistence.rs index f7428393ab5..eb45fa8672d 100644 --- a/rts/motoko-rts/src/persistence.rs +++ b/rts/motoko-rts/src/persistence.rs @@ -222,7 +222,6 @@ pub unsafe fn assign_stable_type( (*metadata).stable_type.assign(mem, &new_type); } - pub(crate) unsafe fn stable_type_descriptor() -> &'static mut TypeDescriptor { let metadata = PersistentMetadata::get(); &mut (*metadata).stable_type diff --git a/src/codegen/compile_classical.ml b/src/codegen/compile_classical.ml index a16282ca4db..1061c7d344a 100644 --- a/src/codegen/compile_classical.ml +++ b/src/codegen/compile_classical.ml @@ -11616,6 +11616,15 @@ and compile_prim_invocation (env : E.t) ae p es at = SR.Vanilla, StableMem.get_mem_size env ^^ BigNum.from_word64 env + | OtherPrim "rts_in_install", [] -> (* classical specific *) + assert (not !Flags.enhanced_orthogonal_persistence); + SR.Vanilla, + StableMem.stable64_size env ^^ + G.i (Test (Wasm_exts.Values.I64 I64Op.Eqz)) ^^ + G.if1 I32Type + (Bool.lit true) + (Bool.lit false) + (* Regions *) | OtherPrim "regionNew", [] -> diff --git a/src/codegen/compile_enhanced.ml b/src/codegen/compile_enhanced.ml index 36d6990e487..b6addc1291b 100644 --- a/src/codegen/compile_enhanced.ml +++ b/src/codegen/compile_enhanced.ml @@ -8757,6 +8757,7 @@ module EnhancedOrthogonalPersistence = struct let initialize env actor_type = register_stable_type env actor_type + end (* EnhancedOrthogonalPersistence *) (* As fallback when doing persistent memory layout changes. *) @@ -11684,6 +11685,15 @@ and compile_prim_invocation (env : E.t) ae p es at = SR.Vanilla, StableMem.get_mem_size env ^^ BigNum.from_word64 env + | OtherPrim "rts_in_install", [] -> (* EOP specific *) + assert (!Flags.enhanced_orthogonal_persistence); + SR.Vanilla, + EnhancedOrthogonalPersistence.load_stable_actor env ^^ + compile_test I64Op.Eqz ^^ + E.if1 I64Type + (Bool.lit true) + (Bool.lit false) + (* Regions *) | OtherPrim "regionNew", [] -> @@ -12258,9 +12268,11 @@ and compile_prim_invocation (env : E.t) ae p es at = | ICStableRead ty, [] -> SR.Vanilla, + (* IC.compile_static_print env ("ICStableRead" ^ Type.string_of_typ ty) ^^ *) Persistence.load env ty | ICStableWrite ty, [] -> SR.unit, + (* IC.compile_static_print env ("ICStableWrite" ^ Type.string_of_typ ty) ^^ *) Persistence.save env ty (* Cycles *) diff --git a/src/ir_def/construct.ml b/src/ir_def/construct.ml index 7d0c53177b3..bca8c8af216 100644 --- a/src/ir_def/construct.ml +++ b/src/ir_def/construct.ml @@ -129,6 +129,7 @@ let primE prim es = | OtherPrim "rts_max_stack_size" -> T.nat | OtherPrim "rts_callback_table_count" -> T.nat | OtherPrim "rts_callback_table_size" -> T.nat + | OtherPrim "rts_in_install" -> T.bool | _ -> assert false (* implement more as needed *) in let eff = map_max_effs eff es in diff --git a/src/lowering/desugar.ml b/src/lowering/desugar.ml index 6a9405dcce5..f77eb62963d 100644 --- a/src/lowering/desugar.ml +++ b/src/lowering/desugar.ml @@ -575,9 +575,7 @@ and build_actor at ts exp_opt self_id es obj_typ = let v_dom = fresh_var "v_dom" dom in let v_rng = fresh_var "v_rng" rng in I.{pre = ty'; post = ty}, - ifE (primE (Ir.RelPrim (T.nat, Operator.EqOp)) [ - primE (I.OtherPrim "rts_stable_memory_size") []; - natE Numerics.Nat.zero]) + ifE (primE (I.OtherPrim "rts_in_install") []) (primE (I.ICStableRead ty) []) (letE v (primE (I.ICStableRead ty') []) (letE v_dom