eObjectInstantiate,
eRegAddRef,
eRegAddRefAddr,
+ eStructRegAddRef,
+ eStructRegAddRefAddr,
eObjectAssign,
eAssign,
eObjectRelease,
eDotTmplVal,
};
-#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 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_plus (f_instr)eint_plus
-#define int_minus (f_instr)eint_minus
-#define int_mul (f_instr)eint_mul
-#define int_div (f_instr)eint_div
-#define int_modulo (f_instr)eint_modulo
-#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_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 FloatPlus (f_instr)eFloatPlus
-#define FloatMinus (f_instr)eFloatMinus
-#define FloatTimes (f_instr)eFloatTimes
-#define FloatDivide (f_instr)eFloatDivide
-#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_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 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 FuncMemberEnd (f_instr)eFuncMemberEnd
-#define SporkIni (f_instr)eSporkIni
-#define ForkIni (f_instr)eForkIni
-#define SporkFunc (f_instr)eSporkFunc
-#define SporkMemberFptr (f_instr)eSporkMemberFptr
-#define SporkExp (f_instr)eSporkExp
-#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 ArrayAppend (f_instr)eArrayAppend
-#define AutoLoop (f_instr)eAutoLoop
-#define AutoLoopPtr (f_instr)eAutoLoopPtr
-#define AutoLoopCount (f_instr)eAutoLoopCount
-#define ArrayTop (f_instr)eArrayTop
-#define ArrayAccess (f_instr)eArrayAccess
-#define ArrayGet (f_instr)eArrayGet
-#define ArrayAddr (f_instr)eArrayAddr
-#define ArrayValid (f_instr)eArrayValid
-#define ObjectInstantiate (f_instr)eObjectInstantiate
-#define RegAddRef (f_instr)eRegAddRef
-#define RegAddRefAddr (f_instr)eRegAddRefAddr
-#define ObjectAssign (f_instr)eObjectAssign
-#define Assign (f_instr)eAssign
-#define ObjectRelease (f_instr)eObjectRelease
-#define GWOP_EXCEPT (f_instr)eGWOP_EXCEPT
-#define AllocMember4 (f_instr)eAllocMember4
-#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 UpvalueInt (f_instr)eUpvalueInt
-#define UpvalueFloat (f_instr)eUpvalueFloat
-#define UpvalueOther (f_instr)eUpvalueOther
-#define UpvalueAddr (f_instr)eUpvalueAddr
-#define DotFunc (f_instr)eDotFunc
-#define DotStaticFunc (f_instr)eDotStaticFunc
-#define GcIni (f_instr)eGcIni
-#define GcAdd (f_instr)eGcAdd
-#define GcEnd (f_instr)eGcEnd
-#define GackType (f_instr)eGackType
-#define GackEnd (f_instr)eGackEnd
-#define Gack (f_instr)eGack
-#define NoOp (f_instr)eNoOp
-#define EOC (f_instr)eEOC
-#define OP_MAX (f_instr)eOP_MAX
-#define DotTmplVal (f_instr)eDotTmplVal
+#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 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_plus (f_instr)eint_plus
+#define int_minus (f_instr)eint_minus
+#define int_mul (f_instr)eint_mul
+#define int_div (f_instr)eint_div
+#define int_modulo (f_instr)eint_modulo
+#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_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 FloatPlus (f_instr)eFloatPlus
+#define FloatMinus (f_instr)eFloatMinus
+#define FloatTimes (f_instr)eFloatTimes
+#define FloatDivide (f_instr)eFloatDivide
+#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_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 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 FuncMemberEnd (f_instr)eFuncMemberEnd
+#define SporkIni (f_instr)eSporkIni
+#define ForkIni (f_instr)eForkIni
+#define SporkFunc (f_instr)eSporkFunc
+#define SporkMemberFptr (f_instr)eSporkMemberFptr
+#define SporkExp (f_instr)eSporkExp
+#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 ArrayAppend (f_instr)eArrayAppend
+#define AutoLoop (f_instr)eAutoLoop
+#define AutoLoopPtr (f_instr)eAutoLoopPtr
+#define AutoLoopCount (f_instr)eAutoLoopCount
+#define ArrayTop (f_instr)eArrayTop
+#define ArrayAccess (f_instr)eArrayAccess
+#define ArrayGet (f_instr)eArrayGet
+#define ArrayAddr (f_instr)eArrayAddr
+#define ArrayValid (f_instr)eArrayValid
+#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 GWOP_EXCEPT (f_instr)eGWOP_EXCEPT
+#define AllocMember4 (f_instr)eAllocMember4
+#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 UpvalueInt (f_instr)eUpvalueInt
+#define UpvalueFloat (f_instr)eUpvalueFloat
+#define UpvalueOther (f_instr)eUpvalueOther
+#define UpvalueAddr (f_instr)eUpvalueAddr
+#define DotFunc (f_instr)eDotFunc
+#define DotStaticFunc (f_instr)eDotStaticFunc
+#define GcIni (f_instr)eGcIni
+#define GcAdd (f_instr)eGcAdd
+#define GcEnd (f_instr)eGcEnd
+#define GackType (f_instr)eGackType
+#define GackEnd (f_instr)eGackEnd
+#define Gack (f_instr)eGack
+#define NoOp (f_instr)eNoOp
+#define EOC (f_instr)eEOC
+#define OP_MAX (f_instr)eOP_MAX
+#define DotTmplVal (f_instr)eDotTmplVal
#endif
return size;
}
-ANN static Instr emit_addref(const Emitter emit, const m_bool emit_var) {
+ANN Instr emit_object_addref(const Emitter emit, const m_int size, const m_bool emit_var) {
const f_instr exec = !emit_var ? RegAddRef : RegAddRefAddr;
const Instr instr = emit_add_instr(emit, exec);
- instr->m_val = -SZ_INT;
+ instr->m_val = size;
return instr;
}
-ANN static void struct_addref(const Emitter emit, const Type type,
- const m_int size, const m_bool offset, const m_bool emit_var) {
- if(!type->info->tuple)
- return;
- for(m_uint i = 0; i < vector_size(&type->info->tuple->types); ++i) {
- const Type t = (Type)vector_at(&type->info->tuple->types, i);
- if(isa(t, emit->gwion->type[et_object]) > 0) {
- const Instr instr = emit_addref(emit, emit_var);
- instr->m_val = size;
- instr->m_val2 = vector_at(&type->info->tuple->offset, i);
- } else if(tflag(t, tflag_struct))
- struct_addref(emit, t, size, offset + vector_at(&type->info->tuple->offset, i), emit_var);
- }
+ANN Instr emit_struct_addref(const Emitter emit, const Type t, const m_int size, const m_bool emit_var) {
+ const Instr instr = emit_add_instr(emit, !emit_var ? StructRegAddRef : StructRegAddRefAddr);
+ instr->m_val = (m_uint)t;
+ instr->m_val2 = size;
+ return instr;
}
-ANN2(1) static void emit_exp_addref1(const Emitter emit, /* const */Exp exp, m_int size) {
- if(isa(exp->type, emit->gwion->type[et_object]) > 0 &&
- (exp->cast_to ? isa(exp->cast_to, emit->gwion->type[et_object]) > 0 : 1)) {
- if(exp->exp_type == ae_exp_decl && GET_FLAG(exp->d.exp_decl.td, late) && !exp_getvar(exp)) {
- const Instr instr = emit_add_instr(emit, GWOP_EXCEPT);
- instr->m_val = size;
- }
- const Instr instr = emit_addref(emit, exp_getvar(exp));
- instr->m_val = size;
- } else if(tflag(exp->type, tflag_struct)) // check cast_to ?
- struct_addref(emit, exp->type, size, 0, exp_getvar(exp));
+ANN2(1) static void emit_exp_addref1(const Emitter emit, const Exp exp, m_int size) {
+ const Type t = exp->cast_to ?: exp->type;
+ if(isa(t, emit->gwion->type[et_compound]) > 0)
+// emit_object_addref(emit, size, exp_getvar(exp));
+// else if(tflag(t, tflag_struct))
+ emit_compound_addref(emit, exp->type, size, exp_getvar(exp));
}
ANN2(1) static void emit_exp_addref(const Emitter emit, /* const */Exp exp, m_int size) {
if(!v->d.ptr)
v->d.ptr = (m_uint*)new_string2(emit->gwion, NULL, s_name(sym));
regpushi(emit, (m_uint)v->d.ptr);
- emit_addref(emit, 0);
+ emit_object_addref(emit, -SZ_INT, 0);
return GW_OK;
}
CHECK_BB(emit_instantiate_decl(emit, v->type, decl->td, var_decl->array, is_ref))
CHECK_BB(emit_dot_static_data(emit, v, 1))
emit_add_instr(emit, Assign);
-// (void)emit_addref(emit, 0);
+// (void)emit_object_addref(emit, -SZ_INT, 0);
regpop(emit, SZ_INT);
emit->code = code;
return GW_OK;
push->m_val = -(missing_depth) * SZ_INT;
}
*/
- (void)emit_addref(emit, emit_var);
+ (void)emit_object_addref(emit, -SZ_INT, emit_var);
} else if(struct_ctor(v))
emit_struct_decl_finish(emit, v->type, emit_addr);
return GW_OK;