[pypy-svn] r69015 - pypy/branch/msvc-asmgcroot/pypy/translator/c/gcc

afa at codespeak.net afa at codespeak.net
Fri Nov 6 00:09:17 CET 2009


Author: afa
Date: Fri Nov  6 00:09:17 2009
New Revision: 69015

Modified:
   pypy/branch/msvc-asmgcroot/pypy/translator/c/gcc/trackgcroot.py
Log:
Make trackgcroot.py really platform-independant:
don't use sys.platform, but the given "format": elf, mingw32, msvc


Modified: pypy/branch/msvc-asmgcroot/pypy/translator/c/gcc/trackgcroot.py
==============================================================================
--- pypy/branch/msvc-asmgcroot/pypy/translator/c/gcc/trackgcroot.py	(original)
+++ pypy/branch/msvc-asmgcroot/pypy/translator/c/gcc/trackgcroot.py	Fri Nov  6 00:09:17 2009
@@ -630,9 +630,9 @@
             assert self.r_unaryinsn_star.match(line)   # indirect call
         else:
             target = match.group(1)
-            if target in FUNCTIONS_NOT_RETURNING:
+            if target in self.FUNCTIONS_NOT_RETURNING:
                 return [InsnStop(), InsnCannotFollowEsp()]
-            if sys.platform == 'win32' and target == '__alloca':
+            if self.format == 'mingw32' and target == '__alloca':
                 # in functions with large stack requirements, windows
                 # needs a call to _alloca(), to turn reserved pages
                 # into committed memory.
@@ -647,7 +647,7 @@
                     return [InsnStackAdjust(-4)]
         insns = [InsnCall(self.currentlineno),
                  InsnSetLocal(self.EAX)]      # the result is there
-        if sys.platform == 'win32':
+        if self.format in ('mingw32', 'msvc'):
             # On win32, the address of a foreign function must be
             # computed, the optimizer may store it in a register.  We
             # could ignore this, except when the function has a
@@ -716,6 +716,14 @@
     r_gcroot_marker = re.compile(r"\t/[*] GCROOT ("+LOCALVARFP+") [*]/")
     r_bottom_marker = re.compile(r"\t/[*] GC_STACK_BOTTOM [*]/")
 
+    FUNCTIONS_NOT_RETURNING = {
+        'abort': None,
+        '_exit': None,
+        '__assert_fail': None,
+        '___assert_rtn': None,
+        'L___assert_rtn$stub': None
+        }
+
     def __init__(self, lines, filetag=0):
         match = self.r_functionstart.match(lines[0])
         funcname = match.group(1)
@@ -779,6 +787,17 @@
     r_jmptable_item = re.compile(r"\tDD\t"+LABEL+"(-\"[A-Za-z0-9$]+\")?\s*$")
     r_jmptable_end  = re.compile(r"[^\t]")
 
+    FUNCTIONS_NOT_RETURNING = {
+        '_abort': None,
+        '__exit': None,
+        '__assert': None,
+        '__wassert': None,
+        '__imp__abort': None,
+        '__imp___wassert': None,
+        'DWORD PTR __imp__abort': None,
+        'DWORD PTR __imp___wassert': None,
+        }
+
     @classmethod
     def init_regexp(cls):
         super(MsvcFunctionGcRootTracker, cls).init_regexp()
@@ -1375,26 +1394,6 @@
     pass
 
 
-if sys.platform != 'win32':
-    FUNCTIONS_NOT_RETURNING = {
-        'abort': None,
-        '_exit': None,
-        '__assert_fail': None,
-        '___assert_rtn': None,
-        'L___assert_rtn$stub': None
-        }
-else:
-    FUNCTIONS_NOT_RETURNING = {
-        '_abort': None,
-        '__exit': None,
-        '__assert': None,
-        '__wassert': None,
-        '__imp__abort': None,
-        '__imp___wassert': None,
-        'DWORD PTR __imp__abort': None,
-        'DWORD PTR __imp___wassert': None,
-        }
-
 # __________ debugging output __________
 
 def format_location(loc):



More information about the Pypy-commit mailing list