From: fennecdjay Date: Fri, 28 Oct 2022 06:54:19 +0000 (+0200) Subject: :art: StructRelease instruction X-Git-Tag: nightly~207^2~103 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=0a58a8ff31995b0b06d2a5cc372150fc2a7d8d8d;p=gwion.git :art: StructRelease instruction --- diff --git a/include/opcode.h b/include/opcode.h index e34d3820..4aa75b97 100644 --- a/include/opcode.h +++ b/include/opcode.h @@ -181,6 +181,8 @@ enum { eAssign, eObjectRelease, eObjectRelease2, + eStructReleaseRegAddr, + eStructReleaseMem, eGWOP_EXCEPT, eAllocMember4, eDotMemberMem, @@ -216,219 +218,221 @@ enum { eOP_MAX, }; -#define RegSetImm (f_instr)eRegSetImm -#define RegPushImm (f_instr)eRegPushImm -#define RegPushImm2 (f_instr)eRegPushImm2 -#define RegPushImm3 (f_instr)eRegPushImm3 -#define RegPushImm4 (f_instr)eRegPushImm4 -#define RegPushMem (f_instr)eRegPushMem -#define RegPushMem2 (f_instr)eRegPushMem2 -#define RegPushMem3 (f_instr)eRegPushMem3 -#define RegPushMem4 (f_instr)eRegPushMem4 -#define RegPushMemDeref (f_instr)eRegPushMemDeref -#define RegPushNow (f_instr)eRegPushNow -#define RegPushBase (f_instr)eRegPushBase -#define RegPushBase2 (f_instr)eRegPushBase2 -#define RegPushBase3 (f_instr)eRegPushBase3 -#define RegPushBase4 (f_instr)eRegPushBase4 -#define Reg2Reg (f_instr)eReg2Reg -#define Reg2RegOther (f_instr)eReg2RegOther -#define Reg2RegAddr (f_instr)eReg2RegAddr -#define Reg2RegDeref (f_instr)eReg2RegDeref -#define StructMember (f_instr)eStructMember -#define StructMemberFloat (f_instr)eStructMemberFloat -#define StructMemberOther (f_instr)eStructMemberOther -#define StructMemberAddr (f_instr)eStructMemberAddr -#define MemSetImm (f_instr)eMemSetImm -#define MemAddImm (f_instr)eMemAddImm -#define RepeatIdx (f_instr)eRepeatIdx -#define Repeat (f_instr)eRepeat -#define RegPushMe (f_instr)eRegPushMe -#define RegPushMaybe (f_instr)eRegPushMaybe -#define FuncReturn (f_instr)eFuncReturn -#define Goto (f_instr)eGoto -#define AllocWord (f_instr)eAllocWord -#define AllocWord2 (f_instr)eAllocWord2 -#define AllocWord3 (f_instr)eAllocWord3 -#define int_add (f_instr)eint_add -#define int_sub (f_instr)eint_sub -#define int_mul (f_instr)eint_mul -#define int_div (f_instr)eint_div -#define int_mod (f_instr)eint_mod -#define int_add_imm (f_instr)eint_add_imm -#define int_sub_imm (f_instr)eint_sub_imm -#define int_mul_imm (f_instr)eint_mul_imm -#define int_div_imm (f_instr)eint_div_imm -#define int_mod_imm (f_instr)eint_mod_imm -#define int_eq (f_instr)eint_eq -#define int_neq (f_instr)eint_neq -#define int_and (f_instr)eint_and -#define int_or (f_instr)eint_or -#define int_gt (f_instr)eint_gt -#define int_ge (f_instr)eint_ge -#define int_lt (f_instr)eint_lt -#define int_le (f_instr)eint_le -#define int_gt_imm (f_instr)eint_gt_imm -#define int_ge_imm (f_instr)eint_ge_imm -#define int_lt_imm (f_instr)eint_lt_imm -#define int_le_imm (f_instr)eint_le_imm -#define int_sl (f_instr)eint_sl -#define int_sr (f_instr)eint_sr -#define int_sand (f_instr)eint_sand -#define int_sor (f_instr)eint_sor -#define int_xor (f_instr)eint_xor -#define int_negate (f_instr)eint_negate -#define IntNot (f_instr)eIntNot -#define int_cmp (f_instr)eint_cmp -#define int_r_assign (f_instr)eint_r_assign -#define int_r_plus (f_instr)eint_r_plus -#define int_r_minus (f_instr)eint_r_minus -#define int_r_mul (f_instr)eint_r_mul -#define int_r_div (f_instr)eint_r_div -#define int_r_modulo (f_instr)eint_r_modulo -#define int_r_sl (f_instr)eint_r_sl -#define int_r_sr (f_instr)eint_r_sr -#define int_r_sand (f_instr)eint_r_sand -#define int_r_sor (f_instr)eint_r_sor -#define int_r_sxor (f_instr)eint_r_sxor -#define int_pre_inc (f_instr)eint_pre_inc -#define int_pre_dec (f_instr)eint_pre_dec -#define int_post_inc (f_instr)eint_post_inc -#define int_post_dec (f_instr)eint_post_dec -#define float_add (f_instr)efloat_add -#define float_sub (f_instr)efloat_sub -#define float_mul (f_instr)efloat_mul -#define float_div (f_instr)efloat_div -#define float_add_imm (f_instr)efloat_add_imm -#define float_sub_imm (f_instr)efloat_sub_imm -#define float_mul_imm (f_instr)efloat_mul_imm -#define float_div_imm (f_instr)efloat_div_imm -#define float_and (f_instr)efloat_and -#define float_or (f_instr)efloat_or -#define float_eq (f_instr)efloat_eq -#define float_neq (f_instr)efloat_neq -#define float_gt (f_instr)efloat_gt -#define float_ge (f_instr)efloat_ge -#define float_lt (f_instr)efloat_lt -#define float_le (f_instr)efloat_le -#define float_gt_imm (f_instr)efloat_gt_imm -#define float_ge_imm (f_instr)efloat_ge_imm -#define float_lt_imm (f_instr)efloat_lt_imm -#define float_le_imm (f_instr)efloat_le_imm -#define float_negate (f_instr)efloat_negate -#define float_not (f_instr)efloat_not -#define float_r_assign (f_instr)efloat_r_assign -#define float_r_plus (f_instr)efloat_r_plus -#define float_r_minus (f_instr)efloat_r_minus -#define float_r_mul (f_instr)efloat_r_mul -#define float_r_div (f_instr)efloat_r_div -#define int_float_plus (f_instr)eint_float_plus -#define int_float_minus (f_instr)eint_float_minus -#define int_float_mul (f_instr)eint_float_mul -#define int_float_div (f_instr)eint_float_div -#define int_float_and (f_instr)eint_float_and -#define int_float_or (f_instr)eint_float_or -#define int_float_eq (f_instr)eint_float_eq -#define int_float_neq (f_instr)eint_float_neq -#define int_float_gt (f_instr)eint_float_gt -#define int_float_ge (f_instr)eint_float_ge -#define int_float_lt (f_instr)eint_float_lt -#define int_float_le (f_instr)eint_float_le -#define int_float_r_assign (f_instr)eint_float_r_assign -#define int_float_r_plus (f_instr)eint_float_r_plus -#define int_float_r_minus (f_instr)eint_float_r_minus -#define int_float_r_mul (f_instr)eint_float_r_mul -#define int_float_r_div (f_instr)eint_float_r_div -#define float_int_plus (f_instr)efloat_int_plus -#define float_int_minus (f_instr)efloat_int_minus -#define float_int_mul (f_instr)efloat_int_mul -#define float_int_div (f_instr)efloat_int_div -#define float_int_and (f_instr)efloat_int_and -#define float_int_or (f_instr)efloat_int_or -#define float_int_eq (f_instr)efloat_int_eq -#define float_int_neq (f_instr)efloat_int_neq -#define float_int_gt (f_instr)efloat_int_gt -#define float_int_ge (f_instr)efloat_int_ge -#define float_int_lt (f_instr)efloat_int_lt -#define float_int_le (f_instr)efloat_int_le -#define float_int_r_assign (f_instr)efloat_int_r_assign -#define float_int_r_plus (f_instr)efloat_int_r_plus -#define float_int_r_minus (f_instr)efloat_int_r_minus -#define float_int_r_mul (f_instr)efloat_int_r_mul -#define float_int_r_div (f_instr)efloat_int_r_div -#define CastI2F (f_instr)eCastI2F -#define CastF2I (f_instr)eCastF2I -#define Time_Advance (f_instr)eTime_Advance -#define Recurs (f_instr)eRecurs -#define SetCode (f_instr)eSetCode -#define RegMove (f_instr)eRegMove -#define Reg2Mem (f_instr)eReg2Mem -#define Reg2Mem4 (f_instr)eReg2Mem4 -#define Overflow (f_instr)eOverflow -#define FuncUsrEnd (f_instr)eFuncUsrEnd -#define FuncUsrEnd2 (f_instr)eFuncUsrEnd2 -#define FuncMemberEnd (f_instr)eFuncMemberEnd -#define SporkIni (f_instr)eSporkIni -#define ForkIni (f_instr)eForkIni -#define SporkFunc (f_instr)eSporkFunc -#define SporkExp (f_instr)eSporkExp -#define SporkCode (f_instr)eSporkCode -#define ForkEnd (f_instr)eForkEnd -#define SporkEnd (f_instr)eSporkEnd -#define BranchEqInt (f_instr)eBranchEqInt -#define BranchNeqInt (f_instr)eBranchNeqInt -#define BranchEqFloat (f_instr)eBranchEqFloat -#define BranchNeqFloat (f_instr)eBranchNeqFloat -#define Unroll (f_instr)eUnroll -#define ArrayAppend (f_instr)eArrayAppend -#define AutoUnrollInit (f_instr)eAutoUnrollInit -#define AutoLoop (f_instr)eAutoLoop -#define ArrayTop (f_instr)eArrayTop -#define ArrayAccess (f_instr)eArrayAccess -#define ArrayGet (f_instr)eArrayGet -#define ArrayAddr (f_instr)eArrayAddr -#define ObjectInstantiate (f_instr)eObjectInstantiate -#define RegAddRef (f_instr)eRegAddRef -#define RegAddRefAddr (f_instr)eRegAddRefAddr -#define StructRegAddRef (f_instr)eStructRegAddRef -#define StructRegAddRefAddr (f_instr)eStructRegAddRefAddr -#define ObjectAssign (f_instr)eObjectAssign -#define Assign (f_instr)eAssign -#define ObjectRelease (f_instr)eObjectRelease -#define ObjectRelease2 (f_instr)eObjectRelease2 -#define GWOP_EXCEPT (f_instr)eGWOP_EXCEPT -#define AllocMember4 (f_instr)eAllocMember4 -#define DotMemberMem (f_instr)eDotMemberMem -#define DotMemberMem2 (f_instr)eDotMemberMem2 -#define DotMemberMem4 (f_instr)eDotMemberMem4 -#define DotMember (f_instr)eDotMember -#define DotMember2 (f_instr)eDotMember2 -#define DotMember3 (f_instr)eDotMember3 -#define DotMember4 (f_instr)eDotMember4 -#define UnionCheck (f_instr)eUnionCheck -#define UnionMember (f_instr)eUnionMember -#define UnionMember2 (f_instr)eUnionMember2 -#define UnionMember3 (f_instr)eUnionMember3 -#define UnionMember4 (f_instr)eUnionMember4 -#define DotStatic (f_instr)eDotStatic -#define DotStatic2 (f_instr)eDotStatic2 -#define DotStatic3 (f_instr)eDotStatic3 -#define DotFunc (f_instr)eDotFunc -#define GackType (f_instr)eGackType -#define GackEnd (f_instr)eGackEnd -#define Gack (f_instr)eGack -#define TryIni (f_instr)eTryIni -#define TryEnd (f_instr)eTryEnd -#define HandleEffect (f_instr)eHandleEffect -#define PerformEffect (f_instr)ePerformEffect -#define NoOp (f_instr)eNoOp -#define DebugLine (f_instr)eDebugLine -#define DebugValue (f_instr)eDebugValue -#define DebugPush (f_instr)eDebugPush -#define DebugPop (f_instr)eDebugPop -#define EOC (f_instr)eEOC -#define VM_IN (f_instr)eVM_IN -#define OP_MAX (f_instr)eOP_MAX +#define RegSetImm (f_instr)eRegSetImm +#define RegPushImm (f_instr)eRegPushImm +#define RegPushImm2 (f_instr)eRegPushImm2 +#define RegPushImm3 (f_instr)eRegPushImm3 +#define RegPushImm4 (f_instr)eRegPushImm4 +#define RegPushMem (f_instr)eRegPushMem +#define RegPushMem2 (f_instr)eRegPushMem2 +#define RegPushMem3 (f_instr)eRegPushMem3 +#define RegPushMem4 (f_instr)eRegPushMem4 +#define RegPushMemDeref (f_instr)eRegPushMemDeref +#define RegPushNow (f_instr)eRegPushNow +#define RegPushBase (f_instr)eRegPushBase +#define RegPushBase2 (f_instr)eRegPushBase2 +#define RegPushBase3 (f_instr)eRegPushBase3 +#define RegPushBase4 (f_instr)eRegPushBase4 +#define Reg2Reg (f_instr)eReg2Reg +#define Reg2RegOther (f_instr)eReg2RegOther +#define Reg2RegAddr (f_instr)eReg2RegAddr +#define Reg2RegDeref (f_instr)eReg2RegDeref +#define StructMember (f_instr)eStructMember +#define StructMemberFloat (f_instr)eStructMemberFloat +#define StructMemberOther (f_instr)eStructMemberOther +#define StructMemberAddr (f_instr)eStructMemberAddr +#define MemSetImm (f_instr)eMemSetImm +#define MemAddImm (f_instr)eMemAddImm +#define RepeatIdx (f_instr)eRepeatIdx +#define Repeat (f_instr)eRepeat +#define RegPushMe (f_instr)eRegPushMe +#define RegPushMaybe (f_instr)eRegPushMaybe +#define FuncReturn (f_instr)eFuncReturn +#define Goto (f_instr)eGoto +#define AllocWord (f_instr)eAllocWord +#define AllocWord2 (f_instr)eAllocWord2 +#define AllocWord3 (f_instr)eAllocWord3 +#define int_add (f_instr)eint_add +#define int_sub (f_instr)eint_sub +#define int_mul (f_instr)eint_mul +#define int_div (f_instr)eint_div +#define int_mod (f_instr)eint_mod +#define int_add_imm (f_instr)eint_add_imm +#define int_sub_imm (f_instr)eint_sub_imm +#define int_mul_imm (f_instr)eint_mul_imm +#define int_div_imm (f_instr)eint_div_imm +#define int_mod_imm (f_instr)eint_mod_imm +#define int_eq (f_instr)eint_eq +#define int_neq (f_instr)eint_neq +#define int_and (f_instr)eint_and +#define int_or (f_instr)eint_or +#define int_gt (f_instr)eint_gt +#define int_ge (f_instr)eint_ge +#define int_lt (f_instr)eint_lt +#define int_le (f_instr)eint_le +#define int_gt_imm (f_instr)eint_gt_imm +#define int_ge_imm (f_instr)eint_ge_imm +#define int_lt_imm (f_instr)eint_lt_imm +#define int_le_imm (f_instr)eint_le_imm +#define int_sl (f_instr)eint_sl +#define int_sr (f_instr)eint_sr +#define int_sand (f_instr)eint_sand +#define int_sor (f_instr)eint_sor +#define int_xor (f_instr)eint_xor +#define int_negate (f_instr)eint_negate +#define IntNot (f_instr)eIntNot +#define int_cmp (f_instr)eint_cmp +#define int_r_assign (f_instr)eint_r_assign +#define int_r_plus (f_instr)eint_r_plus +#define int_r_minus (f_instr)eint_r_minus +#define int_r_mul (f_instr)eint_r_mul +#define int_r_div (f_instr)eint_r_div +#define int_r_modulo (f_instr)eint_r_modulo +#define int_r_sl (f_instr)eint_r_sl +#define int_r_sr (f_instr)eint_r_sr +#define int_r_sand (f_instr)eint_r_sand +#define int_r_sor (f_instr)eint_r_sor +#define int_r_sxor (f_instr)eint_r_sxor +#define int_pre_inc (f_instr)eint_pre_inc +#define int_pre_dec (f_instr)eint_pre_dec +#define int_post_inc (f_instr)eint_post_inc +#define int_post_dec (f_instr)eint_post_dec +#define float_add (f_instr)efloat_add +#define float_sub (f_instr)efloat_sub +#define float_mul (f_instr)efloat_mul +#define float_div (f_instr)efloat_div +#define float_add_imm (f_instr)efloat_add_imm +#define float_sub_imm (f_instr)efloat_sub_imm +#define float_mul_imm (f_instr)efloat_mul_imm +#define float_div_imm (f_instr)efloat_div_imm +#define float_and (f_instr)efloat_and +#define float_or (f_instr)efloat_or +#define float_eq (f_instr)efloat_eq +#define float_neq (f_instr)efloat_neq +#define float_gt (f_instr)efloat_gt +#define float_ge (f_instr)efloat_ge +#define float_lt (f_instr)efloat_lt +#define float_le (f_instr)efloat_le +#define float_gt_imm (f_instr)efloat_gt_imm +#define float_ge_imm (f_instr)efloat_ge_imm +#define float_lt_imm (f_instr)efloat_lt_imm +#define float_le_imm (f_instr)efloat_le_imm +#define float_negate (f_instr)efloat_negate +#define float_not (f_instr)efloat_not +#define float_r_assign (f_instr)efloat_r_assign +#define float_r_plus (f_instr)efloat_r_plus +#define float_r_minus (f_instr)efloat_r_minus +#define float_r_mul (f_instr)efloat_r_mul +#define float_r_div (f_instr)efloat_r_div +#define int_float_plus (f_instr)eint_float_plus +#define int_float_minus (f_instr)eint_float_minus +#define int_float_mul (f_instr)eint_float_mul +#define int_float_div (f_instr)eint_float_div +#define int_float_and (f_instr)eint_float_and +#define int_float_or (f_instr)eint_float_or +#define int_float_eq (f_instr)eint_float_eq +#define int_float_neq (f_instr)eint_float_neq +#define int_float_gt (f_instr)eint_float_gt +#define int_float_ge (f_instr)eint_float_ge +#define int_float_lt (f_instr)eint_float_lt +#define int_float_le (f_instr)eint_float_le +#define int_float_r_assign (f_instr)eint_float_r_assign +#define int_float_r_plus (f_instr)eint_float_r_plus +#define int_float_r_minus (f_instr)eint_float_r_minus +#define int_float_r_mul (f_instr)eint_float_r_mul +#define int_float_r_div (f_instr)eint_float_r_div +#define float_int_plus (f_instr)efloat_int_plus +#define float_int_minus (f_instr)efloat_int_minus +#define float_int_mul (f_instr)efloat_int_mul +#define float_int_div (f_instr)efloat_int_div +#define float_int_and (f_instr)efloat_int_and +#define float_int_or (f_instr)efloat_int_or +#define float_int_eq (f_instr)efloat_int_eq +#define float_int_neq (f_instr)efloat_int_neq +#define float_int_gt (f_instr)efloat_int_gt +#define float_int_ge (f_instr)efloat_int_ge +#define float_int_lt (f_instr)efloat_int_lt +#define float_int_le (f_instr)efloat_int_le +#define float_int_r_assign (f_instr)efloat_int_r_assign +#define float_int_r_plus (f_instr)efloat_int_r_plus +#define float_int_r_minus (f_instr)efloat_int_r_minus +#define float_int_r_mul (f_instr)efloat_int_r_mul +#define float_int_r_div (f_instr)efloat_int_r_div +#define CastI2F (f_instr)eCastI2F +#define CastF2I (f_instr)eCastF2I +#define Time_Advance (f_instr)eTime_Advance +#define Recurs (f_instr)eRecurs +#define SetCode (f_instr)eSetCode +#define RegMove (f_instr)eRegMove +#define Reg2Mem (f_instr)eReg2Mem +#define Reg2Mem4 (f_instr)eReg2Mem4 +#define Overflow (f_instr)eOverflow +#define FuncUsrEnd (f_instr)eFuncUsrEnd +#define FuncUsrEnd2 (f_instr)eFuncUsrEnd2 +#define FuncMemberEnd (f_instr)eFuncMemberEnd +#define SporkIni (f_instr)eSporkIni +#define ForkIni (f_instr)eForkIni +#define SporkFunc (f_instr)eSporkFunc +#define SporkExp (f_instr)eSporkExp +#define SporkCode (f_instr)eSporkCode +#define ForkEnd (f_instr)eForkEnd +#define SporkEnd (f_instr)eSporkEnd +#define BranchEqInt (f_instr)eBranchEqInt +#define BranchNeqInt (f_instr)eBranchNeqInt +#define BranchEqFloat (f_instr)eBranchEqFloat +#define BranchNeqFloat (f_instr)eBranchNeqFloat +#define Unroll (f_instr)eUnroll +#define ArrayAppend (f_instr)eArrayAppend +#define AutoUnrollInit (f_instr)eAutoUnrollInit +#define AutoLoop (f_instr)eAutoLoop +#define ArrayTop (f_instr)eArrayTop +#define ArrayAccess (f_instr)eArrayAccess +#define ArrayGet (f_instr)eArrayGet +#define ArrayAddr (f_instr)eArrayAddr +#define ObjectInstantiate (f_instr)eObjectInstantiate +#define RegAddRef (f_instr)eRegAddRef +#define RegAddRefAddr (f_instr)eRegAddRefAddr +#define StructRegAddRef (f_instr)eStructRegAddRef +#define StructRegAddRefAddr (f_instr)eStructRegAddRefAddr +#define ObjectAssign (f_instr)eObjectAssign +#define Assign (f_instr)eAssign +#define ObjectRelease (f_instr)eObjectRelease +#define ObjectRelease2 (f_instr)eObjectRelease2 +#define StructReleaseRegAddr (f_instr)eStructReleaseRegAddr +#define StructReleaseMem (f_instr)eStructReleaseMem +#define GWOP_EXCEPT (f_instr)eGWOP_EXCEPT +#define AllocMember4 (f_instr)eAllocMember4 +#define DotMemberMem (f_instr)eDotMemberMem +#define DotMemberMem2 (f_instr)eDotMemberMem2 +#define DotMemberMem4 (f_instr)eDotMemberMem4 +#define DotMember (f_instr)eDotMember +#define DotMember2 (f_instr)eDotMember2 +#define DotMember3 (f_instr)eDotMember3 +#define DotMember4 (f_instr)eDotMember4 +#define UnionCheck (f_instr)eUnionCheck +#define UnionMember (f_instr)eUnionMember +#define UnionMember2 (f_instr)eUnionMember2 +#define UnionMember3 (f_instr)eUnionMember3 +#define UnionMember4 (f_instr)eUnionMember4 +#define DotStatic (f_instr)eDotStatic +#define DotStatic2 (f_instr)eDotStatic2 +#define DotStatic3 (f_instr)eDotStatic3 +#define DotFunc (f_instr)eDotFunc +#define GackType (f_instr)eGackType +#define GackEnd (f_instr)eGackEnd +#define Gack (f_instr)eGack +#define TryIni (f_instr)eTryIni +#define TryEnd (f_instr)eTryEnd +#define HandleEffect (f_instr)eHandleEffect +#define PerformEffect (f_instr)ePerformEffect +#define NoOp (f_instr)eNoOp +#define DebugLine (f_instr)eDebugLine +#define DebugValue (f_instr)eDebugValue +#define DebugPush (f_instr)eDebugPush +#define DebugPop (f_instr)eDebugPop +#define EOC (f_instr)eEOC +#define VM_IN (f_instr)eVM_IN +#define OP_MAX (f_instr)eOP_MAX #ifndef __cplusplus ANN static inline void dump_opcodes(const VM_Code code) { gw_out("{Y}┏━━━━┓{0}{-Y} {+}%s{0}\n{Y}┃{0}\n", code->name); @@ -1259,6 +1263,18 @@ ANN static inline void dump_opcodes(const VM_Code code) { gw_out(" {-R}%-14p{0}", instr->m_val); gw_out("\n"); break; + case eStructReleaseRegAddr: + gw_out("{Y}┃{0}{-}% 4lu{0}: StructReleaseRegAddr", j); + gw_out(" {-R}%-14"UINT_F"{0}", instr->m_val); + gw_out(" {-B}%-14s"UINT_F"{0}", ((Type)instr->m_val2)->name); + gw_out("\n"); + break; + case eStructReleaseMem: + gw_out("{Y}┃{0}{-}% 4lu{0}: StructReleaseMem", j); + gw_out(" {-R}%-14"UINT_F"{0}", instr->m_val); + gw_out(" {-B}%-14s"UINT_F"{0}", ((Type)instr->m_val2)->name); + gw_out("\n"); + break; case eGWOP_EXCEPT: gw_out("{Y}┃{0}{-}% 4lu{0}: GWOP_EXCEPT ", j); gw_out(" {-R}%-14"UINT_F"{0}", instr->m_val); diff --git a/opcode.txt b/opcode.txt index 34b74530..3ec53bb4 100644 --- a/opcode.txt +++ b/opcode.txt @@ -178,6 +178,8 @@ ObjectAssign Assign ObjectRelease~u ObjectRelease2~p +StructReleaseRegAddr~u~t +StructReleaseMem~u~t GWOP_EXCEPT~u AllocMember4~u DotMemberMem~u diff --git a/src/emit/emit.c b/src/emit/emit.c index 8c4c7405..57f904ac 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -144,13 +144,9 @@ ANN void emit_compound_release(const Emitter emit, const Type t, const m_uint of ANN void emit_struct_release(const Emitter emit, const Type type, const m_uint offset) { - if (!type->info->tuple) return; - const Vector v = &type->info->tuple->types; - for (m_uint i = 0; i < vector_size(v); i++) { - const Type t = (Type)vector_at(v, i); - if (isa(t, emit->gwion->type[et_compound]) > 0) - emit_compound_release(emit, t, offset + vector_at(&type->info->tuple->offset, i)); - } + const Instr instr = emit_add_instr(emit, StructReleaseMem); + instr->m_val = offset; + instr->m_val2 = (m_uint)type; } ANN static m_bool emit_stmt(const Emitter emit, const Stmt stmt); diff --git a/src/lib/object.c b/src/lib/object.c index 23688de2..924c7c98 100644 --- a/src/lib/object.c +++ b/src/lib/object.c @@ -72,7 +72,7 @@ ANN void struct_release(const VM_Shred shred, const Type base, const Type t = (Type)vector_at(types, i); if (isa(t, shred->info->vm->gwion->type[et_compound]) < 0) continue; const m_uint offset = vector_at(offsets, i); - compound_release(shred, t, *(m_bit **)(ptr + offset)); + compound_release(shred, t, ptr + offset); } } diff --git a/src/parse/scan0.c b/src/parse/scan0.c index 2ecd4f2e..95a4ed9f 100644 --- a/src/parse/scan0.c +++ b/src/parse/scan0.c @@ -514,13 +514,6 @@ ANN static m_bool scan0_class_def_inner(const Env env, const Class_Def cdef) { return ret; } -ANN static m_bool reemit_and_release(const Emitter emit, const Exp e) { - exp_setvar(e, false); - CHECK_BB(emit_exp(emit, e)); - exp_setvar(e, true); - return GW_OK; -} - ANN Ast spread_class(const Env env, const Ast body); ANN static void exp_rewind(const Emitter emit, const uint32_t start) { @@ -536,10 +529,10 @@ static OP_EMIT(opem_struct_assign) { const Exp_Binary *bin = data; const Type t = bin->lhs->type; const Exp e = exp_self(bin); - CHECK_BB(reemit_and_release(emit, bin->rhs)); const Type rhs = bin->rhs->type; - emit_struct_release(emit, rhs, 0); - emit_regmove(emit, -rhs->size); + const Instr instr = emit_add_instr(emit, StructReleaseRegAddr); + instr->m_val = -rhs->size; + instr->m_val2 = (m_uint)t; if(unlikely(exp_getvar(e))) { exp_rewind(emit, e->start); const Vector v = &emit->code->instr; diff --git a/src/vm/vm.c b/src/vm/vm.c index fe130f5b..ca32fd26 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -459,7 +459,8 @@ vm_prepare(const VM *vm, m_bit *prepare_code) { // lgtm [cpp/use-of-goto] &&branchnefloat, &&unroll, &&arrayappend, &&autounrollinit, &&autoloop, &&arraytop, &&arrayaccess, &&arrayget, &&arrayaddr, &&newobj, &&addref, &&addrefaddr, &&structaddref, &&structaddrefaddr, &&objassign, &&assign, - &&remref, &&remref2, &&except, &&allocmemberaddr, + &&_remref, &&_remref2, &&_structreleaseregaddr, &&structreleasemem, + &&_except, &&_allocmemberaddr, &&dotmembermem, &&dotmembermem2, /*&&dotmembermem3, */&&dotmembermem4, &&dotmember, &&dotfloat, &&dotother, &&dotaddr, &&unioncheck, &&unionint, &&unionfloat, @@ -1080,6 +1081,10 @@ vm_prepare(const VM *vm, m_bit *prepare_code) { // lgtm [cpp/use-of-goto] release(*(M_Object *)(mem + vector_at(&v, i)), shred); } DISPATCH() + structreleaseregaddr: + struct_release(shred, (Type)VAL2, *(m_bit**)(reg + IVAL)); + structreleasemem: + struct_release(shred, (Type)VAL2, mem + IVAL); except: /* TODO: Refactor except instruction * * so that * @@ -1303,7 +1308,8 @@ static void *_dispatch[] = { &&_branchnefloat, &&_unroll, &&_arrayappend, &&_autounrollinit, &&_autoloop, &&_arraytop, &&_arrayaccess, &&_arrayget, &&_arrayaddr, &&_newobj, &&_addref, &&_addrefaddr, &&_structaddref, &&_structaddrefaddr, &&_objassign, &&_assign, - &&_remref, &&_remref2, &&_except, &&_allocmemberaddr, + &&_remref, &&_remref2, &&_structreleaseregaddr, &&_structreleasemem, + &&_except, &&_allocmemberaddr, &&_dotmembermem, &&_dotmembermem2, /*&&_dotmembermem3, */&&_dotmembermem4, &&_dotmember, &&_dotfloat, &&_dotother, &&_dotaddr, &&_unioncheck, &&_unionint, &&_unionfloat, @@ -1524,6 +1530,8 @@ return; PREPARE(assign); PREPARE(remref); PREPARE(remref2); + PREPARE(structreleaseregaddr); + PREPARE(structreleasemem); PREPARE(except); PREPARE(allocmemberaddr); PREPARE(dotmembermem);