def test_ll_arraycopy(self): h = HeapCache() h.new_array(box1, lengthbox1) h.setarrayitem(box1, descr1, index1, box2) h.new_array(box2, lengthbox1) # Just need the destination box for this call h.invalidate_caches( rop.CALL, FakeCallDescr(FakeEffektinfo.EF_CANNOT_RAISE, FakeEffektinfo.OS_ARRAYCOPY), [None, None, box2, None, None] ) assert h.getarrayitem(box1, descr1, index1) is box2 h.invalidate_caches( rop.CALL, FakeCallDescr(FakeEffektinfo.EF_CANNOT_RAISE, FakeEffektinfo.OS_ARRAYCOPY), [None, None, box3, None, None] ) assert h.getarrayitem(box1, descr1, index1) is None h.setarrayitem(box4, descr1, index1, box2) assert h.getarrayitem(box4, descr1, index1) is box2 h.invalidate_caches( rop.CALL, FakeCallDescr(FakeEffektinfo.EF_CANNOT_RAISE, FakeEffektinfo.OS_ARRAYCOPY), [None, None, box2, None, None] ) assert h.getarrayitem(box4, descr1, index1) is None
def test_ll_arraycopy(self): h = HeapCache() h.new_array(box1, lengthbox1) h.setarrayitem(box1, descr1, index1, box2) h.new_array(box2, lengthbox1) # Just need the destination box for this call h.invalidate_caches( rop.CALL, FakeCallDescr(FakeEffektinfo.EF_CANNOT_RAISE, FakeEffektinfo.OS_ARRAYCOPY), [None, None, box2, None, None]) assert h.getarrayitem(box1, descr1, index1) is box2 h.invalidate_caches( rop.CALL, FakeCallDescr(FakeEffektinfo.EF_CANNOT_RAISE, FakeEffektinfo.OS_ARRAYCOPY), [None, None, box3, None, None]) assert h.getarrayitem(box1, descr1, index1) is None h.setarrayitem(box4, descr1, index1, box2) assert h.getarrayitem(box4, descr1, index1) is box2 h.invalidate_caches( rop.CALL, FakeCallDescr(FakeEffektinfo.EF_CANNOT_RAISE, FakeEffektinfo.OS_ARRAYCOPY), [None, None, box2, None, None]) assert h.getarrayitem(box4, descr1, index1) is None
def test_length_cache(self): h = HeapCache() h.new_array(box1, lengthbox1) assert h.arraylen(box1) is lengthbox1 assert h.arraylen(box2) is None h.arraylen_now_known(box2, lengthbox2) assert h.arraylen(box2) is lengthbox2
def test_length_cache(self): h = HeapCache() h.new_array(box1, lengthbox1) assert h.arraylen(box1) is lengthbox1 assert h.arraylen(box2) is None h.arraylen_now_known(box2, lengthbox2) assert h.arraylen(box2) is lengthbox2
def test_unescaped_array(self): h = HeapCache() h.new_array(box1, lengthbox1) assert h.is_unescaped(box1) h.invalidate_caches(rop.SETARRAYITEM_GC, None, [box1, index1, box2]) assert h.is_unescaped(box1) h.invalidate_caches(rop.SETARRAYITEM_GC, None, [box2, index1, box1]) assert not h.is_unescaped(box1)
def test_unescaped_array(self): h = HeapCache() h.new_array(box1, lengthbox1) assert h.is_unescaped(box1) h.invalidate_caches(rop.SETARRAYITEM_GC, None, [box1, index1, box2]) assert h.is_unescaped(box1) h.invalidate_caches(rop.SETARRAYITEM_GC, None, [box2, index1, box1]) assert not h.is_unescaped(box1) h = HeapCache() h.new_array(box1, lengthbox1) h.new(box2) assert h.is_unescaped(box1) assert h.is_unescaped(box2) h.invalidate_caches(rop.SETARRAYITEM_GC, None, [box1, lengthbox2, box2]) assert h.is_unescaped(box1) assert h.is_unescaped(box2) h.invalidate_caches( rop.CALL, FakeCallDescr(FakeEffektinfo.EF_RANDOM_EFFECTS), [box1] ) assert not h.is_unescaped(box1) assert not h.is_unescaped(box2)
def test_unescaped_array(self): h = HeapCache() h.new_array(box1, lengthbox1) assert h.is_unescaped(box1) h.invalidate_caches(rop.SETARRAYITEM_GC, None, [box1, index1, box2]) assert h.is_unescaped(box1) h.invalidate_caches(rop.SETARRAYITEM_GC, None, [box2, index1, box1]) assert not h.is_unescaped(box1) h = HeapCache() h.new_array(box1, lengthbox1) h.new(box2) assert h.is_unescaped(box1) assert h.is_unescaped(box2) h.invalidate_caches(rop.SETARRAYITEM_GC, None, [box1, lengthbox2, box2]) assert h.is_unescaped(box1) assert h.is_unescaped(box2) h.invalidate_caches( rop.CALL, FakeCallDescr(FakeEffektinfo.EF_RANDOM_EFFECTS), [box1] ) assert not h.is_unescaped(box1) assert not h.is_unescaped(box2)