コード例 #1
0
    def test_quasiimmut_seen_consts(self):
        h = HeapCache()
        box1 = ConstPtr(rffi.cast(llmemory.GCREF, 1))
        box2 = ConstPtr(rffi.cast(llmemory.GCREF, 1))
        box3 = ConstPtr(rffi.cast(llmemory.GCREF, 1))
        box4 = ConstPtr(rffi.cast(llmemory.GCREF, 1))
        assert not h.is_quasi_immut_known(descr1, box1)
        assert not h.is_quasi_immut_known(descr1, box2)
        assert not h.is_quasi_immut_known(descr2, box3)
        assert not h.is_quasi_immut_known(descr2, box4)
        h.quasi_immut_now_known(descr1, box1)
        assert h.is_quasi_immut_known(descr1, box1)
        assert h.is_quasi_immut_known(descr1, box2)
        assert not h.is_quasi_immut_known(descr2, box3)
        assert not h.is_quasi_immut_known(descr2, box4)
        h.quasi_immut_now_known(descr2, box3)
        assert h.is_quasi_immut_known(descr1, box1)
        assert h.is_quasi_immut_known(descr1, box2)
        assert h.is_quasi_immut_known(descr2, box3)
        assert h.is_quasi_immut_known(descr2, box4)

        # invalidate the descr1 cache

        vbox1 = RefFrontendOp(1)
        vbox2 = RefFrontendOp(2)
        h.setfield(vbox1, vbox2, descr1)
        assert not h.is_quasi_immut_known(descr1, box1)
        assert not h.is_quasi_immut_known(descr1, box2)

        # a call invalidates everything
        h.invalidate_caches(
            rop.CALL_N, FakeCallDescr(FakeEffectinfo.EF_CAN_RAISE), [])
        assert not h.is_quasi_immut_known(descr2, box3)
        assert not h.is_quasi_immut_known(descr2, box4)
コード例 #2
0
    def test_quasiimmut_seen(self):
        h = HeapCache()
        box1 = RefFrontendOp(1)
        box2 = RefFrontendOp(2)
        box3 = RefFrontendOp(3)
        box4 = RefFrontendOp(4)
        assert not h.is_quasi_immut_known(descr1, box1)
        assert not h.is_quasi_immut_known(descr1, box2)
        assert not h.is_quasi_immut_known(descr2, box3)
        assert not h.is_quasi_immut_known(descr2, box4)
        h.quasi_immut_now_known(descr1, box1)
        assert h.is_quasi_immut_known(descr1, box1)
        assert not h.is_quasi_immut_known(descr1, box2)
        assert not h.is_quasi_immut_known(descr2, box3)
        assert not h.is_quasi_immut_known(descr2, box4)
        h.quasi_immut_now_known(descr1, box2)
        assert h.is_quasi_immut_known(descr1, box1)
        assert h.is_quasi_immut_known(descr1, box2)
        assert not h.is_quasi_immut_known(descr2, box3)
        assert not h.is_quasi_immut_known(descr2, box4)
        h.quasi_immut_now_known(descr2, box3)
        assert h.is_quasi_immut_known(descr1, box1)
        assert h.is_quasi_immut_known(descr1, box2)
        assert h.is_quasi_immut_known(descr2, box3)
        assert not h.is_quasi_immut_known(descr2, box4)
        h.quasi_immut_now_known(descr2, box4)
        assert h.is_quasi_immut_known(descr1, box1)
        assert h.is_quasi_immut_known(descr1, box2)
        assert h.is_quasi_immut_known(descr2, box3)
        assert h.is_quasi_immut_known(descr2, box4)

        # invalidate the descr1 cache

        h.setfield(box1, box3, descr1)
        assert not h.is_quasi_immut_known(descr1, box1)
        assert not h.is_quasi_immut_known(descr1, box2)

        # a call invalidates everything
        h.invalidate_caches(
            rop.CALL_N, FakeCallDescr(FakeEffectinfo.EF_CAN_RAISE), [])
        assert not h.is_quasi_immut_known(descr2, box3)
        assert not h.is_quasi_immut_known(descr2, box4)
コード例 #3
0
ファイル: test_heapcache.py プロジェクト: mozillazg/pypy
    def test_quasiimmut_seen(self):
        h = HeapCache()
        box1 = RefFrontendOp(1)
        box2 = RefFrontendOp(2)
        box3 = RefFrontendOp(3)
        box4 = RefFrontendOp(4)
        assert not h.is_quasi_immut_known(descr1, box1)
        assert not h.is_quasi_immut_known(descr1, box2)
        assert not h.is_quasi_immut_known(descr2, box3)
        assert not h.is_quasi_immut_known(descr2, box4)
        h.quasi_immut_now_known(descr1, box1)
        assert h.is_quasi_immut_known(descr1, box1)
        assert not h.is_quasi_immut_known(descr1, box2)
        assert not h.is_quasi_immut_known(descr2, box3)
        assert not h.is_quasi_immut_known(descr2, box4)
        h.quasi_immut_now_known(descr1, box2)
        assert h.is_quasi_immut_known(descr1, box1)
        assert h.is_quasi_immut_known(descr1, box2)
        assert not h.is_quasi_immut_known(descr2, box3)
        assert not h.is_quasi_immut_known(descr2, box4)
        h.quasi_immut_now_known(descr2, box3)
        assert h.is_quasi_immut_known(descr1, box1)
        assert h.is_quasi_immut_known(descr1, box2)
        assert h.is_quasi_immut_known(descr2, box3)
        assert not h.is_quasi_immut_known(descr2, box4)
        h.quasi_immut_now_known(descr2, box4)
        assert h.is_quasi_immut_known(descr1, box1)
        assert h.is_quasi_immut_known(descr1, box2)
        assert h.is_quasi_immut_known(descr2, box3)
        assert h.is_quasi_immut_known(descr2, box4)

        # invalidate the descr1 cache

        h.setfield(box1, box3, descr1)
        assert not h.is_quasi_immut_known(descr1, box1)
        assert not h.is_quasi_immut_known(descr1, box2)

        # a call invalidates everything
        h.invalidate_caches(
            rop.CALL_N, FakeCallDescr(FakeEffectinfo.EF_CAN_RAISE), [])
        assert not h.is_quasi_immut_known(descr2, box3)
        assert not h.is_quasi_immut_known(descr2, box4)