Exemple #1
0
 def f():
     s = lltype.malloc(S)
     gc_swap_pool(None)
     try:
         t = gc_clone(s, None)
     except RuntimeError:
         return 1
     else:
         return 0
Exemple #2
0
        def func(n, dummy):
            lst = [A() for i in range(n)]
            for a in lst:
                a.value = 1
            lst2, newpool = rgc.gc_clone(lst, None)
            for i in range(n):
                a = A()
                a.value = i
                lst.append(a)
                lst[i].value = 4 + i
                lst2[i].value = 7 + i

            n = 0
            for a in lst:
                n = n*10 + a.value
            for a in lst2:
                n = n*10 + a.value
            return n
Exemple #3
0
 def clone_into(self, copy, extradata=None):
     if not we_are_translated():
         raise NotImplementedError
     # cannot gc_clone() directly self, because it is not in its own
     # local_pool.  Moreover, it has a __del__, which cloning doesn't
     # support properly at the moment.
     copy.parent = self.parent
     # the hello/goodbye pair has two purposes: it forces
     # self.local_pool to be computed even if it was None up to now,
     # and it puts the 'data' tuple in the correct pool to be cloned.
     self.hello_local_pool()
     data = (self.frame, extradata)
     self.goodbye_local_pool()
     # clone!
     data, copy.local_pool = gc_clone(data, self.local_pool)
     copy.frame, extradata = data
     copy.thunk = self.thunk # in case we haven't switched to self yet
     return extradata
Exemple #4
0
 def func(n, dummy):
     if n > 5:
         x = A()
     else:
         x = B()
         x.bvalue = 123
     x.next = A()
     x.next.next = x
     y, newpool = rgc.gc_clone(x, None)
     assert y is not x
     assert y.next is not x
     assert y is not x.next
     assert y.next is not x.next
     assert y is not y.next
     assert y is y.next.next
     if isinstance(y, B):
         assert n <= 5
         assert y.bvalue == 123
     else:
         assert n > 5
     return 1
Exemple #5
0
 def func(n, dummy):
     if n > 5:
         x = A()
     else:
         x = B()
         x.bvalue = 123
     x.next = A()
     x.next.next = x
     y, newpool = rgc.gc_clone(x, None)
     assert y is not x
     assert y.next is not x
     assert y is not x.next
     assert y.next is not x.next
     assert y is not y.next
     assert y is y.next.next
     if isinstance(y, B):
         assert n <= 5
         assert y.bvalue == 123
     else:
         assert n > 5
     return 1
Exemple #6
0
def gc_clone(data, pool):
    if we_are_translated():
        return rgc.gc_clone(data, pool)