예제 #1
0
 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
예제 #2
0
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()")
예제 #3
0
 def f():
     vref = virtual_ref(X())
     try:
         vref()
         return 42
     except InvalidVirtualRef:
         return -1
예제 #4
0
 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
예제 #5
0
 def enter(self, frame):
     if self.framestackdepth > self.space.sys.recursionlimit:
         raise OperationError(
             self.space.w_RuntimeError,
             self.space.wrap("maximum recursion depth exceeded"))
     self.framestackdepth += 1
     frame.f_backref = self.topframeref
     self.topframeref = jit.virtual_ref(frame)
예제 #6
0
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
예제 #7
0
 def f(n):
     res1 = -42
     while n > 0:
         myjitdriver.jit_merge_point(n=n, res1=res1)
         x = X()
         vref = virtual_ref(x)
         res1 = residual(vref)
         virtual_ref_finish(vref, x)
         n -= 1
     return res1
예제 #8
0
 def f(n):
     res1 = -42
     while n > 0:
         myjitdriver.jit_merge_point(n=n, res1=res1)
         x = X()
         vref = virtual_ref(x)
         res1 = residual(vref)
         virtual_ref_finish(vref, x)
         n -= 1
     return res1
예제 #9
0
 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
예제 #10
0
def test_direct_forced():
    x1 = X()
    vref = virtual_ref(x1)
    assert vref._state == 'non-forced'
    assert vref.virtual is True
    assert vref() is x1
    assert vref._state == 'forced'
    assert vref.virtual is False
    virtual_ref_finish(vref, x1)
    assert vref._state == 'forced'
    assert vref.virtual is False
    assert vref() is x1
예제 #11
0
 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
예제 #12
0
 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()
예제 #13
0
 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 = vref = virtual_ref(xy)
         xy.next1 = lltype.malloc(A, 0)
         n = exctx.topframeref().n - 1
         xy.next1 = lltype.nullptr(A)
         exctx.topframeref = vref_None
         virtual_ref_finish(vref, xy)
     return 1
예제 #14
0
 def fn(n):
     res = 0
     while n > 0:
         myjitdriver.can_enter_jit(n=n, res=res)
         myjitdriver.jit_merge_point(n=n, res=res)
         xy = XY()
         xy.n = n
         vref = virtual_ref(xy)
         force_it(vref, n)
         virtual_ref_finish(vref, xy)
         res += force_it(vref, n) # doesn't raise, because it was already forced
         n -= 1
     return res
예제 #15
0
 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 = vref = virtual_ref(xy)
         xy.next1 = lltype.malloc(A, 0)
         n = exctx.topframeref().n - 1
         xy.next1 = lltype.nullptr(A)
         exctx.topframeref = vref_None
         virtual_ref_finish(vref, xy)
     return 1
예제 #16
0
 def fn(n):
     res = 0
     while n > 0:
         myjitdriver.can_enter_jit(n=n, res=res)
         myjitdriver.jit_merge_point(n=n, res=res)
         xy = XY()
         xy.n = n
         vref = virtual_ref(xy)
         force_it(vref, n)
         virtual_ref_finish(vref, xy)
         res += force_it(
             vref, n)  # doesn't raise, because it was already forced
         n -= 1
     return res
예제 #17
0
 def f(frame, n, reclevel):
     while n > 0:
         myjitdriver.can_enter_jit(n=n, frame=frame, rec=reclevel)
         myjitdriver.jit_merge_point(n=n, frame=frame, rec=reclevel)
         if reclevel == 0:
             return n
         xy = XY()
         exctx.topframeref = vref = virtual_ref(xy)
         m = f(xy, n, reclevel-1)
         assert m == n
         n -= 1
         exctx.topframeref = vref_None
         virtual_ref_finish(vref, xy)
     return 2
예제 #18
0
 def f(frame, n, reclevel):
     while n > 0:
         myjitdriver.can_enter_jit(n=n, frame=frame, rec=reclevel)
         myjitdriver.jit_merge_point(n=n, frame=frame, rec=reclevel)
         if reclevel == 0:
             return n
         xy = XY()
         exctx.topframeref = vref = virtual_ref(xy)
         m = f(xy, n, reclevel - 1)
         assert m == n
         n -= 1
         exctx.topframeref = vref_None
         virtual_ref_finish(vref, xy)
     return 2
예제 #19
0
 def f(n):
     while n > 0:
         jitdriver.can_enter_jit(n=n)
         jitdriver.jit_merge_point(n=n)
         x = X()
         x.n = n
         exctx.topframeref = vref = virtual_ref(x)
         # here, 'x' should be virtual
         exctx.topframeref = vref_None
         virtual_ref_finish(vref, x)
         # 'x' and 'vref' can randomly escape after the call to
         # finish().
         g(vref)
         n -= 1
     return 1
예제 #20
0
 def f(n):
     while n > 0:
         myjitdriver.jit_merge_point(n=n)
         xy = XY()
         xy.n = n
         vr = virtual_ref(xy)
         # force the virtualref to be allocated
         exctx.vr = vr
         # force xy to be allocated
         escapexy(xy)
         # clean up
         exctx.vr = vref_None
         virtual_ref_finish(vr, xy)
         n -= 1
     return 1
예제 #21
0
 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)
         exctx.topframeref = virtual_ref(xy)
         n -= externalfn(n)
         exctx.topframeref = vref_None
         xy.next1 = lltype.nullptr(A)
         xy.next2 = lltype.nullptr(A)
         xy.next3 = lltype.nullptr(A)
         virtual_ref_finish(xy)
예제 #22
0
 def f(n):
     while n > 0:
         myjitdriver.jit_merge_point(n=n)
         xy = XY()
         xy.n = n
         vr = virtual_ref(xy)
         # force the virtualref to be allocated
         exctx.vr = vr
         # force xy to be allocated
         escapexy(xy)
         # clean up
         exctx.vr = vref_None
         virtual_ref_finish(vr, xy)
         n -= 1
     return 1
예제 #23
0
 def f(n):
     while n > 0:
         jitdriver.can_enter_jit(n=n)
         jitdriver.jit_merge_point(n=n)
         x = X()
         x.n = n
         exctx.topframeref = vref = virtual_ref(x)
         # here, 'x' should be virtual
         exctx.topframeref = vref_None
         virtual_ref_finish(vref, x)
         # 'x' and 'vref' can randomly escape after the call to
         # finish().
         g(vref)
         n -= 1
     return 1
예제 #24
0
 def f(frame, n, reclevel):
     while n > 0:
         myjitdriver.can_enter_jit(n=n, frame=frame, rec=reclevel)
         myjitdriver.jit_merge_point(n=n, frame=frame, rec=reclevel)
         frame.n += 1
         xy = XY()
         xy.n = n
         exctx.topframeref = vref = virtual_ref(xy)
         if reclevel > 0:
             m = f(xy, frame.n, reclevel - 1)
             assert xy.n == m
             n -= 1
         else:
             n -= 2
         exctx.topframeref = vref_None
         virtual_ref_finish(vref, xy)
     return frame.n
예제 #25
0
 def f(frame, n, reclevel):
     while n > 0:
         myjitdriver.can_enter_jit(n=n, frame=frame, rec=reclevel)
         myjitdriver.jit_merge_point(n=n, frame=frame, rec=reclevel)
         frame.n += 1
         xy = XY()
         xy.n = n
         exctx.topframeref = vref = virtual_ref(xy)
         if reclevel > 0:
             m = f(xy, frame.n, reclevel-1)
             assert xy.n == m
             n -= 1
         else:
             n -= 2
         exctx.topframeref = vref_None
         virtual_ref_finish(vref, xy)
     return frame.n
예제 #26
0
 def f():
     x1 = X()
     vref = virtual_ref(x1)
     x2 = vref()
     virtual_ref_finish(vref, x1)
     return x2
예제 #27
0
 def f(n):
     if n > 0:
         return virtual_ref(Y())
     else:
         return non_virtual_ref(Z())
예제 #28
0
 def fn():
     x = X()
     vref = virtual_ref(x)
     x1 = vref()  # jit_force_virtual
     virtual_ref_finish(vref, x)
예제 #29
0
 def enter(self, frame):
     frame.f_backref = self.topframeref
     self.topframeref = jit.virtual_ref(frame)
예제 #30
0
 def f():
     return jit.virtual_ref(X())
예제 #31
0
파일: test_flatten.py 프로젝트: ieure/pypy
 def f():
     return jit.virtual_ref(X())
예제 #32
0
 def f():
     vref = virtual_ref(X())
     return vref.virtual
예제 #33
0
 def f():
     x = X()
     exctx.topframeref = vref = virtual_ref(x)
     exctx.topframeref = vref_None
     virtual_ref_finish(vref, x)
     return 1
예제 #34
0
 def f(n, x, x0, x1, x2, x3, x4, x5, x6, x7, l, s):
     a = A()
     glob.v = virtual_ref(a)
     virtual_ref_finish(a)
     n -= 1
     return n, x, x0, x1, x2, x3, x4, x5, x6, x7, l, s
예제 #35
0
 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
예제 #36
0
파일: test_flatten.py 프로젝트: ieure/pypy
 def f():
     vref = jit.virtual_ref(X())
     return vref()
예제 #37
0
 def f(n):
     if n > 0:
         return virtual_ref(X())
     else:
         return vref_None
예제 #38
0
 def f():
     x = X()
     exctx.topframeref = vref = virtual_ref(x)
     exctx.topframeref = vref_None
     virtual_ref_finish(vref, x)
     return 1
예제 #39
0
 def enter(n):
     x = X(n + 10)
     exctx._frame = x
     exctx.topframeref = virtual_ref(x)
예제 #40
0
 def enter(self, frame):
     frame.f_backref = self.topframeref
     self.topframeref = jit.virtual_ref(frame)
예제 #41
0
 def f():
     vref = jit.virtual_ref(X())
     return vref()
예제 #42
0
 def fn():
     x = X()
     vref = virtual_ref(x)
     x1 = vref()                  # jit_force_virtual
     virtual_ref_finish(vref, x)
예제 #43
0
 def f():
     return virtual_ref(X())
예제 #44
0
 def enter(n):
     x = X(n + 10)
     exctx._frame = x
     exctx.topframeref = virtual_ref(x)
예제 #45
0
def test_direct_2():
    x1 = X()
    vref = virtual_ref(x1)
    virtual_ref_finish(x1)
    assert vref() is x1