本文整理汇总了Python中pypy.rlib.jit.virtual_ref函数的典型用法代码示例。如果您正苦于以下问题:Python virtual_ref函数的具体用法?Python virtual_ref怎么用?Python virtual_ref使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了virtual_ref函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_direct_invalid
def test_direct_invalid():
x1 = X()
vref = virtual_ref(x1)
assert vref._state == 'non-forced'
virtual_ref_finish(vref, x1)
assert vref._state == 'invalid'
py.test.raises(InvalidVirtualRef, "vref()")
示例2: f
def f(n):
while n > 0:
myjitdriver.can_enter_jit(n=n)
myjitdriver.jit_merge_point(n=n)
xy = XY()
xy.next1 = lltype.malloc(A, 0)
xy.next2 = lltype.malloc(A, 0)
xy.next3 = lltype.malloc(A, 0)
xy.next4 = lltype.malloc(A, 0)
xy.next5 = lltype.malloc(A, 0)
xy.n = n
exctx.topframeref = vref = virtual_ref(xy)
if n % 6 == 0:
xy.next1 = lltype.nullptr(A)
xy.next2 = lltype.nullptr(A)
xy.next3 = lltype.nullptr(A)
externalfn(n)
n -= 1
exctx.topframeref = vref_None
xy.next1 = lltype.nullptr(A)
xy.next2 = lltype.nullptr(A)
xy.next3 = lltype.nullptr(A)
xy.next4 = lltype.nullptr(A)
xy.next5 = lltype.nullptr(A)
virtual_ref_finish(vref, xy)
return exctx.m
示例3: f
def f():
vref = virtual_ref(X())
try:
vref()
return 42
except InvalidVirtualRef:
return -1
示例4: test_direct_forced
def test_direct_forced():
x1 = X()
vref = virtual_ref(x1)
assert vref._state == 'non-forced'
assert vref() is x1
assert vref._state == 'forced'
virtual_ref_finish(vref, x1)
assert vref._state == 'forced'
assert vref() is x1
示例5: fn
def fn(n):
res = False
while n > 0:
myjitdriver.can_enter_jit(n=n)
myjitdriver.jit_merge_point(n=n)
xy = XY()
xy.n = n
vref = virtual_ref(xy)
virtual_ref_finish(vref, xy)
vref() # raises InvalidVirtualRef when jitted
n -= 1
return res
示例6: f
def f(n):
while n > 0:
myjitdriver.can_enter_jit(n=n)
myjitdriver.jit_merge_point(n=n)
xy = XY()
xy.n = n
exctx.topframeref = virtual_ref(xy)
exctx.later = exctx.topframeref
n -= 1
exctx.topframeref = vref_None
virtual_ref_finish(xy)
return g()
示例7: f
def f(n, x, x0, x1, x2, x3, x4, x5, x6, x7, l, s):
a = A()
glob.v = vref = virtual_ref(a)
virtual_ref_finish(vref, a)
n -= 1
return n, x, x0, x1, x2, x3, x4, x5, x6, x7, l, s
示例8: enter
def enter(n):
x = X(n + 10)
exctx._frame = x
exctx.topframeref = virtual_ref(x)
示例10: enter
def enter(self, frame):
frame.f_backref = self.topframeref
self.topframeref = jit.virtual_ref(frame)
示例11: test_direct_2
def test_direct_2():
x1 = X()
vref = virtual_ref(x1)
virtual_ref_finish(x1)
assert vref() is x1