Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r68617:3c795daae3eb
Date: 2014-01-12 15:53 +0100
http://bitbucket.org/pypy/pypy/changeset/3c795daae3eb/

Log:    Fix in trackgcroot: support another style of "jmp *addr" to do
        jumptables

diff --git a/rpython/translator/c/gcc/trackgcroot.py 
b/rpython/translator/c/gcc/trackgcroot.py
--- a/rpython/translator/c/gcc/trackgcroot.py
+++ b/rpython/translator/c/gcc/trackgcroot.py
@@ -31,7 +31,7 @@
         cls.r_binaryinsn    = 
re.compile(r"\t[a-z]\w*\s+(?P<source>"+cls.OPERAND+"),\s*(?P<target>"+cls.OPERAND+")\s*$")
 
         cls.r_jump          = re.compile(r"\tj\w+\s+"+cls.LABEL+"\s*" + 
cls.COMMENT + "$")
-        cls.r_jmp_switch    = re.compile(r"\tjmp\t[*]"+cls.LABEL+"[(]")
+        cls.r_jmp_switch    = re.compile(r"\tjmp\t[*]")
         cls.r_jmp_source    = re.compile(r"\d*[(](%[\w]+)[,)]")
 
     def __init__(self, funcname, lines, filetag=0):
@@ -697,10 +697,22 @@
         tablelabels = []
         match = self.r_jmp_switch.match(line)
         if match:
-            # this is a jmp *Label(%index), used for table-based switches.
-            # Assume that the table is just a list of lines looking like
-            # .long LABEL or .long 0, ending in a .text or .section .text.hot.
-            tablelabels.append(match.group(1))
+            # this is a jmp *Label(%index) or jmp *%addr, used for
+            # table-based switches.  Assume that the table is coming
+            # after a .section .rodata and a label, and is a list of
+            # lines looking like .long LABEL or .long 0 or .long L2-L1,
+            # ending in a .text or .section .text.hot.
+            lineno = self.currentlineno + 1
+            if '.section' not in self.lines[lineno]:
+                pass  # bah, probably a tail-optimized indirect call...
+            else:
+                assert '.rodata' in self.lines[lineno]
+                lineno += 1
+                while '.align' in self.lines[lineno]:
+                    lineno += 1
+                match = self.r_label.match(self.lines[lineno])
+                assert match, repr(self.lines[lineno])
+                tablelabels.append(match.group(1))
         elif self.r_unaryinsn_star.match(line):
             # maybe a jmp similar to the above, but stored in a
             # registry:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to