Commits

Armin Rigo committed 10bafee

bytearray length

  • Participants
  • Parent commits 41fe706
  • Branches jit-ordereddict

Comments (0)

Files changed (2)

rpython/jit/backend/llgraph/runner.py

 
     def bh_arraylen_gc(self, a, descr):
         array = a._obj.container
+        if descr.A is not descr.OUTERA:
+            array = getattr(array, descr.OUTERA._arrayfld)
         return array.getlength()
 
     def bh_getarrayitem_gc(self, a, index, descr):

rpython/jit/codewriter/jtransform.py

         optype = op.args[0].concretetype
         if optype == lltype.Ptr(rstr.STR):
             opname = "strlen"
+        elif optype == lltype.Ptr(rstr.UNICODE):
+            opname = "unicodelen"
+        elif optype == lltype.Ptr(rbytearray.BYTEARRAY):
+            bytearraydescr = self.cpu.arraydescrof(rbytearray.BYTEARRAY)
+            return SpaceOperation('arraylen_gc', [op.args[0], bytearraydescr],
+                                  op.result)
         else:
-            assert optype == lltype.Ptr(rstr.UNICODE)
-            opname = "unicodelen"
+            assert 0, "supported type %r" % (optype,)
         return SpaceOperation(opname, [op.args[0]], op.result)
 
     def rewrite_op_getinteriorfield(self, op):
         elif optype == lltype.Ptr(rbytearray.BYTEARRAY):
             bytearraydescr = self.cpu.arraydescrof(rbytearray.BYTEARRAY)
             v_index = op.args[2]
-            op = SpaceOperation('getarrayitem_gc_i',
-                                [op.args[0], v_index, bytearraydescr],
-                                op.result)
-            return op
+            return SpaceOperation('getarrayitem_gc_i',
+                                  [op.args[0], v_index, bytearraydescr],
+                                  op.result)
         else:
             v_inst, v_index, c_field = op.args
             if op.result.concretetype is lltype.Void: