[pypy-svn] r23529 - in pypy/dist/pypy: annotation rpython rpython/lltypesystem

arigo at codespeak.net arigo at codespeak.net
Mon Feb 20 23:21:10 CET 2006


Author: arigo
Date: Mon Feb 20 23:21:09 2006
New Revision: 23529

Modified:
   pypy/dist/pypy/annotation/annrpython.py
   pypy/dist/pypy/rpython/annlowlevel.py
   pypy/dist/pypy/rpython/lltypesystem/lltype.py
Log:
(pedronis, arigo)

Sometimes we need prebuilt constant structs whose type is still a delayed
GcForwardReference...  Added support for this case in the
MixLevelHelperAnnotator with the help of lltype._ptr.



Modified: pypy/dist/pypy/annotation/annrpython.py
==============================================================================
--- pypy/dist/pypy/annotation/annrpython.py	(original)
+++ pypy/dist/pypy/annotation/annrpython.py	Mon Feb 20 23:21:09 2006
@@ -200,8 +200,9 @@
                         blocked_err.append('-+' * 30 +'\n')
                         log.ERROR(''.join(blocked_err))
 
-            raise AnnotatorError('%d blocks are still blocked' %
-                                 self.annotated.values().count(False))
+            blocked_blocks = [block for block, done in self.annotated.items()
+                                    if done is False]
+            raise AnnotatorError('%d blocks are still blocked' % len(blocked_blocks))
         # make sure that the return variables of all graphs is annotated
         if self.added_blocks is not None:
             newgraphs = [self.annotated[block] for block in self.added_blocks]

Modified: pypy/dist/pypy/rpython/annlowlevel.py
==============================================================================
--- pypy/dist/pypy/rpython/annlowlevel.py	(original)
+++ pypy/dist/pypy/rpython/annlowlevel.py	Mon Feb 20 23:21:09 2006
@@ -119,6 +119,7 @@
         self.policy = MixLevelAnnotatorPolicy(rtyper)
         self.pending = []     # list of (graph, args_s, s_result)
         self.delayedreprs = []
+        self.delayedconsts = [] 
 
     def getgraph(self, ll_function, args_s, s_result):
         # get the graph of the mix-level helper ll_function and prepare it for
@@ -142,6 +143,14 @@
         self.delayedreprs.append(r)
         return r
 
+    def delayedconst(self, repr, obj):
+        if repr.is_setup_delayed():
+            delayedptr = lltype._ptr(repr.lowleveltype, "delayed!")
+            self.delayedconsts.append((delayedptr, repr, obj))
+            return delayedptr
+        else:
+            return repr.convert_const(obj)
+
     def finish(self):
         # push all the graphs into the annotator's pending blocks dict at once
         rtyper = self.rtyper
@@ -164,6 +173,9 @@
         rtyper.type_system.perform_normalizations(rtyper)
         for r in self.delayedreprs:
             r.set_setup_delayed(False)
+        for p, repr, obj in self.delayedconsts:
+            p._become(repr.convert_const(obj))
         rtyper.specialize_more_blocks()
         del self.pending[:]
         del self.delayedreprs[:]
+        del self.delayedconsts[:]

Modified: pypy/dist/pypy/rpython/lltypesystem/lltype.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/lltype.py	(original)
+++ pypy/dist/pypy/rpython/lltypesystem/lltype.py	Mon Feb 20 23:21:09 2006
@@ -649,6 +649,11 @@
         self._set_weak(False)
         self._setobj(pointing_to, solid)
 
+    def _become(self, other):
+        assert self._TYPE == other._TYPE
+        assert not self._weak
+        self._setobj(other._obj, other._solid)
+
     def __eq__(self, other):
         if not isinstance(other, _ptr):
             raise TypeError("comparing pointer with %r object" % (



More information about the Pypy-commit mailing list