Beispiel #1
0
    def test_heapcache_fields(self):
        h = HeapCache()
        box1 = RefFrontendOp(1)
        box2 = RefFrontendOp(2)
        box3 = RefFrontendOp(3)
        assert h.getfield(box1, descr1) is None
        assert h.getfield(box1, descr2) is None
        h.setfield(box1, box2, descr1)
        assert h.getfield(box1, descr1) is box2
        assert h.getfield(box1, descr2) is None
        h.setfield(box1, box3, descr2)
        assert h.getfield(box1, descr1) is box2
        assert h.getfield(box1, descr2) is box3
        h.setfield(box1, box3, descr1)
        assert h.getfield(box1, descr1) is box3
        assert h.getfield(box1, descr2) is box3
        h.setfield(box3, box1, descr1)
        assert h.getfield(box3, descr1) is box1
        assert h.getfield(box1, descr1) is None
        assert h.getfield(box1, descr2) is box3

        h.reset()
        assert h.getfield(box1, descr1) is None
        assert h.getfield(box1, descr2) is None
        assert h.getfield(box3, descr1) is None
Beispiel #2
0
    def test_heapcache_fields(self):
        h = HeapCache()
        box1 = RefFrontendOp(1)
        box2 = RefFrontendOp(2)
        box3 = RefFrontendOp(3)
        assert h.getfield(box1, descr1) is None
        assert h.getfield(box1, descr2) is None
        h.setfield(box1, box2, descr1)
        assert h.getfield(box1, descr1) is box2
        assert h.getfield(box1, descr2) is None
        h.setfield(box1, box3, descr2)
        assert h.getfield(box1, descr1) is box2
        assert h.getfield(box1, descr2) is box3
        h.setfield(box1, box3, descr1)
        assert h.getfield(box1, descr1) is box3
        assert h.getfield(box1, descr2) is box3
        h.setfield(box3, box1, descr1)
        assert h.getfield(box3, descr1) is box1
        assert h.getfield(box1, descr1) is None
        assert h.getfield(box1, descr2) is box3

        h.reset()
        assert h.getfield(box1, descr1) is None
        assert h.getfield(box1, descr2) is None
        assert h.getfield(box3, descr1) is None
Beispiel #3
0
    def test_nonstandard_virtualizable_allocation(self):
        h = HeapCache()
        box1 = RefFrontendOp(1)
        h.new(box1)
        # we've seen the allocation, so it's not the virtualizable
        assert h.is_known_nonstandard_virtualizable(box1)

        h.reset()
        assert not h.is_known_nonstandard_virtualizable(box1)
Beispiel #4
0
    def test_known_class_box(self):
        h = HeapCache()
        assert not h.is_class_known(1)
        assert not h.is_class_known(2)
        h.class_now_known(1)
        assert h.is_class_known(1)
        assert not h.is_class_known(2)

        h.reset()
        assert not h.is_class_known(1)
        assert not h.is_class_known(2)
Beispiel #5
0
    def test_nonstandard_virtualizable(self):
        h = HeapCache()
        assert not h.is_nonstandard_virtualizable(1)
        assert not h.is_nonstandard_virtualizable(2)
        h.nonstandard_virtualizables_now_known(1)
        assert h.is_nonstandard_virtualizable(1)
        assert not h.is_nonstandard_virtualizable(2)

        h.reset()
        assert not h.is_nonstandard_virtualizable(1)
        assert not h.is_nonstandard_virtualizable(2)
Beispiel #6
0
    def test_known_class_box(self):
        h = HeapCache()
        assert not h.is_class_known(1)
        assert not h.is_class_known(2)
        h.class_now_known(1)
        assert h.is_class_known(1)
        assert not h.is_class_known(2)

        h.reset()
        assert not h.is_class_known(1)
        assert not h.is_class_known(2)
Beispiel #7
0
    def test_nonstandard_virtualizable(self):
        h = HeapCache()
        assert not h.is_nonstandard_virtualizable(1)
        assert not h.is_nonstandard_virtualizable(2)
        h.nonstandard_virtualizables_now_known(1)
        assert h.is_nonstandard_virtualizable(1)
        assert not h.is_nonstandard_virtualizable(2)

        h.reset()
        assert not h.is_nonstandard_virtualizable(1)
        assert not h.is_nonstandard_virtualizable(2)
Beispiel #8
0
    def test_known_nullity(self):
        h = HeapCache()
        assert not h.is_nullity_known(1)
        assert not h.is_nullity_known(2)
        h.nullity_now_known(1)
        assert h.is_nullity_known(1)
        assert not h.is_nullity_known(2)

        h.reset()
        assert not h.is_nullity_known(1)
        assert not h.is_nullity_known(2)
Beispiel #9
0
 def test_is_likely_virtual(self):
     h = HeapCache()
     h.new(box1)
     assert h.is_unescaped(box1)
     assert h.is_likely_virtual(box1)
     h.reset(reset_virtuals=False)
     assert not h.is_unescaped(box1)
     assert h.is_likely_virtual(box1)
     h._escape(box1)
     assert not h.is_unescaped(box1)
     assert not h.is_likely_virtual(box1)
Beispiel #10
0
 def test_is_likely_virtual_2(self):
     h = HeapCache()
     box1 = RefFrontendOp(1)
     h.new(box1)
     assert h.is_unescaped(box1)
     assert h.is_likely_virtual(box1)
     h.reset_keep_likely_virtuals()
     assert not h.is_unescaped(box1)
     assert h.is_likely_virtual(box1)
     h.reset()     # reset everything
     assert not h.is_unescaped(box1)
     assert not h.is_likely_virtual(box1)
Beispiel #11
0
 def test_is_likely_virtual_2(self):
     h = HeapCache()
     box1 = RefFrontendOp(1)
     h.new(box1)
     assert h.is_unescaped(box1)
     assert h.is_likely_virtual(box1)
     h.reset_keep_likely_virtuals()
     assert not h.is_unescaped(box1)
     assert h.is_likely_virtual(box1)
     h.reset()     # reset everything
     assert not h.is_unescaped(box1)
     assert not h.is_likely_virtual(box1)
Beispiel #12
0
    def test_nonstandard_virtualizable(self):
        h = HeapCache()
        box1 = RefFrontendOp(1)
        box2 = RefFrontendOp(2)
        assert not h.is_nonstandard_virtualizable(box1)
        assert not h.is_nonstandard_virtualizable(box2)
        h.nonstandard_virtualizables_now_known(box1)
        assert h.is_nonstandard_virtualizable(box1)
        assert not h.is_nonstandard_virtualizable(box2)

        h.reset()
        assert not h.is_nonstandard_virtualizable(box1)
        assert not h.is_nonstandard_virtualizable(box2)
Beispiel #13
0
    def test_known_nullity(self):
        h = HeapCache()
        box1 = RefFrontendOp(1)
        box2 = RefFrontendOp(2)
        assert not h.is_nullity_known(box1)
        assert not h.is_nullity_known(box2)
        h.nullity_now_known(box1)
        assert h.is_nullity_known(box1)
        assert not h.is_nullity_known(box2)

        h.reset()
        assert not h.is_nullity_known(box1)
        assert not h.is_nullity_known(box2)
Beispiel #14
0
    def test_known_class_box(self):
        h = HeapCache()
        box1 = RefFrontendOp(1)
        box2 = RefFrontendOp(2)
        assert not h.is_class_known(box1)
        assert not h.is_class_known(box2)
        h.class_now_known(box1)
        assert h.is_class_known(box1)
        assert not h.is_class_known(box2)

        h.reset()
        assert not h.is_class_known(box1)
        assert not h.is_class_known(box2)
Beispiel #15
0
    def test_known_nullity_more_cases(self):
        h = HeapCache()
        box1 = RefFrontendOp(1)
        box2 = RefFrontendOp(2)
        h.class_now_known(box1)
        assert h.is_nullity_known(box1)

        h.new(box2)
        assert h.is_nullity_known(box2)

        h.reset()
        assert not h.is_nullity_known(box1)
        assert not h.is_nullity_known(box2)
Beispiel #16
0
    def test_known_class_box(self):
        h = HeapCache()
        box1 = RefFrontendOp(1)
        box2 = RefFrontendOp(2)
        assert not h.is_class_known(box1)
        assert not h.is_class_known(box2)
        h.class_now_known(box1)
        assert h.is_class_known(box1)
        assert not h.is_class_known(box2)

        h.reset()
        assert not h.is_class_known(box1)
        assert not h.is_class_known(box2)
Beispiel #17
0
    def test_known_nullity(self):
        h = HeapCache()
        box1 = RefFrontendOp(1)
        box2 = RefFrontendOp(2)
        assert not h.is_nullity_known(box1)
        assert not h.is_nullity_known(box2)
        h.nullity_now_known(box1)
        assert h.is_nullity_known(box1)
        assert not h.is_nullity_known(box2)

        h.reset()
        assert not h.is_nullity_known(box1)
        assert not h.is_nullity_known(box2)
Beispiel #18
0
    def test_nonstandard_virtualizable(self):
        h = HeapCache()
        box1 = RefFrontendOp(1)
        box2 = RefFrontendOp(2)
        assert not h.is_known_nonstandard_virtualizable(box1)
        assert not h.is_known_nonstandard_virtualizable(box2)
        h.nonstandard_virtualizables_now_known(box1)
        assert h.is_known_nonstandard_virtualizable(box1)
        assert not h.is_known_nonstandard_virtualizable(box2)

        h.reset()
        assert not h.is_known_nonstandard_virtualizable(box1)
        assert not h.is_known_nonstandard_virtualizable(box2)
Beispiel #19
0
    def test_heapcache_read_fields_multiple(self):
        h = HeapCache()
        h.getfield_now_known(box1, descr1, box2)
        h.getfield_now_known(box3, descr1, box4)
        assert h.getfield(box1, descr1) is box2
        assert h.getfield(box1, descr2) is None
        assert h.getfield(box3, descr1) is box4
        assert h.getfield(box3, descr2) is None

        h.reset()
        assert h.getfield(box1, descr1) is None
        assert h.getfield(box1, descr2) is None
        assert h.getfield(box3, descr1) is None
        assert h.getfield(box3, descr2) is None
Beispiel #20
0
    def test_heapcache_read_fields_multiple_array(self):
        h = HeapCache()
        h.getarrayitem_now_known(box1, index1, box2, descr1)
        h.getarrayitem_now_known(box3, index1, box4, descr1)
        assert h.getarrayitem(box1, index1, descr1) is box2
        assert h.getarrayitem(box1, index1, descr2) is None
        assert h.getarrayitem(box3, index1, descr1) is box4
        assert h.getarrayitem(box3, index1, descr2) is None

        h.reset()
        assert h.getarrayitem(box1, index1, descr1) is None
        assert h.getarrayitem(box1, index1, descr2) is None
        assert h.getarrayitem(box3, index1, descr1) is None
        assert h.getarrayitem(box3, index1, descr2) is None
Beispiel #21
0
    def test_heapcache_read_fields_multiple_array(self):
        h = HeapCache()
        h.getarrayitem_now_known(box1, index1, box2, descr1)
        h.getarrayitem_now_known(box3, index1, box4, descr1)
        assert h.getarrayitem(box1, index1, descr1) is box2
        assert h.getarrayitem(box1, index1, descr2) is None
        assert h.getarrayitem(box3, index1, descr1) is box4
        assert h.getarrayitem(box3, index1, descr2) is None

        h.reset()
        assert h.getarrayitem(box1, index1, descr1) is None
        assert h.getarrayitem(box1, index1, descr2) is None
        assert h.getarrayitem(box3, index1, descr1) is None
        assert h.getarrayitem(box3, index1, descr2) is None
Beispiel #22
0
    def test_heapcache_read_fields_multiple(self):
        h = HeapCache()
        h.getfield_now_known(box1, descr1, box2)
        h.getfield_now_known(box3, descr1, box4)
        assert h.getfield(box1, descr1) is box2
        assert h.getfield(box1, descr2) is None
        assert h.getfield(box3, descr1) is box4
        assert h.getfield(box3, descr2) is None

        h.reset()
        assert h.getfield(box1, descr1) is None
        assert h.getfield(box1, descr2) is None
        assert h.getfield(box3, descr1) is None
        assert h.getfield(box3, descr2) is None
Beispiel #23
0
    def test_heapcache_arrays(self):
        h = HeapCache()
        box1 = RefFrontendOp(1)
        box2 = RefFrontendOp(2)
        box3 = RefFrontendOp(3)
        box4 = RefFrontendOp(4)
        assert h.getarrayitem(box1, index1, descr1) is None
        assert h.getarrayitem(box1, index1, descr2) is None
        assert h.getarrayitem(box1, index2, descr1) is None
        assert h.getarrayitem(box1, index2, descr2) is None

        h.setarrayitem(box1, index1, box2, descr1)
        assert h.getarrayitem(box1, index1, descr1) is box2
        assert h.getarrayitem(box1, index1, descr2) is None
        assert h.getarrayitem(box1, index2, descr1) is None
        assert h.getarrayitem(box1, index2, descr2) is None
        h.setarrayitem(box1, index2, box4, descr1)
        assert h.getarrayitem(box1, index1, descr1) is box2
        assert h.getarrayitem(box1, index1, descr2) is None
        assert h.getarrayitem(box1, index2, descr1) is box4
        assert h.getarrayitem(box1, index2, descr2) is None

        h.setarrayitem(box1, index1, box3, descr2)
        assert h.getarrayitem(box1, index1, descr1) is box2
        assert h.getarrayitem(box1, index1, descr2) is box3
        assert h.getarrayitem(box1, index2, descr1) is box4
        assert h.getarrayitem(box1, index2, descr2) is None

        h.setarrayitem(box1, index1, box3, descr1)
        assert h.getarrayitem(box1, index1, descr1) is box3
        assert h.getarrayitem(box1, index1, descr2) is box3
        assert h.getarrayitem(box1, index2, descr1) is box4
        assert h.getarrayitem(box1, index2, descr2) is None

        h.setarrayitem(box3, index1, box1, descr1)
        assert h.getarrayitem(box3, index1, descr1) is box1
        assert h.getarrayitem(box1, index1, descr1) is None
        assert h.getarrayitem(box1, index1, descr2) is box3
        assert h.getarrayitem(box1, index2, descr1) is box4
        assert h.getarrayitem(box1, index2, descr2) is None

        h.reset()
        assert h.getarrayitem(box1, index1, descr1) is None
        assert h.getarrayitem(box1, index1, descr2) is None
        assert h.getarrayitem(box3, index1, descr1) is None
Beispiel #24
0
    def test_heapcache_arrays(self):
        h = HeapCache()
        box1 = RefFrontendOp(1)
        box2 = RefFrontendOp(2)
        box3 = RefFrontendOp(3)
        box4 = RefFrontendOp(4)
        assert h.getarrayitem(box1, index1, descr1) is None
        assert h.getarrayitem(box1, index1, descr2) is None
        assert h.getarrayitem(box1, index2, descr1) is None
        assert h.getarrayitem(box1, index2, descr2) is None

        h.setarrayitem(box1, index1, box2, descr1)
        assert h.getarrayitem(box1, index1, descr1) is box2
        assert h.getarrayitem(box1, index1, descr2) is None
        assert h.getarrayitem(box1, index2, descr1) is None
        assert h.getarrayitem(box1, index2, descr2) is None
        h.setarrayitem(box1, index2, box4, descr1)
        assert h.getarrayitem(box1, index1, descr1) is box2
        assert h.getarrayitem(box1, index1, descr2) is None
        assert h.getarrayitem(box1, index2, descr1) is box4
        assert h.getarrayitem(box1, index2, descr2) is None

        h.setarrayitem(box1, index1, box3, descr2)
        assert h.getarrayitem(box1, index1, descr1) is box2
        assert h.getarrayitem(box1, index1, descr2) is box3
        assert h.getarrayitem(box1, index2, descr1) is box4
        assert h.getarrayitem(box1, index2, descr2) is None

        h.setarrayitem(box1, index1, box3, descr1)
        assert h.getarrayitem(box1, index1, descr1) is box3
        assert h.getarrayitem(box1, index1, descr2) is box3
        assert h.getarrayitem(box1, index2, descr1) is box4
        assert h.getarrayitem(box1, index2, descr2) is None

        h.setarrayitem(box3, index1, box1, descr1)
        assert h.getarrayitem(box3, index1, descr1) is box1
        assert h.getarrayitem(box1, index1, descr1) is None
        assert h.getarrayitem(box1, index1, descr2) is box3
        assert h.getarrayitem(box1, index2, descr1) is box4
        assert h.getarrayitem(box1, index2, descr2) is None

        h.reset()
        assert h.getarrayitem(box1, index1, descr1) is None
        assert h.getarrayitem(box1, index1, descr2) is None
        assert h.getarrayitem(box3, index1, descr1) is None
Beispiel #25
0
    def test_heapcache_read_fields_multiple(self):
        h = HeapCache()
        box1 = RefFrontendOp(1)
        box2 = RefFrontendOp(2)
        box3 = RefFrontendOp(3)
        box4 = RefFrontendOp(4)
        h.getfield_now_known(box1, descr1, box2)
        h.getfield_now_known(box3, descr1, box4)
        assert h.getfield(box1, descr1) is box2
        assert h.getfield(box1, descr2) is None
        assert h.getfield(box3, descr1) is box4
        assert h.getfield(box3, descr2) is None

        h.reset()
        assert h.getfield(box1, descr1) is None
        assert h.getfield(box1, descr2) is None
        assert h.getfield(box3, descr1) is None
        assert h.getfield(box3, descr2) is None
Beispiel #26
0
    def test_heapcache_read_fields_multiple(self):
        h = HeapCache()
        box1 = RefFrontendOp(1)
        box2 = RefFrontendOp(2)
        box3 = RefFrontendOp(3)
        box4 = RefFrontendOp(4)
        h.getfield_now_known(box1, descr1, box2)
        h.getfield_now_known(box3, descr1, box4)
        assert h.getfield(box1, descr1) is box2
        assert h.getfield(box1, descr2) is None
        assert h.getfield(box3, descr1) is box4
        assert h.getfield(box3, descr2) is None

        h.reset()
        assert h.getfield(box1, descr1) is None
        assert h.getfield(box1, descr2) is None
        assert h.getfield(box3, descr1) is None
        assert h.getfield(box3, descr2) is None
Beispiel #27
0
    def test_heapcache_arrays(self):
        h = HeapCache()
        assert h.getarrayitem(box1, index1, descr1) is None
        assert h.getarrayitem(box1, index1, descr2) is None
        assert h.getarrayitem(box1, index2, descr1) is None
        assert h.getarrayitem(box1, index2, descr2) is None

        h.setarrayitem(box1, index1, box2, descr1)
        assert h.getarrayitem(box1, index1, descr1) is box2
        assert h.getarrayitem(box1, index1, descr2) is None
        assert h.getarrayitem(box1, index2, descr1) is None
        assert h.getarrayitem(box1, index2, descr2) is None
        h.setarrayitem(box1, index2, box4, descr1)
        assert h.getarrayitem(box1, index1, descr1) is box2
        assert h.getarrayitem(box1, index1, descr2) is None
        assert h.getarrayitem(box1, index2, descr1) is box4
        assert h.getarrayitem(box1, index2, descr2) is None

        h.setarrayitem(box1, index1, box3, descr2)
        assert h.getarrayitem(box1, index1, descr1) is box2
        assert h.getarrayitem(box1, index1, descr2) is box3
        assert h.getarrayitem(box1, index2, descr1) is box4
        assert h.getarrayitem(box1, index2, descr2) is None

        h.setarrayitem(box1, index1, box3, descr1)
        assert h.getarrayitem(box1, index1, descr1) is box3
        assert h.getarrayitem(box1, index1, descr2) is box3
        assert h.getarrayitem(box1, index2, descr1) is box4
        assert h.getarrayitem(box1, index2, descr2) is None

        h.setarrayitem(box3, index1, box1, descr1)
        assert h.getarrayitem(box3, index1, descr1) is box1
        assert h.getarrayitem(box1, index1, descr1) is None
        assert h.getarrayitem(box1, index1, descr2) is box3
        assert h.getarrayitem(box1, index2, descr1) is box4
        assert h.getarrayitem(box1, index2, descr2) is None

        h.reset()
        assert h.getarrayitem(box1, index1, descr1) is None
        assert h.getarrayitem(box1, index1, descr2) is None
        assert h.getarrayitem(box3, index1, descr1) is None
Beispiel #28
0
    def test_heapcache_arrays(self):
        h = HeapCache()
        assert h.getarrayitem(box1, index1, descr1) is None
        assert h.getarrayitem(box1, index1, descr2) is None
        assert h.getarrayitem(box1, index2, descr1) is None
        assert h.getarrayitem(box1, index2, descr2) is None

        h.setarrayitem(box1, index1, box2, descr1)
        assert h.getarrayitem(box1, index1, descr1) is box2
        assert h.getarrayitem(box1, index1, descr2) is None
        assert h.getarrayitem(box1, index2, descr1) is None
        assert h.getarrayitem(box1, index2, descr2) is None
        h.setarrayitem(box1, index2, box4, descr1)
        assert h.getarrayitem(box1, index1, descr1) is box2
        assert h.getarrayitem(box1, index1, descr2) is None
        assert h.getarrayitem(box1, index2, descr1) is box4
        assert h.getarrayitem(box1, index2, descr2) is None

        h.setarrayitem(box1, index1, box3, descr2)
        assert h.getarrayitem(box1, index1, descr1) is box2
        assert h.getarrayitem(box1, index1, descr2) is box3
        assert h.getarrayitem(box1, index2, descr1) is box4
        assert h.getarrayitem(box1, index2, descr2) is None

        h.setarrayitem(box1, index1, box3, descr1)
        assert h.getarrayitem(box1, index1, descr1) is box3
        assert h.getarrayitem(box1, index1, descr2) is box3
        assert h.getarrayitem(box1, index2, descr1) is box4
        assert h.getarrayitem(box1, index2, descr2) is None

        h.setarrayitem(box3, index1, box1, descr1)
        assert h.getarrayitem(box3, index1, descr1) is box1
        assert h.getarrayitem(box1, index1, descr1) is None
        assert h.getarrayitem(box1, index1, descr2) is box3
        assert h.getarrayitem(box1, index2, descr1) is box4
        assert h.getarrayitem(box1, index2, descr2) is None

        h.reset()
        assert h.getarrayitem(box1, index1, descr1) is None
        assert h.getarrayitem(box1, index1, descr2) is None
        assert h.getarrayitem(box3, index1, descr1) is None
Beispiel #29
0
    def test_heapcache_fields(self):
        h = HeapCache()
        assert h.getfield(box1, descr1) is None
        assert h.getfield(box1, descr2) is None
        h.setfield(box1, box2, descr1)
        assert h.getfield(box1, descr1) is box2
        assert h.getfield(box1, descr2) is None
        h.setfield(box1, box3, descr2)
        assert h.getfield(box1, descr1) is box2
        assert h.getfield(box1, descr2) is box3
        h.setfield(box1, box3, descr1)
        assert h.getfield(box1, descr1) is box3
        assert h.getfield(box1, descr2) is box3
        h.setfield(box3, box1, descr1)
        assert h.getfield(box3, descr1) is box1
        assert h.getfield(box1, descr1) is None
        assert h.getfield(box1, descr2) is box3

        h.reset()
        assert h.getfield(box1, descr1) is None
        assert h.getfield(box1, descr2) is None
        assert h.getfield(box3, descr1) is None
Beispiel #30
0
    def test_heapcache_fields(self):
        h = HeapCache()
        assert h.getfield(box1, descr1) is None
        assert h.getfield(box1, descr2) is None
        h.setfield(box1, box2, descr1)
        assert h.getfield(box1, descr1) is box2
        assert h.getfield(box1, descr2) is None
        h.setfield(box1, box3, descr2)
        assert h.getfield(box1, descr1) is box2
        assert h.getfield(box1, descr2) is box3
        h.setfield(box1, box3, descr1)
        assert h.getfield(box1, descr1) is box3
        assert h.getfield(box1, descr2) is box3
        h.setfield(box3, box1, descr1)
        assert h.getfield(box3, descr1) is box1
        assert h.getfield(box1, descr1) is None
        assert h.getfield(box1, descr2) is box3

        h.reset()
        assert h.getfield(box1, descr1) is None
        assert h.getfield(box1, descr2) is None
        assert h.getfield(box3, descr1) is None