Ejemplo n.º 1
0
 def test_replace_box_with_const(self):
     h = HeapCache()
     box1 = RefFrontendOp(1)
     box2 = RefFrontendOp(2)
     box3 = RefFrontendOp(3)
     c_box3 = ConstPtr(ConstPtr.value)
     h.setfield(box1, box2, descr1)
     h.setfield(box1, box3, descr2)
     h.setfield(box2, box3, descr3)
     h.replace_box(box3, c_box3)
     assert h.getfield(box1, descr1) is box2
     assert c_box3.same_constant(h.getfield(box1, descr2))
     assert c_box3.same_constant(h.getfield(box2, descr3))
Ejemplo n.º 2
0
 def test_replace_box_with_const(self):
     h = HeapCache()
     box1 = RefFrontendOp(1)
     box2 = RefFrontendOp(2)
     box3 = RefFrontendOp(3)
     c_box3 = ConstPtr(ConstPtr.value)
     h.setfield(box1, box2, descr1)
     h.setfield(box1, box3, descr2)
     h.setfield(box2, box3, descr3)
     h.replace_box(box3, c_box3)
     assert h.getfield(box1, descr1) is box2
     assert c_box3.same_constant(h.getfield(box1, descr2))
     assert c_box3.same_constant(h.getfield(box2, descr3))
Ejemplo n.º 3
0
 def test_replace_box_with_box(self):
     py.test.skip("replacing a box with another box: not supported any more")
     h = HeapCache()
     box1 = RefFrontendOp(1)
     box2 = RefFrontendOp(2)
     box3 = RefFrontendOp(3)
     box4 = RefFrontendOp(4)
     h.setfield(box1, box2, descr1)
     h.setfield(box1, box3, descr2)
     h.setfield(box2, box3, descr3)
     h.replace_box(box1, box4)
     assert h.getfield(box4, descr1) is box2
     assert h.getfield(box4, descr2) is box3
     assert h.getfield(box2, descr3) is box3
     h.setfield(box4, box3, descr1)
     assert h.getfield(box4, descr1) is box3
Ejemplo n.º 4
0
 def test_replace_box_with_box(self):
     py.test.skip("replacing a box with another box: not supported any more")
     h = HeapCache()
     box1 = RefFrontendOp(1)
     box2 = RefFrontendOp(2)
     box3 = RefFrontendOp(3)
     box4 = RefFrontendOp(4)
     h.setfield(box1, box2, descr1)
     h.setfield(box1, box3, descr2)
     h.setfield(box2, box3, descr3)
     h.replace_box(box1, box4)
     assert h.getfield(box4, descr1) is box2
     assert h.getfield(box4, descr2) is box3
     assert h.getfield(box2, descr3) is box3
     h.setfield(box4, box3, descr1)
     assert h.getfield(box4, descr1) is box3
Ejemplo n.º 5
0
    def test_replace_box_with_const_in_array(self):
        h = HeapCache()
        box1 = RefFrontendOp(1)
        lengthbox2 = IntFrontendOp(2)
        lengthbox2.setint(10)
        h.arraylen_now_known(box1, lengthbox2)
        assert h.arraylen(box1) is lengthbox2
        c10 = ConstInt(10)
        h.replace_box(lengthbox2, c10)
        assert c10.same_constant(h.arraylen(box1))

        box2 = IntFrontendOp(2)
        box2.setint(12)
        h.setarrayitem(box1, index2, box2, descr1)
        assert h.getarrayitem(box1, index2, descr1) is box2
        c12 = ConstInt(12)
        h.replace_box(box2, c12)
        assert c12.same_constant(h.getarrayitem(box1, index2, descr1))
Ejemplo n.º 6
0
    def test_replace_box_array(self):
        h = HeapCache()
        h.setarrayitem(box1, index1, box2, descr1)
        h.setarrayitem(box1, index1, box3, descr2)
        h.arraylen_now_known(box1, lengthbox1)
        h.setarrayitem(box2, index2, box1, descr1)
        h.setarrayitem(box3, index2, box1, descr2)
        h.setarrayitem(box2, index2, box3, descr3)
        h.replace_box(box1, box4)
        assert h.arraylen(box4) is lengthbox1
        assert h.getarrayitem(box4, index1, descr1) is box2
        assert h.getarrayitem(box4, index1, descr2) is box3
        assert h.getarrayitem(box2, index2, descr1) is box4
        assert h.getarrayitem(box3, index2, descr2) is box4
        assert h.getarrayitem(box2, index2, descr3) is box3

        h.replace_box(lengthbox1, lengthbox2)
        assert h.arraylen(box4) is lengthbox2
Ejemplo n.º 7
0
    def test_replace_box_array(self):
        h = HeapCache()
        h.setarrayitem(box1, index1, box2, descr1)
        h.setarrayitem(box1, index1, box3, descr2)
        h.arraylen_now_known(box1, lengthbox1)
        h.setarrayitem(box2, index2, box1, descr1)
        h.setarrayitem(box3, index2, box1, descr2)
        h.setarrayitem(box2, index2, box3, descr3)
        h.replace_box(box1, box4)
        assert h.arraylen(box4) is lengthbox1
        assert h.getarrayitem(box4, index1, descr1) is box2
        assert h.getarrayitem(box4, index1, descr2) is box3
        assert h.getarrayitem(box2, index2, descr1) is box4
        assert h.getarrayitem(box3, index2, descr2) is box4
        assert h.getarrayitem(box2, index2, descr3) is box3

        h.replace_box(lengthbox1, lengthbox2)
        assert h.arraylen(box4) is lengthbox2
Ejemplo n.º 8
0
    def test_replace_box_with_const_in_array(self):
        h = HeapCache()
        box1 = RefFrontendOp(1)
        lengthbox2 = IntFrontendOp(2)
        lengthbox2.setint(10)
        h.arraylen_now_known(box1, lengthbox2)
        assert h.arraylen(box1) is lengthbox2
        c10 = ConstInt(10)
        h.replace_box(lengthbox2, c10)
        assert c10.same_constant(h.arraylen(box1))

        box2 = IntFrontendOp(2)
        box2.setint(12)
        h.setarrayitem(box1, index2, box2, descr1)
        assert h.getarrayitem(box1, index2, descr1) is box2
        c12 = ConstInt(12)
        h.replace_box(box2, c12)
        assert c12.same_constant(h.getarrayitem(box1, index2, descr1))
Ejemplo n.º 9
0
    def test_replace_box_array(self):
        py.test.skip("replacing a box with another box: not supported any more")
        h = HeapCache()
        h.setarrayitem(box1, index1, box2, descr1)
        h.setarrayitem(box1, index1, box3, descr2)
        h.arraylen_now_known(box1, lengthbox1)
        h.setarrayitem(box2, index2, box1, descr1)
        h.setarrayitem(box3, index2, box1, descr2)
        h.setarrayitem(box2, index2, box3, descr3)
        h.replace_box(box1, box4)
        assert h.arraylen(box4) is lengthbox1
        assert h.getarrayitem(box4, index1, descr1) is box2
        assert h.getarrayitem(box4, index1, descr2) is box3
        assert h.getarrayitem(box2, index2, descr1) is box4
        assert h.getarrayitem(box3, index2, descr2) is box4
        assert h.getarrayitem(box2, index2, descr3) is box3

        h.replace_box(lengthbox1, lengthbox2)
        assert h.arraylen(box4) is lengthbox2
Ejemplo n.º 10
0
    def test_replace_box_array(self):
        py.test.skip("replacing a box with another box: not supported any more")
        h = HeapCache()
        h.setarrayitem(box1, index1, box2, descr1)
        h.setarrayitem(box1, index1, box3, descr2)
        h.arraylen_now_known(box1, lengthbox1)
        h.setarrayitem(box2, index2, box1, descr1)
        h.setarrayitem(box3, index2, box1, descr2)
        h.setarrayitem(box2, index2, box3, descr3)
        h.replace_box(box1, box4)
        assert h.arraylen(box4) is lengthbox1
        assert h.getarrayitem(box4, index1, descr1) is box2
        assert h.getarrayitem(box4, index1, descr2) is box3
        assert h.getarrayitem(box2, index2, descr1) is box4
        assert h.getarrayitem(box3, index2, descr2) is box4
        assert h.getarrayitem(box2, index2, descr3) is box3

        h.replace_box(lengthbox1, lengthbox2)
        assert h.arraylen(box4) is lengthbox2
Ejemplo n.º 11
0
    def test_replace_box(self):
        h = HeapCache()
        h.setfield(box1, box2, descr1)
        h.setfield(box1, box3, descr2)
        h.setfield(box2, box3, descr3)
        h.replace_box(box1, box4)
        assert h.getfield(box4, descr1) is box2
        assert h.getfield(box4, descr2) is box3
        assert h.getfield(box2, descr3) is box3
        h.setfield(box4, box3, descr1)
        assert h.getfield(box4, descr1) is box3

        h = HeapCache()
        h.setfield(box1, box2, descr1)
        h.setfield(box1, box3, descr2)
        h.setfield(box2, box3, descr3)
        h.replace_box(box3, box4)
        assert h.getfield(box1, descr1) is box2
        assert h.getfield(box1, descr2) is box4
        assert h.getfield(box2, descr3) is box4
Ejemplo n.º 12
0
    def test_replace_box(self):
        h = HeapCache()
        h.setfield(box1, box2, descr1)
        h.setfield(box1, box3, descr2)
        h.setfield(box2, box3, descr3)
        h.replace_box(box1, box4)
        assert h.getfield(box4, descr1) is box2
        assert h.getfield(box4, descr2) is box3
        assert h.getfield(box2, descr3) is box3
        h.setfield(box4, box3, descr1)
        assert h.getfield(box4, descr1) is box3

        h = HeapCache()
        h.setfield(box1, box2, descr1)
        h.setfield(box1, box3, descr2)
        h.setfield(box2, box3, descr3)
        h.replace_box(box3, box4)
        assert h.getfield(box1, descr1) is box2
        assert h.getfield(box1, descr2) is box4
        assert h.getfield(box2, descr3) is box4
Ejemplo n.º 13
0
    def test_replace_box_twice(self):
        py.test.skip("replacing a box with another box: not supported any more")
        h = HeapCache()
        h.setfield(box1, box2, descr1)
        h.setfield(box1, box3, descr2)
        h.setfield(box2, box3, descr3)
        h.replace_box(box1, box4)
        h.replace_box(box4, box5)
        assert h.getfield(box5, descr1) is box2
        assert h.getfield(box5, descr2) is box3
        assert h.getfield(box2, descr3) is box3
        h.setfield(box5, box3, descr1)
        assert h.getfield(box4, descr1) is box3

        h = HeapCache()
        h.setfield(box1, box2, descr1)
        h.setfield(box1, box3, descr2)
        h.setfield(box2, box3, descr3)
        h.replace_box(box3, box4)
        h.replace_box(box4, box5)
        assert h.getfield(box1, descr1) is box2
        assert h.getfield(box1, descr2) is box5
        assert h.getfield(box2, descr3) is box5
Ejemplo n.º 14
0
    def test_replace_box_twice(self):
        py.test.skip("replacing a box with another box: not supported any more")
        h = HeapCache()
        h.setfield(box1, box2, descr1)
        h.setfield(box1, box3, descr2)
        h.setfield(box2, box3, descr3)
        h.replace_box(box1, box4)
        h.replace_box(box4, box5)
        assert h.getfield(box5, descr1) is box2
        assert h.getfield(box5, descr2) is box3
        assert h.getfield(box2, descr3) is box3
        h.setfield(box5, box3, descr1)
        assert h.getfield(box4, descr1) is box3

        h = HeapCache()
        h.setfield(box1, box2, descr1)
        h.setfield(box1, box3, descr2)
        h.setfield(box2, box3, descr3)
        h.replace_box(box3, box4)
        h.replace_box(box4, box5)
        assert h.getfield(box1, descr1) is box2
        assert h.getfield(box1, descr2) is box5
        assert h.getfield(box2, descr3) is box5