Commits

Alex Gaynor committed c3e20e9

a bit of progress all over

  • Participants
  • Parent commits b3ef852
  • Branches result-in-resops

Comments (0)

Files changed (4)

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

         return self._optimize_nullness(op, op.getarg(0), False)
 
     def _optimize_oois_ooisnot(self, op, expect_isnot, instance):
-        value0 = self.getvalue(op.getarg(0))
-        value1 = self.getvalue(op.getarg(1))
+        value0 = self.getforwarded(op.getarg(0))
+        value1 = self.getforwarded(op.getarg(1))
         if value0.is_virtual():
             if value1.is_virtual():
                 intres = (value0 is value1) ^ expect_isnot
         if oopspecindex == EffectInfo.OS_ARRAYCOPY:
             if self._optimize_CALL_ARRAYCOPY(op):
                 return
-        self.emit_operation(op)
+        return op
     optimize_CALL_p = optimize_CALL_i
     optimize_CALL_f = optimize_CALL_i
     optimize_CALL_v = optimize_CALL_i
         # it's being done by someone else)
         for i in range(op.numargs()):
             arg = op.getarg(i)
-            const = self.get_constant_box(arg)
+            const = self.get_constant_op(arg)
             if const is None or not const.eq_value(arg):
                 break
         else:
             self.make_constant(op, op.constbox())
             self.last_emitted_operation = REMOVED
             return
-        self.emit_operation(op)
+        return op
     optimize_CALL_PURE_f = optimize_CALL_PURE_i
     optimize_CALL_PURE_p = optimize_CALL_PURE_i
     optimize_CALL_PURE_v = optimize_CALL_PURE_i

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

     def test_oois_1(self):
         ops = """
         [p0]
-        guard_class(p0, ConstClass(node_vtable)) []
+        guard_class(p0, ConstClass(node_vtable))
         i0 = instance_ptr_ne(p0, NULL)
-        guard_true(i0) []
+        guard_true(i0)
         i1 = instance_ptr_eq(p0, NULL)
-        guard_false(i1) []
+        guard_false(i1)
         i2 = instance_ptr_ne(NULL, p0)
-        guard_true(i0) []
+        guard_true(i0)
         i3 = instance_ptr_eq(NULL, p0)
-        guard_false(i1) []
+        guard_false(i1)
         jump(p0)
         """
         expected = """
         [p0]
-        guard_class(p0, ConstClass(node_vtable)) []
+        guard_class(p0, ConstClass(node_vtable))
         jump(p0)
         """
         self.optimize_loop(ops, expected)
         [p0]
         setfield_gc(p0, 5, descr=valuedescr)     # forces p0 != NULL
         i0 = ptr_ne(p0, NULL)
-        guard_true(i0) []
+        guard_true(i0)
         i1 = ptr_eq(p0, NULL)
-        guard_false(i1) []
+        guard_false(i1)
         i2 = ptr_ne(NULL, p0)
-        guard_true(i0) []
+        guard_true(i0)
         i3 = ptr_eq(NULL, p0)
-        guard_false(i1) []
-        guard_nonnull(p0) []
+        guard_false(i1)
+        guard_nonnull(p0)
         jump(p0)
         """
         expected = """
     def test_const_guard_value(self):
         ops = """
         [i0]
-        guard_value(i0, 2) []
+        guard_value(i0, 2)
         i = int_add(5, i0)
-        guard_value(i, 7) []
+        guard_value(i, 7)
         jump(i0)
         """
         expected = """
         [i0]
-        guard_value(i0, 2) []
+        guard_value(i0, 2)
         jump(2)
         """
         self.optimize_loop(ops, expected)
     def test_constptr_guard_value(self):
         ops = """
         [p1]
-        guard_value(p1, ConstPtr(myptr)) []
+        guard_value(p1, ConstPtr(myptr))
         jump(p1)
         """
         expected = """
         [p1]
-        guard_value(p1, ConstPtr(myptr)) []
+        guard_value(p1, ConstPtr(myptr))
         jump(ConstPtr(myptr))
         """
         self.optimize_loop(ops, expected)
         ops = """
         [i]
         i1 = int_lt(i, 3)
-        guard_value(i1, 1) [i]
+        guard_value(i1, 1)
         jump(i)
         """
         expected = """
         [i]
         i1 = int_lt(i, 3)
-        guard_true(i1) [i]
+        guard_true(i1)
         jump(i)
         """
         self.optimize_loop(ops, expected)
         ops = """
         [i]
         i1 = int_is_true(i)
-        guard_value(i1, 0) [i]
+        guard_value(i1, 0)
         jump(i)
         """
         expected = """
         [i]
         i1 = int_is_true(i)
-        guard_false(i1) [i]
+        guard_false(i1)
         jump(i)
         """
         self.optimize_loop(ops, expected)
         ops = """
         [i]
         i1 = int_add(i, 3)
-        guard_value(i1, 0) [i]
+        guard_value(i1, 0)
         jump(i)
         """
         expected = """
         [i]
         i1 = int_add(i, 3)
-        guard_value(i1, 0) [i]
+        guard_value(i1, 0)
         jump(-3)
         """
         self.optimize_loop(ops, expected)
         i2 = int_gt(i0, i1)
         i3 = int_is_true(i2)
         i4 = int_is_true(i3)
-        guard_value(i4, 0) [i0, i1]
+        guard_value(i4, 0)
         jump(i0, i1)
         """
         expected = """
         [i0, i1]
         i2 = int_gt(i0, i1)
-        guard_false(i2) [i0, i1]
+        guard_false(i2)
         jump(i0, i1)
         """
         self.optimize_loop(ops, expected)
 
-
-
-
     def test_p123_simple(self):
         ops = """
         [i1, p2, p3]
         ops = """
         [i1]
         i2 = call_i(i1, descr=nonwritedescr)
-        guard_no_exception() [i1, i2]
+        guard_no_exception()
         jump(i2)
         """
         self.optimize_loop(ops, ops)
         ops = """
         [i1]
         i2 = call_pure_i(123456, i1, descr=nonwritedescr)
-        guard_no_exception() [i1, i2]
+        guard_no_exception()
         jump(i2)
         """
         expected = """
         [i1]
         i2 = call_i(123456, i1, descr=nonwritedescr)
-        guard_no_exception() [i1, i2]
+        guard_no_exception()
         jump(i2)
         """
         self.optimize_loop(ops, expected)
         [i1]
         i3 = same_as_i(81)
         i2 = call_pure_i(123456, i3, descr=nonwritedescr)
-        guard_no_exception() [i1, i2]
+        guard_no_exception()
         jump(i2)
         """
         expected = """
         ops = """
         [i1]
         i2 = call_pure_i(123456, i1, descr=nonwritedescr)
-        guard_no_exception() [i1, i2]
+        guard_no_exception()
         i3 = call_pure_i(123456, i1, descr=nonwritedescr)
-        guard_no_exception() [i1, i2, i3]
+        guard_no_exception()
         jump(i3)
         """
         expected = """
         [i1]
         i2 = call_i(123456, i1, descr=nonwritedescr)
-        guard_no_exception() [i1, i2]
+        guard_no_exception()
         jump(i2)
         """
         self.optimize_loop(ops, expected)
         ops = """
         [i1]
         i2 = call_loopinvariant_i(1, i1, descr=nonwritedescr)
-        guard_no_exception() []
-        guard_value(i2, 1) []
+        guard_no_exception()
+        guard_value(i2, 1)
         i3 = call_loopinvariant_i(1, i1, descr=nonwritedescr)
-        guard_no_exception() []
-        guard_value(i3, 1) []
+        guard_no_exception()
+        guard_value(i3, 1)
         i4 = call_loopinvariant_i(1, i1, descr=nonwritedescr)
-        guard_no_exception() []
-        guard_value(i4, 1) []
+        guard_no_exception()
+        guard_value(i4, 1)
         jump(i1)
         """
         expected = """
         [i1]
         i2 = call_i(1, i1, descr=nonwritedescr)
-        guard_no_exception() []
-        guard_value(i2, 1) []
+        guard_no_exception()
+        guard_value(i2, 1)
         jump(i1)
         """
         self.optimize_loop(ops, expected)
 
-
     # ----------
 
     def test_virtual_1(self):
     def test_getfield_gc_pure_2(self):
         ops = """
         [p0, i]
-        guard_value(p0, ConstPtr(myptr)) []
+        guard_value(p0, ConstPtr(myptr))
         i1 = getfield_gc_pure_i(p0, descr=valuedescr)
         jump(p0, i1)
         """
         expected = """
         [p0, i]
-        guard_value(p0, ConstPtr(myptr)) []
+        guard_value(p0, ConstPtr(myptr))
         jump(ConstPtr(myptr), 5)
         """
         self.node.value = 5
         [i1]
         p1 = new_array(3, descr=arraydescr)
         i3 = arraylen_gc(p1, descr=arraydescr)
-        guard_value(i3, 3) []
+        guard_value(i3, 3)
         setarrayitem_gc(p1, 1, i1, descr=arraydescr)
         setarrayitem_gc(p1, 0, 25, descr=arraydescr)
         i2 = getarrayitem_gc_i(p1, 1, descr=arraydescr)
         [f1]
         p1 = new_array(3, descr=floatarraydescr)
         i3 = arraylen_gc(p1, descr=floatarraydescr)
-        guard_value(i3, 3) []
+        guard_value(i3, 3)
         setarrayitem_gc(p1, 1, f1, descr=floatarraydescr)
         setarrayitem_gc(p1, 0, 3.5, descr=floatarraydescr)
         f2 = getarrayitem_gc_f(p1, 1, descr=floatarraydescr)

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

         # was already forced).
 
     def optimize_GETFIELD_GC_i(self, op):
-        value = self.getvalue(op.getarg(0))
+        value = self.getforwarded(op.getarg(0))
         # If this is an immutable field (as indicated by op.is_always_pure())
         # then it's safe to reuse the virtual's field, even if it has been
         # forced, because it should never be written to again.
         self.make_vstruct(op.getdescr(), op)
 
     def optimize_NEW_ARRAY(self, op):
-        sizebox = self.get_constant_box(op.getarg(0))
+        sizebox = self.get_constant_op(op.getarg(0))
         if sizebox is not None:
             # if the original 'op' did not have a ConstInt as argument,
             # build a new one with the ConstInt argument

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

             if oopspecindex == EffectInfo.OS_STR2UNICODE:
                 if self.opt_call_str_STR2UNICODE(op):
                     return
-        self.emit_operation(op)
+        return op
     optimize_CALL_f = optimize_CALL_i
     optimize_CALL_r = optimize_CALL_i
     optimize_CALL_v = optimize_CALL_i