[pypy-svn] r69774 - in pypy/branch/virtual-forcing/pypy: jit/backend/x86 rpython/lltypesystem

arigo at codespeak.net arigo at codespeak.net
Mon Nov 30 17:54:16 CET 2009


Author: arigo
Date: Mon Nov 30 17:54:16 2009
New Revision: 69774

Modified:
   pypy/branch/virtual-forcing/pypy/jit/backend/x86/assembler.py
   pypy/branch/virtual-forcing/pypy/jit/backend/x86/runner.py
   pypy/branch/virtual-forcing/pypy/rpython/lltypesystem/ll2ctypes.py
Log:
Fix a translation issue: we cannot write
'rffi.ptradd(self.all_null_registers, 16)'
because that's constant-foldable, but the
result is an ll2ctypes array of unknown
length, which is not translatable.

Crash a bit more explicitly in ll2ctypes
in that case.


Modified: pypy/branch/virtual-forcing/pypy/jit/backend/x86/assembler.py
==============================================================================
--- pypy/branch/virtual-forcing/pypy/jit/backend/x86/assembler.py	(original)
+++ pypy/branch/virtual-forcing/pypy/jit/backend/x86/assembler.py	Mon Nov 30 17:54:16 2009
@@ -878,8 +878,9 @@
             arglocs.append(loc)
         return arglocs[:]
 
-    def grab_frame_values(self, bytecode, frame_addr, registers):
-        self.fail_ebp = registers[ebp.op]
+    def grab_frame_values(self, bytecode, frame_addr, allregisters):
+        # no malloc allowed here!!
+        self.fail_ebp = allregisters[16 + ebp.op]
         num = 0
         value_hi = 0
         while 1:
@@ -916,11 +917,10 @@
                     break
                 code >>= 2
                 if kind == self.DESCR_FLOAT:
-                    xmmregisters = rffi.ptradd(registers, -16)
-                    value = xmmregisters[2*code]
-                    value_hi = xmmregisters[2*code + 1]
+                    value = allregisters[2*code]
+                    value_hi = allregisters[2*code + 1]
                 else:
-                    value = registers[code]
+                    value = allregisters[16 + code]
 
             # store the loaded value into fail_boxes_<type>
             if kind == self.DESCR_INT:
@@ -943,14 +943,14 @@
     def setup_failure_recovery(self):
 
         def failure_recovery_func(registers):
-            # no malloc allowed here!!
             # 'registers' is a pointer to a structure containing the
             # original value of the registers, optionally the original
             # value of XMM registers, and finally a reference to the
             # recovery bytecode.  See _build_failure_recovery() for details.
             stack_at_ebp = registers[ebp.op]
             bytecode = rffi.cast(rffi.UCHARP, registers[8])
-            return self.grab_frame_values(bytecode, stack_at_ebp, registers)
+            allregisters = rffi.ptradd(registers, -16)
+            return self.grab_frame_values(bytecode, stack_at_ebp, allregisters)
 
         self.failure_recovery_func = failure_recovery_func
         self.failure_recovery_code = [0, 0, 0, 0]

Modified: pypy/branch/virtual-forcing/pypy/jit/backend/x86/runner.py
==============================================================================
--- pypy/branch/virtual-forcing/pypy/jit/backend/x86/runner.py	(original)
+++ pypy/branch/virtual-forcing/pypy/jit/backend/x86/runner.py	Mon Nov 30 17:54:16 2009
@@ -105,7 +105,7 @@
         fail_index_2 = self.assembler.grab_frame_values(
             bytecode,
             addr_of_force_index - FORCE_INDEX_OFS,
-            rffi.ptradd(self.all_null_registers, 16))
+            self.all_null_registers)
         self.assembler.leave_jitted_hook()
         # end of "no gc operation!" block
         assert fail_index == fail_index_2

Modified: pypy/branch/virtual-forcing/pypy/rpython/lltypesystem/ll2ctypes.py
==============================================================================
--- pypy/branch/virtual-forcing/pypy/rpython/lltypesystem/ll2ctypes.py	(original)
+++ pypy/branch/virtual-forcing/pypy/rpython/lltypesystem/ll2ctypes.py	Mon Nov 30 17:54:16 2009
@@ -443,6 +443,9 @@
         self._storage._setitem(index, value, boundscheck=False)
 
     def getitems(self):
+        if self._TYPE.OF != lltype.Char:
+            raise Exception("cannot get all items of an unknown-length "
+                            "array of %r" % self._TYPE.OF)
         _items = []
         i = 0
         while 1:



More information about the Pypy-commit mailing list