Exemple #1
0
 def delete(self):
     cur = self.chunk
     while cur:
         prev = cur.previous
         unused_chunks.put(cur)
         cur = prev
     free_non_gc_object(self)
Exemple #2
0
 def bootstrap(self):
     state.my_thread_ident = get_ident()
     assert state.my_thread_ident == get_ident()
     state.seen_value = self.z.value
     self.z = None
     free_non_gc_object(self)
     state.done = 1
Exemple #3
0
 def bootstrap(self):
     state.my_thread_ident = get_ident()
     assert state.my_thread_ident == get_ident()
     state.seen_value = self.z.value
     self.z = None
     free_non_gc_object(self)
     state.done = 1
Exemple #4
0
 def delete(self):
     cur = self.oldest_chunk
     while cur:
         next = cur.next
         unused_chunks.put(cur)
         cur = next
     free_non_gc_object(self)
Exemple #5
0
 def delete(self):
     cur = self.oldest_chunk
     while cur:
         next = cur.next
         unused_chunks.put(cur)
         cur = next
     free_non_gc_object(self)
Exemple #6
0
def test_free_non_gc_object():
    class TestClass(object):
        _alloc_flavor_ = ""

        def __init__(self, a):
            self.a = a

        def method1(self):
            return self.a

        def method2(self):
            return 42

    class TestClass2(object):
        pass

    t = TestClass(1)
    assert t.method1() == 1
    assert t.method2() == 42
    free_non_gc_object(t)
    py.test.raises(RuntimeError, "t.method1()")
    py.test.raises(RuntimeError, "t.method2()")
    py.test.raises(RuntimeError, "t.a")
    py.test.raises(RuntimeError, "t.a = 1")
    py.test.raises(AssertionError, "free_non_gc_object(TestClass2())")
Exemple #7
0
 def f():
     from pypy.rlib.objectmodel import free_non_gc_object
     state.freed_counter = 0
     x = g()
     assert state.freed_counter == 0
     x.y = None
     assert state.freed_counter == 1
     free_non_gc_object(x)
Exemple #8
0
 def bootstrap(self):
     space = self.space
     space.threadlocals.enter_thread(space)
     try:
         self.run()
     finally:
         # release ownership of these objects before we release the GIL.
         # (for the refcounting gc it is necessary to reset the fields to
         # None before we use free_non_gc_object(), because the latter
         # doesn't know that it needs to decref the fields)
         self.args = None
         self.w_callable = None
         # we can free the empty 'self' structure now
         free_non_gc_object(self)
         # clean up space.threadlocals to remove the ExecutionContext
         # entry corresponding to the current thread and release the GIL
         space.threadlocals.leave_thread(space)
Exemple #9
0
 def bootstrap(self):
     space = self.space
     space.threadlocals.enter_thread(space)
     try:
         self.run()
     finally:
         # release ownership of these objects before we release the GIL.
         # (for the refcounting gc it is necessary to reset the fields to
         # None before we use free_non_gc_object(), because the latter
         # doesn't know that it needs to decref the fields)
         self.args       = None
         self.w_callable = None
         # we can free the empty 'self' structure now
         free_non_gc_object(self)
         # clean up space.threadlocals to remove the ExecutionContext
         # entry corresponding to the current thread and release the GIL
         space.threadlocals.leave_thread(space)
Exemple #10
0
 def f(i):
     a = A()
     b = B()
     c = C()
     d = None
     e = None
     if i == 0:
         d = a
     elif i == 1:
         d = b
     elif i == 2:
         e = c
     res = (0x0001 * (a is b) | 0x0002 * (a is c) | 0x0004 * (a is d)
            | 0x0008 * (a is e) | 0x0010 * (b is c) | 0x0020 * (b is d)
            | 0x0040 * (b is e) | 0x0080 * (c is d) | 0x0100 * (c is e)
            | 0x0200 * (d is e))
     free_non_gc_object(a)
     free_non_gc_object(b)
     return res
Exemple #11
0
 def f(i):
     a = A()
     b = B()
     c = C()
     d = None
     e = None
     if i == 0:
         d = a
     elif i == 1:
         d = b
     elif i == 2:
         e = c
     res =  (0x0001*(a is b) | 0x0002*(a is c) | 0x0004*(a is d) |
             0x0008*(a is e) | 0x0010*(b is c) | 0x0020*(b is d) |
             0x0040*(b is e) | 0x0080*(c is d) | 0x0100*(c is e) |
             0x0200*(d is e))
     free_non_gc_object(a)
     free_non_gc_object(b)
     return res
Exemple #12
0
def test_free_non_gc_object():
    class TestClass(object):
        _alloc_flavor_ = ""
        def __init__(self, a):
            self.a = a
        def method1(self):
            return self.a
        def method2(self):
            return 42
    class TestClass2(object):
        pass
    t = TestClass(1)
    assert t.method1() == 1
    assert t.method2() == 42
    free_non_gc_object(t)
    py.test.raises(RuntimeError, "t.method1()")
    py.test.raises(RuntimeError, "t.method2()") 
    py.test.raises(RuntimeError, "t.a")
    py.test.raises(RuntimeError, "t.a = 1")
    py.test.raises(AssertionError, "free_non_gc_object(TestClass2())")
Exemple #13
0
 def f(i):
     if i == 0:
         o = None
     elif i == 1:
         o = A()
     elif i == 2:
         o = B()
     else:
         o = C()
     res = 100*isinstance(o, A) + 10*isinstance(o, B) + 1*isinstance(o, C)
     if i == 0:
         pass
     elif i == 1:
         assert isinstance(o, A)
         free_non_gc_object(o)
     elif i == 2:
         assert isinstance(o, B)
         free_non_gc_object(o)
     else:
         assert isinstance(o, C)
         free_non_gc_object(o)
     return res
Exemple #14
0
 def f(i):
     if i == 0:
         o = None
     elif i == 1:
         o = A()
     elif i == 2:
         o = B()
     else:
         o = C()
     res = 100 * isinstance(o, A) + 10 * isinstance(o, B) + 1 * isinstance(
         o, C)
     if i == 0:
         pass
     elif i == 1:
         assert isinstance(o, A)
         free_non_gc_object(o)
     elif i == 2:
         assert isinstance(o, B)
         free_non_gc_object(o)
     else:
         assert isinstance(o, C)
         free_non_gc_object(o)
     return res
Exemple #15
0
 def malloc_and_free(a):
     ci = TestClass(a)
     b = ci.method1()
     free_non_gc_object(ci)
     return b
Exemple #16
0
 def f(x):
     a = A(x + 1)
     result = a.val
     free_non_gc_object(a)
     return result
Exemple #17
0
 def delete(self):
     if self.gcflag == 0:
         self.seen.delete()
     self.pending.delete()
     lltype.free(self.writebuffer, flavor='raw')
     free_non_gc_object(self)
 def f(x):
     a = A(x + 1)
     result = a.val
     free_non_gc_object(a)
     return result
Exemple #19
0
 def malloc_and_free(a):
     ci = TestClass(a)
     b = ci.method1()
     free_non_gc_object(ci)
     return b