Author: Armin Rigo <[email protected]>
Branch: jit-ordereddict
Changeset: r68551:d646fef13877
Date: 2013-12-25 23:07 +0100
http://bitbucket.org/pypy/pypy/changeset/d646fef13877/

Log:    in-progress

diff --git a/rpython/jit/codewriter/jtransform.py 
b/rpython/jit/codewriter/jtransform.py
--- a/rpython/jit/codewriter/jtransform.py
+++ b/rpython/jit/codewriter/jtransform.py
@@ -888,6 +888,11 @@
             opname = "unicodesetitem"
             return SpaceOperation(opname, [op.args[0], op.args[2], op.args[3]],
                                   op.result)
+        elif optype == lltype.Ptr(rbytearray.BYTEARRAY):
+            bytearraydescr = self.cpu.arraydescrof(rbytearray.BYTEARRAY)
+            opname = "setarrayitem_gc_i"
+            return SpaceOperation(opname, [op.args[0], op.args[2], op.args[3],
+                                           bytearraydescr], op.result)
         else:
             v_inst, v_index, c_field, v_value = op.args
             if v_value.concretetype is lltype.Void:
diff --git a/rpython/jit/metainterp/test/test_bytearray.py 
b/rpython/jit/metainterp/test/test_bytearray.py
--- a/rpython/jit/metainterp/test/test_bytearray.py
+++ b/rpython/jit/metainterp/test/test_bytearray.py
@@ -1,7 +1,6 @@
 import py
 from rpython.jit.metainterp.test.support import LLJitMixin
-from rpython.rlib.jit import JitDriver
-
+from rpython.rlib.jit import JitDriver, dont_look_inside
 
 class TestByteArray(LLJitMixin):
 
@@ -28,9 +27,12 @@
         assert res == 6
 
     def test_setitem(self):
-        x = bytearray("foobar")
+        @dont_look_inside
+        def make_me():
+            return bytearray("foobar")
         def fn(n):
             assert n >= 0
+            x = make_me()
             x[n] = 3
             return x[3] + 1000 * x[4]
 
@@ -38,8 +40,11 @@
         assert res == 3 + 1000 * ord('a')
 
     def test_setitem_negative(self):
-        x = bytearray("foobar")
+        @dont_look_inside
+        def make_me():
+            return bytearray("foobar")
         def fn(n):
+            x = make_me()
             x[n] = 3
             return x[3] + 1000 * x[4]
 
@@ -49,17 +54,18 @@
     def test_new_bytearray(self):
         def fn(n, m):
             x = bytearray(str(n))
-            x[m] = 4
+            x[m] = 0x34
             return int(str(x))
 
+        assert fn(610978, 3) == 610478
         res = self.interp_operations(fn, [610978, 3])
         assert res == 610478
 
     def test_slice(self):
-        def fn(n):
+        def fn(n, m):
             x = bytearray(str(n))
             x = x[1:5]
-            x[m] = 5
+            x[m] = 0x35
             return int(str(x))
         res = self.interp_operations(fn, [610978, 1])
         assert res == 1597
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to