def add_block(decs: Decs, incs: Incs, cache: BlockCache, blocks: List[BasicBlock], label: BasicBlock) -> BasicBlock: if not decs and not incs: return label # TODO: be able to share *partial* results if (label, decs, incs) in cache: return cache[label, decs, incs] block = BasicBlock() blocks.append(block) block.ops.extend(DecRef(reg, is_xdec=xdec) for reg, xdec in decs) block.ops.extend(IncRef(reg) for reg in incs) block.ops.append(Goto(label)) cache[label, decs, incs] = block return block
def maybe_append_inc_ref(ops: List[Op], dest: Value) -> None: if dest.type.is_refcounted: ops.append(IncRef(dest))
def test_inc_ref(self) -> None: self.assert_emit(IncRef(self.m), "CPyTagged_IncRef(cpy_r_m);")
def test_inc_ref_int(self) -> None: self.assert_emit(IncRef(self.m), "CPyTagged_INCREF(cpy_r_m);") self.assert_emit(IncRef(self.m), "CPyTagged_IncRef(cpy_r_m);", rare=True)
def test_inc_ref(self) -> None: self.assert_emit(IncRef(self.o), "CPy_INCREF(cpy_r_o);") self.assert_emit(IncRef(self.o), "CPy_INCREF(cpy_r_o);", rare=True)