[pypy-svn] r77499 - in pypy/branch/jit-str-fix/pypy/jit: backend/test metainterp

arigo at codespeak.net arigo at codespeak.net
Thu Sep 30 17:32:44 CEST 2010


Author: arigo
Date: Thu Sep 30 17:32:43 2010
New Revision: 77499

Modified:
   pypy/branch/jit-str-fix/pypy/jit/backend/test/test_ll_random.py
   pypy/branch/jit-str-fix/pypy/jit/metainterp/executor.py
Log:
Add COPYSTRCONTENT and COPYUNICODECONTENT to the operations
generated by test_ll_random.  Fix in metainterp/executor to
support this.


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 17:32:43 2010
@@ -386,6 +386,18 @@
         v_string = self.get_string(builder, r)
         builder.do(self.opnum, [v_string])
 
+class AbstractCopyContentOperation(AbstractStringOperation):
+    def produce_into(self, builder, r):
+        v_srcstring = self.get_string(builder, r)
+        v_dststring = self.get_string(builder, r)
+        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)
+        v_srcstart = builder.get_index(srclen - v_length.value + 1, r)
+        v_dststart = builder.get_index(dstlen - v_length.value + 1, r)
+        builder.do(self.opnum, [v_srcstring, v_dststring,
+                                v_srcstart, v_dststart, v_length])
+
 class StrGetItemOperation(AbstractGetItemOperation, _StrOperation):
     pass
 
@@ -404,6 +416,13 @@
 class UnicodeLenOperation(AbstractStringLenOperation, _UnicodeOperation):
     pass
 
+class CopyStrContentOperation(AbstractCopyContentOperation, _StrOperation):
+    pass
+
+class CopyUnicodeContentOperation(AbstractCopyContentOperation,
+                                  _UnicodeOperation):
+    pass
+
 
 # there are five options in total:
 # 1. non raising call and guard_no_exception
@@ -577,6 +596,8 @@
     OPERATIONS.append(UnicodeSetItemOperation(rop.UNICODESETITEM))
     OPERATIONS.append(StrLenOperation(rop.STRLEN))
     OPERATIONS.append(UnicodeLenOperation(rop.UNICODELEN))
+    OPERATIONS.append(CopyStrContentOperation(rop.COPYSTRCONTENT))
+    OPERATIONS.append(CopyUnicodeContentOperation(rop.COPYUNICODECONTENT))
 
 for i in range(2):
     OPERATIONS.append(GuardClassOperation(rop.GUARD_CLASS))

Modified: pypy/branch/jit-str-fix/pypy/jit/metainterp/executor.py
==============================================================================
--- pypy/branch/jit-str-fix/pypy/jit/metainterp/executor.py	(original)
+++ pypy/branch/jit-str-fix/pypy/jit/metainterp/executor.py	Thu Sep 30 17:32:43 2010
@@ -205,8 +205,8 @@
 
 def do_copystrcontent(cpu, _, srcbox, dstbox,
                       srcstartbox, dststartbox, lengthbox):
-    src = srcbox.getptr(lltype.Ptr(rstr.STR))
-    dst = dstbox.getptr(lltype.Ptr(rstr.STR))
+    src = srcbox.getref(lltype.Ptr(rstr.STR))
+    dst = dstbox.getref(lltype.Ptr(rstr.STR))
     srcstart = srcstartbox.getint()
     dststart = dststartbox.getint()
     length = lengthbox.getint()
@@ -214,8 +214,8 @@
 
 def do_copyunicodecontent(cpu, _, srcbox, dstbox,
                           srcstartbox, dststartbox, lengthbox):
-    src = srcbox.getptr(lltype.Ptr(rstr.UNICODE))
-    dst = dstbox.getptr(lltype.Ptr(rstr.UNICODE))
+    src = srcbox.getref(lltype.Ptr(rstr.UNICODE))
+    dst = dstbox.getref(lltype.Ptr(rstr.UNICODE))
     srcstart = srcstartbox.getint()
     dststart = dststartbox.getint()
     length = lengthbox.getint()
@@ -428,6 +428,10 @@
         if arity == 3:
             func = get_execute_funclist(3, False)[opnum]
             return func(cpu, metainterp, argboxes[0], argboxes[1], argboxes[2])
+        if arity == 5:    # copystrcontent, copyunicodecontent
+            func = get_execute_funclist(5, False)[opnum]
+            return func(cpu, metainterp, argboxes[0], argboxes[1],
+                        argboxes[2], argboxes[3], argboxes[4])
     raise NotImplementedError
 
 



More information about the Pypy-commit mailing list