[pypy-svn] r24466 - in pypy/dist/pypy/rpython/memory: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Thu Mar 16 15:02:23 CET 2006


Author: cfbolz
Date: Thu Mar 16 15:02:22 2006
New Revision: 24466

Modified:
   pypy/dist/pypy/rpython/memory/gctransform.py
   pypy/dist/pypy/rpython/memory/test/test_gctransform.py
Log:
fix the quite broken gc_(un)protect code:
  * raise NotImplementedError in the base class, since (un)protect does not
    make sense for most gcs
  * make sure that the new operation introduced by replace_gc_(un)protect has
    the same result variable as the replaced operation. Otherwise we will end
    up with graphs that are missing a variable.


Modified: pypy/dist/pypy/rpython/memory/gctransform.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gctransform.py	(original)
+++ pypy/dist/pypy/rpython/memory/gctransform.py	Thu Mar 16 15:02:22 2006
@@ -216,12 +216,14 @@
         return [SpaceOperation("gc_pop_alive_pyobj", [var], result)]
 
     def replace_gc_protect(self, op, livevars):
-        """ protect this object from gc (make it immortal) """
-        return [], []
+        """ protect this object from gc (make it immortal). the specific
+        gctransformer needs to overwrite this"""
+        raise NotImplementedError("gc_protect does not make sense for this gc")
 
     def replace_gc_unprotect(self, op, livevars):
-        """ get this object back into gc control """
-        return [], []
+        """ get this object back into gc control. the specific gctransformer
+        needs to overwrite this"""
+        raise NotImplementedError("gc_protect does not make sense for this gc")
 
     def annotate_helper(self, ll_helper, ll_args, ll_result):
         assert not self.finished
@@ -367,11 +369,15 @@
 
     def replace_gc_protect(self, op, livevars):
         """ protect this object from gc (make it immortal) """
-        return self.push_alive(op.args[0]), []
+        newops = self.push_alive(op.args[0])
+        newops[-1].result = op.result
+        return newops, []
 
     def replace_gc_unprotect(self, op, livevars):
         """ get this object back into gc control """
-        return self.pop_alive(op.args[0]), []
+        newops = self.pop_alive(op.args[0])
+        newops[-1].result = op.result
+        return newops, []
 
     def replace_setfield(self, op, livevars):
         if not var_needsgc(op.args[2]):
@@ -583,6 +589,14 @@
     def pop_alive_nopyobj(self, var):
         return []
 
+    def replace_gc_protect(self, op, livevars):
+        """ for boehm it is enough to do nothing"""
+        return [SpaceOperation("same_as", [Constant(None, lltype.Void)], op.result)], []
+
+    def replace_gc_unprotect(self, op, livevars):
+        """ for boehm it is enough to do nothing"""
+        return [SpaceOperation("same_as", [Constant(None, lltype.Void)], op.result)], []
+
     def get_rtti(self, TYPE):
         if isinstance(TYPE, lltype.GcStruct):
             try:

Modified: pypy/dist/pypy/rpython/memory/test/test_gctransform.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/test/test_gctransform.py	(original)
+++ pypy/dist/pypy/rpython/memory/test/test_gctransform.py	Thu Mar 16 15:02:22 2006
@@ -231,8 +231,8 @@
     extregistry.register_value(unprotect,
         compute_result_annotation=annmodel.s_None, specialize_call=rtype_unprotect)
 
-    def p():    protect('this is an object')
-    def u():    unprotect('this is an object')
+    def p():    return protect('this is an object')
+    def u():    return unprotect('this is an object')
 
     rgc = gctransform.RefcountingGCTransformer
     bgc = gctransform.BoehmGCTransformer



More information about the Pypy-commit mailing list