Commits

Maciej Fijalkowski committed b3ef852

stop just short of starting to implement virtuals

  • Participants
  • Parent commits 66cc988
  • Branches result-in-resops

Comments (0)

Files changed (4)

File pypy/jit/metainterp/optimizeopt/rewrite.py

         self.postprocess_guard(op, CONST_0)
 
     def optimize_GUARD_ISNULL(self, op):
-        value = self.getvalue(op.getarg(0))
+        value = self.getforwarded(op.getarg(0))
         if value.is_null():
             return
         elif value.is_nonnull():
             raise InvalidLoop('A GUARD_ISNULL was proven to always fail')
-        self.emit_operation(op)
-        value.make_constant(self.optimizer.cpu.ts.CONST_NULL)
+        return op
+
+    def postprocess_GUARD_ISNULL(self, op):
+        self.optimizer.make_constant(op.getarg(0),
+                                     self.optimizer.cpu.ts.CONST_NULL)
 
     def optimize_GUARD_NONNULL(self, op):
         value = self.getforwarded(op.getarg(0))
         elif value.is_null():
             raise InvalidLoop('A GUARD_NONNULL was proven to always fail')
         value.setknownnonnull(True)
-        value.setlastguardpos(self.optimizer.getpos())
+        value.setlastguardpos(self.optimizer.get_pos())
         return op
 
     def optimize_GUARD_VALUE(self, op):

File pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py

     def test_ooisnull_on_null_ptr_1(self):
         ops = """
         [p0, p1]
-        guard_isnull(p0) []
-        guard_isnull(p0) []
+        guard_isnull(p0)
+        guard_isnull(p0)
         jump(p1, p1)
         """
         expected = """
         [p0, p1]
-        guard_isnull(p0) []
+        guard_isnull(p0)
         jump(p1, p1)
         """
         self.optimize_loop(ops, expected)
         [p0]
         pv = new_with_vtable(ConstClass(node_vtable))
         setfield_gc(pv, p0, descr=valuedescr)
-        guard_nonnull(p0) []
+        guard_nonnull(p0)
         p1 = getfield_gc_r(pv, descr=valuedescr)
-        guard_nonnull(p1) []
+        guard_nonnull(p1)
         jump(p0)
         """
         expected = """
         [p0]
-        guard_nonnull(p0) []
+        guard_nonnull(p0)
         jump(p0)
         """
         self.optimize_loop(ops, expected)

File pypy/jit/metainterp/optimizeopt/virtualize.py

     optimize_GETFIELD_GC_PURE_f = optimize_GETFIELD_GC_i
 
     def optimize_SETFIELD_GC(self, op):
-        value = self.getvalue(op.getarg(0))
+        value = self.getforwarded(op.getarg(0))
 
         if value.is_virtual():
-            fieldvalue = self.getvalue(op.getarg(1))
+            fieldvalue = self.getforwarded(op.getarg(1))
+            xxx
             value.setfield(op.getdescr(), fieldvalue)
         else:
+            xxx
             value.ensure_nonnull()
-            self.emit_operation(op)
+            return op
 
     def optimize_NEW_WITH_VTABLE(self, op):
         value = self.getforwarded(op)

File pypy/jit/metainterp/optmodel.py

 
                 if cls.getopnum() in (rop.NEW_WITH_VTABLE, rop.NEW):
                     def force(self, optimizer):
-                        optimizer.emit_operation(self)
+                        if not self._isforced:
+                            optimizer.emit_operation(self)
+                            self._isforced = True
                         return self
+                    def is_virtual(self):
+                        return not self._isforced
                 else:
                     def force(self, _):
                         return self
+                    def is_virtual(self):
+                        return False
             if cls.is_guard() or cls.getopnum() == rop.FINISH:
                 addattr(Mutable, 'failargs')
             if cls.is_guard():
                 addattr(Mutable, 'knownnonnull', False)
                 Mutable.is_nonnull = ref_is_nonnull
                 Mutable.is_null = ref_is_null
+            if cls.getopnum() in (rop.NEW_WITH_VTABLE, rop.NEW):
+                addattr(Mutable, 'isforced', False)
             # for tracking last guard and merging GUARD_VALUE with
             # GUARD_NONNULL etc
             addattr(Mutable, 'lastguardpos', -1)