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

arigo at codespeak.net arigo at codespeak.net
Fri Apr 10 18:44:27 CEST 2009


Author: arigo
Date: Fri Apr 10 18:44:26 2009
New Revision: 63962

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_basic.py
Log:
Unicode operations in the x86 backend.  For now only works with
4-byte unicodes, which is the default for PyPy translations
(as far as I know -- I might be wrong on Windows).


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	Fri Apr 10 18:44:26 2009
@@ -605,9 +605,17 @@
         base_loc, ofs_loc, val_loc = arglocs
         basesize, itemsize, ofs_length = symbolic.get_array_token(rstr.STR,
                                               self.cpu.translate_support_code)
+        assert itemsize == 1
         self.mc.MOV(addr8_add(base_loc, ofs_loc, basesize),
                     lower_byte(val_loc))
 
+    def genop_discard_unicodesetitem(self, op, arglocs):
+        base_loc, ofs_loc, val_loc = arglocs
+        basesize, itemsize, ofs_length = symbolic.get_array_token(rstr.UNICODE,
+                                              self.cpu.translate_support_code)
+        assert itemsize == 4
+        self.mc.MOV(addr_add(base_loc, ofs_loc, basesize), val_loc)
+
     genop_discard_setfield_raw = genop_discard_setfield_gc
 
     def genop_strlen(self, op, arglocs, resloc):
@@ -616,6 +624,12 @@
                                              self.cpu.translate_support_code)
         self.mc.MOV(resloc, addr_add_const(base_loc, ofs_length))
 
+    def genop_unicodelen(self, op, arglocs, resloc):
+        base_loc = arglocs[0]
+        basesize, itemsize, ofs_length = symbolic.get_array_token(rstr.UNICODE,
+                                             self.cpu.translate_support_code)
+        self.mc.MOV(resloc, addr_add_const(base_loc, ofs_length))
+
     def genop_arraylen_gc(self, op, arglocs, resloc):
         base_loc, ofs_loc = arglocs
         self.mc.MOV(resloc, addr_add(base_loc, imm(0)))
@@ -624,8 +638,16 @@
         base_loc, ofs_loc = arglocs
         basesize, itemsize, ofs_length = symbolic.get_array_token(rstr.STR,
                                              self.cpu.translate_support_code)
+        assert itemsize == 1
         self.mc.MOVZX(resloc, addr8_add(base_loc, ofs_loc, basesize))
 
+    def genop_unicodegetitem(self, op, arglocs, resloc):
+        base_loc, ofs_loc = arglocs
+        basesize, itemsize, ofs_length = symbolic.get_array_token(rstr.UNICODE,
+                                             self.cpu.translate_support_code)
+        assert itemsize == 4
+        self.mc.MOV(resloc, addr_add(base_loc, ofs_loc, basesize))
+
     def make_merge_point(self, tree, locs):
         pos = self.mc.tell()
         tree._x86_compiled = pos

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	Fri Apr 10 18:44:26 2009
@@ -894,10 +894,17 @@
         return self._call(op, [imm(descr.v[0]), self.loc(op.args[0])])
 
     def consider_newstr(self, op, ignored):
-        ofs_items, _, ofs = symbolic.get_array_token(rstr.STR, self.translate_support_code)
+        ofs_items, itemsize, ofs = symbolic.get_array_token(rstr.STR, self.translate_support_code)
+        assert itemsize == 1
         return self._malloc_varsize(0, ofs_items, ofs, 0, op.args[0],
                                     op.result)
 
+    def consider_newunicode(self, op, ignored):
+        ofs_items, itemsize, ofs = symbolic.get_array_token(rstr.UNICODE, self.translate_support_code)
+        assert itemsize == 4
+        return self._malloc_varsize(0, ofs_items, ofs, 2, op.args[0],
+                                    op.result)
+
     def _malloc_varsize(self, ofs, ofs_items, ofs_length, size, v, res_v):
         if isinstance(v, Box):
             loc = self.make_sure_var_in_reg(v, [v])
@@ -947,6 +954,8 @@
         self.eventually_free_vars([op.args[0], op.args[1], op.args[2]])
         self.PerformDiscard(op, [base_loc, ofs_loc, value_loc])
 
+    consider_unicodesetitem = consider_strsetitem
+
     def consider_setarrayitem_gc(self, op, ignored):
         scale, ofs, _ = self._unpack_arraydescr(op.descr)
         base_loc  = self.make_sure_var_in_reg(op.args[0], op.args)
@@ -1038,6 +1047,8 @@
         result_loc = self.force_allocate_reg(op.result, [])
         self.Perform(op, [base_loc], result_loc)
 
+    consider_unicodelen = consider_strlen
+
     def consider_arraylen_gc(self, op, ignored):
         _, ofs, _ = self._unpack_arraydescr(op.descr)
         base_loc = self.make_sure_var_in_reg(op.args[0], op.args)
@@ -1052,6 +1063,8 @@
         result_loc = self.force_allocate_reg(op.result, [])
         self.Perform(op, [base_loc, ofs_loc], result_loc)
 
+    consider_unicodegetitem = consider_strgetitem
+
     def consider_jump(self, op, ignored):
         later_loads = []
         reloaded = []

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/test/test_basic.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/test/test_basic.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/test/test_basic.py	Fri Apr 10 18:44:26 2009
@@ -31,6 +31,3 @@
             return n
         res = self.meta_interp(f, [31], specialize=False)
         assert res == -4
-
-    def test_unicode(self):
-        py.test.skip("fixme")



More information about the Pypy-commit mailing list