Esempio n. 1
0
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))
Esempio n. 3
0
 def test_inc_ref(self) -> None:
     self.assert_emit(IncRef(self.m), "CPyTagged_IncRef(cpy_r_m);")
Esempio n. 4
0
 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)
Esempio n. 5
0
 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)