本文整理汇总了Python中pypy.jit.metainterp.heapcache.HeapCache.setfield方法的典型用法代码示例。如果您正苦于以下问题:Python HeapCache.setfield方法的具体用法?Python HeapCache.setfield怎么用?Python HeapCache.setfield使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypy.jit.metainterp.heapcache.HeapCache
的用法示例。
在下文中一共展示了HeapCache.setfield方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_invalidate_cache
# 需要导入模块: from pypy.jit.metainterp.heapcache import HeapCache [as 别名]
# 或者: from pypy.jit.metainterp.heapcache.HeapCache import setfield [as 别名]
def test_invalidate_cache(self):
h = HeapCache()
h.setfield(box1, descr1, box2)
h.setarrayitem(box1, descr1, index1, box2)
h.setarrayitem(box1, descr1, index2, box4)
h.invalidate_caches(rop.INT_ADD, None, [])
h.invalidate_caches(rop.INT_ADD_OVF, None, [])
h.invalidate_caches(rop.SETFIELD_RAW, None, [])
h.invalidate_caches(rop.SETARRAYITEM_RAW, None, [])
assert h.getfield(box1, descr1) is box2
assert h.getarrayitem(box1, descr1, index1) is box2
assert h.getarrayitem(box1, descr1, index2) is box4
h.invalidate_caches(
rop.CALL, FakeCallDescr(FakeEffektinfo.EF_ELIDABLE_CANNOT_RAISE), [])
assert h.getfield(box1, descr1) is box2
assert h.getarrayitem(box1, descr1, index1) is box2
assert h.getarrayitem(box1, descr1, index2) is box4
h.invalidate_caches(
rop.CALL_LOOPINVARIANT, FakeCallDescr(FakeEffektinfo.EF_LOOPINVARIANT), [])
h.invalidate_caches(
rop.CALL, FakeCallDescr(FakeEffektinfo.EF_RANDOM_EFFECTS), [])
assert h.getfield(box1, descr1) is None
assert h.getarrayitem(box1, descr1, index1) is None
assert h.getarrayitem(box1, descr1, index2) is None
示例2: test_replace_box
# 需要导入模块: from pypy.jit.metainterp.heapcache import HeapCache [as 别名]
# 或者: from pypy.jit.metainterp.heapcache.HeapCache import setfield [as 别名]
def test_replace_box(self):
h = HeapCache()
h.setfield(box1, descr1, box2)
h.setfield(box1, descr2, box3)
h.setfield(box2, descr3, box3)
h.replace_box(box1, box4)
assert h.getfield(box1, descr1) is None
assert h.getfield(box1, descr2) is None
assert h.getfield(box4, descr1) is box2
assert h.getfield(box4, descr2) is box3
assert h.getfield(box2, descr3) is box3
示例3: test_replace_box_twice
# 需要导入模块: from pypy.jit.metainterp.heapcache import HeapCache [as 别名]
# 或者: from pypy.jit.metainterp.heapcache.HeapCache import setfield [as 别名]
def test_replace_box_twice(self):
h = HeapCache()
h.setfield(box1, descr1, box2)
h.setfield(box1, descr2, box3)
h.setfield(box2, descr3, box3)
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, descr1, box3)
assert h.getfield(box4, descr1) is box3
h = HeapCache()
h.setfield(box1, descr1, box2)
h.setfield(box1, descr2, box3)
h.setfield(box2, descr3, box3)
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
示例4: test_heapcache_fields
# 需要导入模块: from pypy.jit.metainterp.heapcache import HeapCache [as 别名]
# 或者: from pypy.jit.metainterp.heapcache.HeapCache import setfield [as 别名]
def test_heapcache_fields(self):
h = HeapCache()
assert h.getfield(box1, descr1) is None
assert h.getfield(box1, descr2) is None
h.setfield(box1, descr1, box2)
assert h.getfield(box1, descr1) is box2
assert h.getfield(box1, descr2) is None
h.setfield(box1, descr2, box3)
assert h.getfield(box1, descr1) is box2
assert h.getfield(box1, descr2) is box3
h.setfield(box1, descr1, box3)
assert h.getfield(box1, descr1) is box3
assert h.getfield(box1, descr2) is box3
h.setfield(box3, descr1, box1)
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
示例5: test_heapcache_write_fields_multiple
# 需要导入模块: from pypy.jit.metainterp.heapcache import HeapCache [as 别名]
# 或者: from pypy.jit.metainterp.heapcache.HeapCache import setfield [as 别名]
def test_heapcache_write_fields_multiple(self):
h = HeapCache()
h.setfield(box1, descr1, box2)
assert h.getfield(box1, descr1) is box2
h.setfield(box3, descr1, box4)
assert h.getfield(box3, descr1) is box4
assert h.getfield(box1, descr1) is None # box1 and box3 can alias
h = HeapCache()
h.new(box1)
h.setfield(box1, descr1, box2)
assert h.getfield(box1, descr1) is box2
h.setfield(box3, descr1, box4)
assert h.getfield(box3, descr1) is box4
assert h.getfield(box1, descr1) is None # box1 and box3 can alias
h = HeapCache()
h.new(box1)
h.new(box3)
h.setfield(box1, descr1, box2)
assert h.getfield(box1, descr1) is box2
h.setfield(box3, descr1, box4)
assert h.getfield(box3, descr1) is box4
assert h.getfield(box1, descr1) is box2 # box1 and box3 cannot alias
h.setfield(box1, descr1, box3)
assert h.getfield(box1, descr1) is box3