[pypy-svn] r65192 - in pypy/branch/pyjitpl5/pypy/jit: backend/llgraph metainterp/test

arigo at codespeak.net arigo at codespeak.net
Sun May 10 12:56:51 CEST 2009


Author: arigo
Date: Sun May 10 12:56:50 2009
New Revision: 65192

Modified:
   pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py
   pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py
Log:
A test for clean_up_history().  Passes, with a few extra clean-ups
in the llgraph backend.


Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py	Sun May 10 12:56:50 2009
@@ -820,6 +820,7 @@
     frame.env = {}
     for i in range(len(loop.inputargs)):
         frame.env[loop.inputargs[i]] = _future_values[i]
+    del _future_values[:]
 
 def set_future_value_int(index, value):
     del _future_values[index:]
@@ -853,6 +854,7 @@
             import sys, pdb
             pdb.post_mortem(sys.exc_info()[2])
         raise
+    del frame.env
     return result
 
 def frame_int_getvalue(frame, num):
@@ -861,15 +863,9 @@
 
 def frame_ptr_getvalue(frame, num):
     frame = _from_opaque(frame)
-    return frame.fail_args[num]
-
-def frame_int_getresult(frame):
-    frame = _from_opaque(frame)
-    return frame.returned_value
-
-def frame_ptr_getresult(frame):
-    frame = _from_opaque(frame)
-    return frame.returned_value
+    result = frame.fail_args[num]
+    frame.fail_args[num] = None
+    return result
 
 _last_exception = None
 
@@ -1228,8 +1224,6 @@
 setannotation(frame_execute, annmodel.SomeInteger())
 setannotation(frame_int_getvalue, annmodel.SomeInteger())
 setannotation(frame_ptr_getvalue, annmodel.SomePtr(llmemory.GCREF))
-setannotation(frame_int_getresult, annmodel.SomeInteger())
-setannotation(frame_ptr_getresult, annmodel.SomePtr(llmemory.GCREF))
 
 setannotation(get_exception, annmodel.SomeAddress())
 setannotation(get_exc_value, annmodel.SomePtr(llmemory.GCREF))

Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py	Sun May 10 12:56:50 2009
@@ -639,6 +639,33 @@
         res = self.interp_operations(f, [1000000000, 90, 91])
         assert res == (1000000000 * 90 // 91) // 3
 
+    def test_free_object(self):
+        import weakref
+        from pypy.rlib import rgc
+        from pypy.rpython.lltypesystem.lloperation import llop
+        myjitdriver = JitDriver(greens = [], reds = ['n', 'x'])
+        class X(object):
+            pass
+        def main(n, x):
+            while n > 0:
+                myjitdriver.can_enter_jit(n=n, x=x)
+                myjitdriver.jit_merge_point(n=n, x=x)
+                n -= x.foo
+        def g(n):
+            x = X()
+            x.foo = 2
+            main(n, x)
+            x.foo = 5
+            return weakref.ref(x)
+        def f(n):
+            r = g(n)
+            rgc.collect(); rgc.collect(); rgc.collect()
+            return r() is None
+        #
+        assert f(30) == 1
+        res = self.meta_interp(f, [30])
+        assert res == 1
+
 
 class TestOOtype(BasicTests, OOJitMixin):
 



More information about the Pypy-commit mailing list