[pypy-svn] r63703 - in pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86: . test

fijal at codespeak.net fijal at codespeak.net
Mon Apr 6 06:27:00 CEST 2009


Author: fijal
Date: Mon Apr  6 06:26:58 2009
New Revision: 63703

Modified:
   pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/assembler.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/regalloc.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/test/test_runner.py
Log:
implement getarrayitem_gc for chars (probably at some point will explode on
unichars, let's implement it at some point soon I suppose)


Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/assembler.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/assembler.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/assembler.py	Mon Apr  6 06:26:58 2009
@@ -497,7 +497,15 @@
         base_loc, ofs_loc, scale, ofs = arglocs
         assert isinstance(ofs, IMM32)
         assert isinstance(scale, IMM32)
-        self.mc.MOV(resloc, addr_add(base_loc, ofs_loc, ofs.value, scale.value))
+        if scale.value == 0:
+            self.mc.MOVZX(resloc, addr8_add(base_loc, ofs_loc, ofs.value,
+                                            scale.value))
+        elif scale.value == 2:
+            self.mc.MOV(resloc, addr_add(base_loc, ofs_loc, ofs.value,
+                                         scale.value))
+        else:
+            print "[asmgen]setarrayitem unsupported size: %d" % scale.value
+            raise NotImplementedError()
 
     genop_getfield_raw = genop_getfield_gc
     genop_getarrayitem_gc_pure = genop_getarrayitem_gc
@@ -514,6 +522,7 @@
         elif size == 1:
             self.mc.MOV(addr8_add(base_loc, ofs_loc), lower_byte(value_loc))
         else:
+            print "[asmgen]setfield addr size %d" % size
             raise NotImplementedError("Addr size %d" % size)
 
     def genop_discard_setarrayitem_gc(self, op, arglocs):

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/regalloc.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/regalloc.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/regalloc.py	Mon Apr  6 06:26:58 2009
@@ -13,7 +13,7 @@
 
 # esi edi and ebp can be added to this list, provided they're correctly
 # saved and restored
-REGS = [eax, ecx, edx]
+REGS = [eax, ecx, edx, ebx]
 WORD = 4
 FRAMESIZE = 1024    # XXX should not be a constant at all!!
 

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/test/test_runner.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/test/test_runner.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/test/test_runner.py	Mon Apr  6 06:26:58 2009
@@ -260,6 +260,27 @@
                                    'int', descr)
         assert r.value == 42
 
+    def test_arrayitems_not_int(self):
+        TP = lltype.GcArray(lltype.Char)
+        ofs = symbolic.get_field_token(TP, 'length', False)[0]
+        itemsofs = symbolic.get_field_token(TP, 'items', False)[0]
+        descr = self.cpu.arraydescrof(TP)
+        res = self.execute_operation(rop.NEW_ARRAY, [ConstInt(10)],
+                                     'ptr', descr)
+        resbuf = ctypes.cast(res.value.intval, ctypes.POINTER(ctypes.c_char))
+        assert resbuf[ofs] == chr(10)
+        for i in range(10):
+            self.execute_operation(rop.SETARRAYITEM_GC, [res,
+                                                   ConstInt(i), BoxInt(i)],
+                                   'void', descr)
+        for i in range(10):
+            assert resbuf[itemsofs + i] == chr(i)
+        for i in range(10):
+            r = self.execute_operation(rop.GETARRAYITEM_GC, [res,
+                                                             ConstInt(i)],
+                                         'int', descr)
+            assert r.value == i
+
     def test_getfield_setfield(self):
         TP = lltype.GcStruct('x', ('s', lltype.Signed),
                              ('f', lltype.Float),



More information about the Pypy-commit mailing list