[pypy-svn] r50143 - pypy/branch/llvmgcroot/pypy/translator/c

arigo at codespeak.net arigo at codespeak.net
Thu Dec 27 18:48:37 CET 2007


Author: arigo
Date: Thu Dec 27 18:48:36 2007
New Revision: 50143

Modified:
   pypy/branch/llvmgcroot/pypy/translator/c/trackgcroot.py
Log:
More hacks until targetprologstandalone works.


Modified: pypy/branch/llvmgcroot/pypy/translator/c/trackgcroot.py
==============================================================================
--- pypy/branch/llvmgcroot/pypy/translator/c/trackgcroot.py	(original)
+++ pypy/branch/llvmgcroot/pypy/translator/c/trackgcroot.py	Thu Dec 27 18:48:36 2007
@@ -106,14 +106,18 @@
         match = r_functionstart.match(lines[0])
         self.funcname = match.group(1)
         self.lines = lines
+        self.inconsistent_state = {}
 
     def computegcmaptable(self):
         self.findlabels()
-        self.uses_frame_pointer = False
-        self.calls = {}         # {label_after_call: state}
-        self.ignore_calls = {}
-        self.missing_labels_after_call = []
-        self.follow_control_flow()
+        try:
+            self.uses_frame_pointer = False
+            self.calls = {}         # {label_after_call: state}
+            self.ignore_calls = {}
+            self.missing_labels_after_call = []
+            self.follow_control_flow()
+        except ReflowCompletely:
+            return self.computegcmaptable()
         table = self.gettable()
         self.extend_calls_with_labels()
         return table
@@ -154,8 +158,11 @@
         self.check_all_calls_seen()
 
     def getstate(self):
-        gcroots = self.gcroots.keys()
-        gcroots.sort()
+        if self.gcroots is Bogus:
+            gcroots = ()
+        else:
+            gcroots = self.gcroots.keys()
+            gcroots.sort()
         return (self.framesize,) + tuple(gcroots)
 
     def propagate_state_to(self, lin):
@@ -163,13 +170,19 @@
         if self.states[lin] is None:
             self.states[lin] = state
             self.pending.append(lin)
-        else:
-            assert self.states[lin] == state
+        elif self.states[lin] != state:
+            if lin not in self.inconsistent_state:
+                self.inconsistent_state[lin] = (self.states[lin], state)
+                raise ReflowCompletely
 
     def follow_basic_block(self, lin):
         state = self.states[lin]
         self.framesize = state[0]
         self.gcroots = dict.fromkeys(state[1:])
+        if lin in self.inconsistent_state:  # in case of inconsistent gcroots,
+            self.framesize = Bogus          # assume that we're about to leave
+        if self.framesize is Bogus:         # the function or fail an assert
+            self.gcroots = Bogus
         line = '?'
         self.in_APP = False
         while 1:
@@ -205,6 +218,8 @@
                     lin += 1
                     continue
                 raise
+            except ReflowCompletely:
+                raise
             except Exception, e:
                 print >> sys.stderr, '*'*60
                 print >> sys.stderr, "%s while processing line:" % (
@@ -321,6 +336,9 @@
                     self.propagate_state_to(targetlin)
                 tablelin += 1
             raise LeaveBasicBlock
+        if r_unaryinsn_star.match(line):
+            # that looks like an indirect tail-call.
+            raise LeaveBasicBlock
         try:
             self.conditional_jump(line)
         except KeyError:
@@ -411,6 +429,13 @@
 class UnrecognizedOperation(Exception):
     pass
 
+class ReflowCompletely(Exception):
+    pass
+
+class BogusObject(object):
+    pass
+Bogus = BogusObject()
+
 FUNCTIONS_NOT_RETURNING = {
     'abort': None,
     '__assert_fail': None,



More information about the Pypy-commit mailing list