[pypy-svn] r77503 - in pypy/branch/jit-str-fix/pypy/jit/backend: . test x86

arigo at codespeak.net arigo at codespeak.net
Thu Sep 30 18:43:42 CEST 2010


Author: arigo
Date: Thu Sep 30 18:43:41 2010
New Revision: 77503

Added:
   pypy/branch/jit-str-fix/pypy/jit/backend/conftest.py
      - copied, changed from r77494, pypy/branch/jit-str-fix/pypy/jit/backend/test/conftest.py
Removed:
   pypy/branch/jit-str-fix/pypy/jit/backend/test/conftest.py
Modified:
   pypy/branch/jit-str-fix/pypy/jit/backend/test/test_ll_random.py
   pypy/branch/jit-str-fix/pypy/jit/backend/test/test_random.py
   pypy/branch/jit-str-fix/pypy/jit/backend/x86/regalloc.py
   pypy/branch/jit-str-fix/pypy/jit/backend/x86/runner.py
Log:
More fixes.  It's a complete MESS to handle efficiently operations
with 5 arguments with that regalloc interface.


Copied: pypy/branch/jit-str-fix/pypy/jit/backend/conftest.py (from r77494, pypy/branch/jit-str-fix/pypy/jit/backend/test/conftest.py)
==============================================================================
--- pypy/branch/jit-str-fix/pypy/jit/backend/test/conftest.py	(original)
+++ pypy/branch/jit-str-fix/pypy/jit/backend/conftest.py	Thu Sep 30 18:43:41 2010
@@ -1,3 +1,7 @@
+"""
+This conftest adds options used by test/test_random and
+x86/test/test_zll_random.
+"""
 import py, random
 
 option = py.test.config.option
@@ -29,4 +33,3 @@
     group.addoption('--output', '-O', action="store", type="str",
                     default="", dest="output",
                     help="dump output to a file")
-

Modified: pypy/branch/jit-str-fix/pypy/jit/backend/test/test_ll_random.py
==============================================================================
--- pypy/branch/jit-str-fix/pypy/jit/backend/test/test_ll_random.py	(original)
+++ pypy/branch/jit-str-fix/pypy/jit/backend/test/test_ll_random.py	Thu Sep 30 18:43:41 2010
@@ -390,6 +390,8 @@
     def produce_into(self, builder, r):
         v_srcstring = self.get_string(builder, r)
         v_dststring = self.get_string(builder, r)
+        if v_srcstring.value == v_dststring.value:    # because it's not a
+            raise test_random.CannotProduceOperation  # memmove(), but memcpy()
         srclen = len(v_srcstring.getref(self.ptr).chars)
         dstlen = len(v_dststring.getref(self.ptr).chars)
         v_length = builder.get_index(min(srclen, dstlen), r)

Modified: pypy/branch/jit-str-fix/pypy/jit/backend/test/test_random.py
==============================================================================
--- pypy/branch/jit-str-fix/pypy/jit/backend/test/test_random.py	(original)
+++ pypy/branch/jit-str-fix/pypy/jit/backend/test/test_random.py	Thu Sep 30 18:43:41 2010
@@ -1,7 +1,7 @@
 import py, sys
 from pypy.rlib.rarithmetic import intmask, LONG_BIT
 from pypy.rpython.lltypesystem import llmemory
-from pypy.jit.backend.test import conftest as demo_conftest
+from pypy.jit.backend import conftest as demo_conftest
 from pypy.jit.metainterp.history import BasicFailDescr, TreeLoop
 from pypy.jit.metainterp.history import BoxInt, ConstInt, LoopToken
 from pypy.jit.metainterp.history import BoxPtr, ConstPtr
@@ -102,7 +102,7 @@
             elif isinstance(v, ConstFloat):
                 args.append('ConstFloat(%r)' % v.value)
             elif isinstance(v, ConstInt):
-                args.append('ConstInt(%d)' % v.value)
+                args.append('ConstInt(%s)' % v.value)
             else:
                 raise NotImplementedError(v)
         if op.getdescr() is None:
@@ -113,7 +113,7 @@
             except AttributeError:
                 descrstr = ', descr=...'
         print >>s, '        ResOperation(rop.%s, [%s], %s%s),' % (
-            opname[op.opnum], ', '.join(args), names[op.result], descrstr)
+            opname[op.getopnum()], ', '.join(args), names[op.result], descrstr)
         #if getattr(op, 'suboperations', None) is not None:
         #    subops.append(op)
 
@@ -189,7 +189,7 @@
                                                                        v.value)
         print >>s, '    op = cpu.execute_token(looptoken)'
         if self.should_fail_by is None:
-            fail_args = self.loop.operations[-1].args
+            fail_args = self.loop.operations[-1].getarglist()
         else:
             fail_args = self.should_fail_by.getfailargs()
         for i, v in enumerate(fail_args):

Modified: pypy/branch/jit-str-fix/pypy/jit/backend/x86/regalloc.py
==============================================================================
--- pypy/branch/jit-str-fix/pypy/jit/backend/x86/regalloc.py	(original)
+++ pypy/branch/jit-str-fix/pypy/jit/backend/x86/regalloc.py	Thu Sep 30 18:43:41 2010
@@ -959,18 +959,23 @@
         args = op.getarglist()
         base_loc = self.rm.make_sure_var_in_reg(args[0], args)
         ofs_loc = self.rm.make_sure_var_in_reg(args[2], args)
+        assert args[0] is not args[1]    # forbidden case of aliasing
         self.rm.possibly_free_var(args[0])
-        self.rm.possibly_free_var(args[2])
+        if args[3] is not args[2] is not args[4]:  # MESS MESS MESS: don't free
+            self.rm.possibly_free_var(args[2])     # it if ==args[3] or args[4]
         srcaddr_box = TempBox()
-        srcaddr_loc = self.rm.force_allocate_reg(srcaddr_box)
+        forbidden_vars = [args[1], args[3], args[4], srcaddr_box]
+        srcaddr_loc = self.rm.force_allocate_reg(srcaddr_box, forbidden_vars)
         self._gen_address_inside_string(base_loc, ofs_loc, srcaddr_loc)
         # compute the destination address
-        base_loc = self.rm.make_sure_var_in_reg(args[1], args)
-        ofs_loc = self.rm.make_sure_var_in_reg(args[3], args)
+        base_loc = self.rm.make_sure_var_in_reg(args[1], forbidden_vars)
+        ofs_loc = self.rm.make_sure_var_in_reg(args[3], forbidden_vars)
         self.rm.possibly_free_var(args[1])
-        self.rm.possibly_free_var(args[3])
+        if args[3] is not args[4]:     # more of the MESS described above
+            self.rm.possibly_free_var(args[3])
+        forbidden_vars = [args[4], srcaddr_box]
         dstaddr_box = TempBox()
-        dstaddr_loc = self.rm.force_allocate_reg(dstaddr_box)
+        dstaddr_loc = self.rm.force_allocate_reg(dstaddr_box, forbidden_vars)
         self._gen_address_inside_string(base_loc, ofs_loc, dstaddr_loc)
         # call memcpy()
         length_loc = self.loc(args[4])

Modified: pypy/branch/jit-str-fix/pypy/jit/backend/x86/runner.py
==============================================================================
--- pypy/branch/jit-str-fix/pypy/jit/backend/x86/runner.py	(original)
+++ pypy/branch/jit-str-fix/pypy/jit/backend/x86/runner.py	Thu Sep 30 18:43:41 2010
@@ -87,7 +87,9 @@
 
     def execute_token(self, executable_token):
         addr = executable_token._x86_bootstrap_code
+        #llop.debug_print(lltype.Void, ">>>> Entering", addr)
         func = rffi.cast(lltype.Ptr(self.BOOTSTRAP_TP), addr)
+        #llop.debug_print(lltype.Void, "<<<< Back")
         fail_index = self._execute_call(func)
         return self.get_fail_descr_from_number(fail_index)
 
@@ -99,10 +101,7 @@
             LLInterpreter.current_interpreter = self.debug_ll_interpreter
         res = 0
         try:
-            #llop.debug_print(lltype.Void, ">>>> Entering",
-            #                 rffi.cast(lltype.Signed, func))
             res = func()
-            #llop.debug_print(lltype.Void, "<<<< Back")
         finally:
             if not self.translate_support_code:
                 LLInterpreter.current_interpreter = prev_interpreter



More information about the Pypy-commit mailing list