Commits

Armin Rigo committed 523c9a2

Fix trackgcroot for ignoring r15 in case it is used by rlib/register.py.

  • Participants
  • Parent commits 5c84150
  • Branches r15-for-exception

Comments (0)

Files changed (2)

File pypy/translator/c/gcc/trackgcroot.py

                 else:
                     regindex = self.CALLEE_SAVE_REGISTERS.index(tag)
                     shape[1 + regindex] = loc
-            if LOC_NOWHERE in shape and not self.is_stack_bottom:
+            #
+            if self.special_register is None:
+                shape_wo_specialreg = shape
+            else:
+                tag = self.special_register
+                regindex = self.CALLEE_SAVE_REGISTERS.index(tag)
+                shape_wo_specialreg = shape[:]
+                del shape_wo_specialreg[1 + regindex]
+            if LOC_NOWHERE in shape_wo_specialreg and not self.is_stack_bottom:
                 reg = self.CALLEE_SAVE_REGISTERS[shape.index(LOC_NOWHERE) - 1]
                 raise AssertionError("cannot track where register %s is saved"
                                      % (reg,))
     def process_function(self, lines, filename):
         tracker = self.FunctionGcRootTracker(
             lines, filetag=getidentifier(filename))
+        tracker.special_register = special_register
         if self.verbose == 1:
             sys.stderr.write('.')
         elif self.verbose > 1:
 
 class GcRootTracker(object):
 
-    def __init__(self, verbose=0, shuffle=False, format='elf'):
+    def __init__(self, verbose=0, shuffle=False, format='elf',
+                 special_register=None):
         self.verbose = verbose
         self.shuffle = shuffle     # to debug the sorting logic in asmgcroot.py
         self.format = format
+        self.special_register = special_register
         self.gcmaptable = []
 
     def dump_raw_table(self, output):
     verbose = 0
     shuffle = False
     output_raw_table = False
+    special_register = None
     if sys.platform == 'darwin':
         if sys.maxint > 2147483647:
             format = 'darwin64'
         elif sys.argv[1].startswith('-f'):
             format = sys.argv[1][2:]
             del sys.argv[1]
+        elif sys.argv[1].startswith('-%'):
+            special_register = sys.argv[1][1:]
+            del sys.argv[1]
         elif sys.argv[1].startswith('-'):
             print >> sys.stderr, "unrecognized option:", sys.argv[1]
             sys.exit(1)
         else:
             break
-    tracker = GcRootTracker(verbose=verbose, shuffle=shuffle, format=format)
+    tracker = GcRootTracker(verbose=verbose, shuffle=shuffle, format=format,
+                            special_register=special_register)
     for fn in sys.argv[1:]:
         f = open(fn, 'r')
         firstline = f.readline()

File pypy/translator/c/genc.py

         for rule in rules:
             mk.rule(*rule)
 
+        from pypy.rlib.register import register_number
+        if register_number is None:
+            extra_trackgcroot_arg = ''
+        else:
+            extra_trackgcroot_arg = '-%%r%d' % register_number
+
         if self.config.translation.gcrootfinder == 'asmgcc':
             trackgcfiles = [cfile[:-2] for cfile in mk.cfiles]
             if self.translator.platform.name == 'msvc':
                         'cmd /c $(MASM) /nologo /Cx /Cp /Zm /coff /Fo$@ /c $< $(INCLUDEDIRS)')
                 mk.rule('.c.gcmap', '',
                         ['$(CC) /nologo $(ASM_CFLAGS) /c /FAs /Fa$*.s $< $(INCLUDEDIRS)',
-                         'cmd /c ' + python + '$(PYPYDIR)/translator/c/gcc/trackgcroot.py -fmsvc -t $*.s > $@']
+                         'cmd /c ' + python + '$(PYPYDIR)/translator/c/gcc/trackgcroot.py -fmsvc -t %s $*.s > $@' % extra_trackgcroot_arg]
                         )
                 mk.rule('gcmaptable.c', '$(GCMAPFILES)',
                         'cmd /c ' + python + '$(PYPYDIR)/translator/c/gcc/trackgcroot.py -fmsvc $(GCMAPFILES) > $@')
                 mk.rule('%.lbl.s %.gcmap', '%.s',
                         [python +
                              '$(PYPYDIR)/translator/c/gcc/trackgcroot.py '
-                             '-t $< > $*.gctmp',
+                             '-t %s $< > $*.gctmp' % extra_trackgcroot_arg,
                          'mv $*.gctmp $*.gcmap'])
                 mk.rule('gcmaptable.s', '$(GCMAPFILES)',
                         [python +