Armin Rigo avatar Armin Rigo committed d646fef

in-progress

Comments (0)

Files changed (2)

rpython/jit/codewriter/jtransform.py

             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:

rpython/jit/metainterp/test/test_bytearray.py

 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):
 
         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]
 
         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]
 
     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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.