Commits

Maciej Fijalkowski committed 9f414db

finish strings enough for test_loop_unroll to pass

  • Participants
  • Parent commits f87bcc7
  • Branches resume-refactor

Comments (0)

Files changed (4)

rpython/jit/metainterp/optimizeopt/vstring.py

                 index = indexbox.getint()
                 varg = self.getvalue(op.getarg(2))
                 value.setitem(index, varg)
-                self.optimizer.resumebuilder.strsetitem(value, varg)
+                self.optimizer.resumebuilder.strsetitem(value, ConstInt(index),
+                                                        varg)
                 return
         value.ensure_nonnull()
         self.emit_operation(op)

rpython/jit/metainterp/resoperation.py

     'RESUME_NEWUNICODE/1',
     'RESUME_CONCATSTR/2',
     'RESUME_CONCATUNICODE/2',
-    'RESUME_STRSETITEM/2',
+    'RESUME_STRSETITEM/3',
     'RESUME_SETFIELD_GC/2d',
     'RESUME_SET_PC/1',
     'RESUME_CLEAR/2',

rpython/jit/resume/backend.py

     def resume_setfield_gc(self, arg0, arg1, descr):
         self.deps[arg0].fields[descr] = arg1
 
-    def resume_strsetitem(self, arg0, arg1):
-        xxx
+    def resume_strsetitem(self, arg0, index, arg1):
+        self.deps[arg0].l[index] = arg1
 
     def resume_set_pc(self, pc):
         pass
             elif op.getopnum() == rop.RESUME_CONCATUNICODE:
                 self.resume_concatunicode(op.result, op.getarg(0), op.getarg(1))
             elif op.getopnum() == rop.RESUME_STRSETITEM:
-                self.resume_strsetitem(op.getarg(0), op.getarg(1))
+                self.resume_strsetitem(op.getarg(0), op.getarg(1).getint(),
+                                       op.getarg(2))
             elif not op.is_resume():
                 pos += 1
                 continue
             v_pos = len(self.virtuals)
             self.virtuals[op.result] = v_pos
             leftpos = self.get_box_pos(op.getarg(0))
-            rightpos = self.get_box_pos(op.getarg(0))
+            rightpos = self.get_box_pos(op.getarg(1))
             self.builder.resume_concatunicode(v_pos, leftpos, rightpos)
+        elif op.getopnum() == rop.RESUME_STRSETITEM:
+            v_pos = self.virtuals[op.getarg(0)]
+            index = op.getarg(1).getint()
+            valpos = self.get_box_pos(op.getarg(2))
+            self.builder.resume_strsetitem(v_pos, index, valpos)
         else:
             raise Exception("strange operation")
 

rpython/jit/resume/optimizer.py

         op = ResOperation(mode.RESUME_CONCAT, [leftbox, rightbox], newbox)
         self.opt._newoperations.append(op)
 
-    def strsetitem(self, vstring, varg):
+    def strsetitem(self, vstring, indexbox, varg):
         argbox = varg.get_resume_box()
         op = ResOperation(rop.RESUME_STRSETITEM, [vstring.get_resume_box(),
-                                                     argbox], None)
+                                                  indexbox, argbox], None)
         self.opt._newoperations.append(op)
 
     def setfield(self, box, fieldbox, descr):