[pypy-svn] r37670 - in pypy/dist/pypy/jit/codegen/ppc: . test

mwh at codespeak.net mwh at codespeak.net
Wed Jan 31 15:03:34 CET 2007


Author: mwh
Date: Wed Jan 31 15:03:17 2007
New Revision: 37670

Modified:
   pypy/dist/pypy/jit/codegen/ppc/conftest.py
   pypy/dist/pypy/jit/codegen/ppc/regalloc.py
   pypy/dist/pypy/jit/codegen/ppc/rgenop.py
   pypy/dist/pypy/jit/codegen/ppc/test/test_rgenop.py
Log:
add an options for scribbling into unused registers and parts of the stack


Modified: pypy/dist/pypy/jit/codegen/ppc/conftest.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/ppc/conftest.py	(original)
+++ pypy/dist/pypy/jit/codegen/ppc/conftest.py	Wed Jan 31 15:03:17 2007
@@ -21,6 +21,9 @@
         Option('--run-interp-tests', action="store_true", default=False,
                dest="run_interp_tests",
                help=""),
+        Option('--debug-scribble', action="store_true", default=False,
+               dest="debug_scribble",
+               help="write junk into unused registers and regions of the stack"),
         Option('--debug-print', action="store_true", default=False,
                dest="debug_print",
                help=""))

Modified: pypy/dist/pypy/jit/codegen/ppc/regalloc.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/ppc/regalloc.py	(original)
+++ pypy/dist/pypy/jit/codegen/ppc/regalloc.py	Wed Jan 31 15:03:17 2007
@@ -7,6 +7,7 @@
 from pypy.jit.codegen.ppc.conftest import option
 
 DEBUG_PRINT = option.debug_print
+DEBUG_PRINT = option.debug_print
 
 class RegisterAllocation:
     def __init__(self, freeregs, initial_mapping, initial_spill_offset):

Modified: pypy/dist/pypy/jit/codegen/ppc/rgenop.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/ppc/rgenop.py	(original)
+++ pypy/dist/pypy/jit/codegen/ppc/rgenop.py	Wed Jan 31 15:03:17 2007
@@ -420,6 +420,14 @@
         there_size = self._stack_size(target.min_stack_offset)
         if here_size != there_size:
             self.emit_stack_adjustment(there_size)
+            if self.rgenop.DEBUG_SCRIBBLE:
+                if here_size > there_size:
+                    offsets = range(there_size, here_size, 4)
+                else:
+                    offsets = range(here_size, there_size, 4)
+                for offset in offsets:
+                    self.asm.load_word(rSCRATCH, 0x23456789)
+                    self.asm.stw(rSCRATCH, rSP, -offset)
         self.asm.load_word(rSCRATCH, target.startaddr)
         self.asm.mtctr(rSCRATCH)
         self.asm.bctr()
@@ -541,6 +549,16 @@
         # save stack pointer into linkage area and set stack pointer for us.
         self.asm.stwu(rSP, rSP, -minspace)
 
+        if self.rgenop.DEBUG_SCRIBBLE:
+            # write junk into all non-argument, non rFP or rSP registers
+            self.asm.load_word(rSCRATCH, 0x12345678)
+            for i in range(min(11, 3+len(self.initial_var2loc)), 32):
+                if i != 1 and i != 2: # apart from rSP and rFP of course...
+                    self.asm.load_word(i, 0x12345678)
+            # scribble the part of the stack between self._var_offset(0) and minspace
+            for offset in range(self._var_offset(0), -minspace, -4):
+                self.asm.stw(rSCRATCH, rFP, offset)
+
         return inputargs
 
     def _var_offset(self, v):
@@ -588,8 +606,26 @@
         if in_size != our_size:
             assert our_size > in_size
             self.emit_stack_adjustment(our_size)
-        for insn in self.insns:
-            insn.emit(self.asm)
+            if self.rgenop.DEBUG_SCRIBBLE:
+                for offset in range(in_size, our_size, 4):
+                    self.asm.load_word(rSCRATCH, 0x23456789)
+                    self.asm.stw(rSCRATCH, rSP, -offset)
+        if self.rgenop.DEBUG_SCRIBBLE:
+            locs = {}
+            for _, loc in self.initial_var2loc.iteritems():
+                locs[loc] = True
+            regs = insn.gprs[3:]
+            for reg in regs:
+                if reg not in locs:
+                    self.asm.load_word(reg.number, 0x3456789)
+            self.asm.load_word(0, 0x3456789)
+            for offset in range(self._var_offset(0),
+                                self.initial_spill_offset,
+                                -4):
+                if insn.stack_slot(offset) not in locs:
+                    self.asm.stw(0, rFP, offset)
+        for insn_ in self.insns:
+            insn_.emit(self.asm)
         for label in allocator.labels_to_tell_spill_offset_to:
             label.min_stack_offset = allocator.spill_offset
         for builder in allocator.builders_to_tell_spill_offset_to:
@@ -988,6 +1024,7 @@
         insn.FP_REGISTER:insn.fprs,
         insn.CR_FIELD:insn.crfs,
         insn.CT_REGISTER:[insn.ctr]}
+    DEBUG_SCRIBBLE = option.debug_scribble
 
     def __init__(self):
         self.mcs = []   # machine code blocks where no-one is currently writing

Modified: pypy/dist/pypy/jit/codegen/ppc/test/test_rgenop.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/ppc/test/test_rgenop.py	(original)
+++ pypy/dist/pypy/jit/codegen/ppc/test/test_rgenop.py	Wed Jan 31 15:03:17 2007
@@ -12,6 +12,9 @@
         insn.CR_FIELD:insn.crfs[:1],
         insn.CT_REGISTER:[insn.ctr]}
 
+class FewRegistersAndScribble(FewRegisters):
+    DEBUG_SCRIBBLE = True
+
 class TestRPPCGenop(AbstractRGenOpTests):
     RGenOp = RPPCGenOp
 
@@ -28,3 +31,6 @@
 
     def compile(self, runner, argtypes):
         py.test.skip("Skip compiled tests w/ restricted register allocator")
+
+class TestRPPCGenopNoRegsAndScribble(TestRPPCGenopNoRegs):
+    RGenOp = FewRegistersAndScribble



More information about the Pypy-commit mailing list