[pypy-commit] pypy result-in-resops: clean up some leftovers

fijal noreply at buildbot.pypy.org
Tue Sep 25 11:44:08 CEST 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: result-in-resops
Changeset: r57554:be2372096220
Date: 2012-09-23 22:26 +0200
http://bitbucket.org/pypy/pypy/changeset/be2372096220/

Log:	clean up some leftovers

diff --git a/pypy/jit/metainterp/optimizeopt/heap.py b/pypy/jit/metainterp/optimizeopt/heap.py
--- a/pypy/jit/metainterp/optimizeopt/heap.py
+++ b/pypy/jit/metainterp/optimizeopt/heap.py
@@ -264,7 +264,7 @@
             opnum == rop.COPYUNICODECONTENT):    # no effect on GC struct/array
             return
         if opnum in opgroups.ALLCALLS:
-            if opnum == rop.CALL_ASSEMBLER:
+            if opnum in opgroups.CALL_ASSEMBLER:
                 self._seen_guard_not_invalidated = False
             else:
                 effectinfo = op.getdescr().get_extra_info()
@@ -377,7 +377,7 @@
         structvalue.ensure_nonnull()
         self.emit_operation(op)
         # then remember the result of reading the field
-        fieldvalue = self.getvalue(op.result)
+        fieldvalue = self.getvalue(op)
         cf.remember_field_value(structvalue, fieldvalue, op)
     optimize_GETFIELD_GC_p = optimize_GETFIELD_GC_i
     optimize_GETFIELD_GC_f = optimize_GETFIELD_GC_i
diff --git a/pypy/jit/metainterp/optimizeopt/rewrite.py b/pypy/jit/metainterp/optimizeopt/rewrite.py
--- a/pypy/jit/metainterp/optimizeopt/rewrite.py
+++ b/pypy/jit/metainterp/optimizeopt/rewrite.py
@@ -344,7 +344,7 @@
 
     def optimize_INT_IS_TRUE(self, op):
         if self.getvalue(op.getarg(0)).is_bool_box:
-            self.make_equal_to(op, self.getvalue(op.getarg(0)))
+            self.replace(op, op.getarg(0))
             return
         self._optimize_nullness(op, op.getarg(0), True)
 
diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
@@ -18,7 +18,7 @@
     b1 = BoxInt()
     opt = optimizeopt.Optimizer(FakeMetaInterpStaticData(LLtypeMixin.cpu),
                                 None)
-    op = create_resop_1(rop.GUARD_TRUE, None, 'dummy')
+    op = create_resop_1(rop.GUARD_TRUE, None, BoxInt(0))
     # setup rd data
     fi0 = resume.FrameInfo(None, "code0", 11)
     op._rd_frame_info_list = resume.FrameInfo(fi0, "code1", 33)
@@ -370,21 +370,19 @@
 
     def test_remove_consecutive_guard_value_constfold(self):
         ops = """
-        []
-        i0 = escape()
+        [i0]
         guard_value(i0, 0) []
         i1 = int_add(i0, 1)
         guard_value(i1, 1) []
         i2 = int_add(i1, 2)
         escape(i2)
-        jump()
-        """
-        expected = """
-        []
-        i0 = escape()
+        jump(i0)
+        """
+        expected = """
+        [i0]
         guard_value(i0, 0) []
         escape(3)
-        jump()
+        jump(0)
         """
         self.optimize_loop(ops, expected)
 
@@ -483,17 +481,15 @@
 
     def test_ooisnull_on_null_ptr_1(self):
         ops = """
-        []
-        p0 = escape()
+        [p0, p1]
         guard_isnull(p0) []
         guard_isnull(p0) []
-        jump()
-        """
-        expected = """
-        []
-        p0 = escape()
+        jump(p1, p1)
+        """
+        expected = """
+        [p0, p1]
         guard_isnull(p0) []
-        jump()
+        jump(p1, p1)
         """
         self.optimize_loop(ops, expected)
 
@@ -574,12 +570,16 @@
 
     def test_constptr_guard_value(self):
         ops = """
-        []
-        p1 = escape()
+        [p1]
         guard_value(p1, ConstPtr(myptr)) []
-        jump()
-        """
-        self.optimize_loop(ops, ops)
+        jump(p1)
+        """
+        expected = """
+        [p1]
+        guard_value(p1, ConstPtr(myptr)) []
+        jump(ConstPtr(myptr))
+        """
+        self.optimize_loop(ops, expected)
 
     def test_guard_value_to_guard_true(self):
         ops = """
@@ -649,7 +649,7 @@
     def test_p123_simple(self):
         ops = """
         [i1, p2, p3]
-        i3 = getfield_gc(p3, descr=valuedescr)
+        i3 = getfield_gc_i(p3, descr=valuedescr)
         escape(i3)
         p1 = new_with_vtable(ConstClass(node_vtable))
         setfield_gc(p1, i1, descr=valuedescr)
@@ -661,7 +661,7 @@
     def test_p123_nested(self):
         ops = """
         [i1, p2, p3]
-        i3 = getfield_gc(p3, descr=valuedescr)
+        i3 = getfield_gc_i(p3, descr=valuedescr)
         escape(i3)
         p1 = new_with_vtable(ConstClass(node_vtable))
         p1sub = new_with_vtable(ConstClass(node_vtable2))
@@ -677,8 +677,8 @@
     def test_p123_anti_nested(self):
         ops = """
         [i1, p2, p3]
-        p3sub = getfield_gc(p3, descr=nextdescr)
-        i3 = getfield_gc(p3sub, descr=valuedescr)
+        p3sub = getfield_gc_p(p3, descr=nextdescr)
+        i3 = getfield_gc_i(p3sub, descr=valuedescr)
         escape(i3)
         p1 = new_with_vtable(ConstClass(node_vtable))
         p2sub = new_with_vtable(ConstClass(node_vtable2))
@@ -695,7 +695,7 @@
     def test_keep_guard_no_exception(self):
         ops = """
         [i1]
-        i2 = call(i1, descr=nonwritedescr)
+        i2 = call_i(i1, descr=nonwritedescr)
         guard_no_exception() [i1, i2]
         jump(i2)
         """
@@ -704,13 +704,13 @@
     def test_keep_guard_no_exception_with_call_pure_that_is_not_folded(self):
         ops = """
         [i1]
-        i2 = call_pure(123456, i1, descr=nonwritedescr)
+        i2 = call_pure_i(123456, i1, descr=nonwritedescr)
         guard_no_exception() [i1, i2]
         jump(i2)
         """
         expected = """
         [i1]
-        i2 = call(123456, i1, descr=nonwritedescr)
+        i2 = call_i(123456, i1, descr=nonwritedescr)
         guard_no_exception() [i1, i2]
         jump(i2)
         """
diff --git a/pypy/jit/metainterp/optimizeopt/virtualize.py b/pypy/jit/metainterp/optimizeopt/virtualize.py
--- a/pypy/jit/metainterp/optimizeopt/virtualize.py
+++ b/pypy/jit/metainterp/optimizeopt/virtualize.py
@@ -3,7 +3,8 @@
 from pypy.jit.metainterp.optimizeopt import optimizer
 from pypy.jit.metainterp.optimizeopt.util import (make_dispatcher_method,
     descrlist_dict, sort_descrs)
-from pypy.jit.metainterp.resoperation import rop, Const, ConstInt, BoxInt
+from pypy.jit.metainterp.resoperation import rop, Const, ConstInt, BoxInt,\
+     create_resop_2
 from pypy.rlib.objectmodel import we_are_translated
 from pypy.jit.metainterp.optimizeopt.optimizer import OptValue
 
@@ -154,9 +155,8 @@
                 if value.is_null():
                     continue
                 subbox = value.force_box(optforce)
-                op = ResOperation(rop.SETFIELD_GC, [box, subbox], None,
-                                  descr=ofs)
-
+                op = create_resop_2(rop.SETFIELD_GC, None, self.op, subbox,
+                                    descr=ofs)
                 optforce.emit_operation(op)
 
     def _get_field_descr_list(self):
diff --git a/pypy/jit/metainterp/resoperation.py b/pypy/jit/metainterp/resoperation.py
--- a/pypy/jit/metainterp/resoperation.py
+++ b/pypy/jit/metainterp/resoperation.py
@@ -43,7 +43,9 @@
         op = cls()
     else:
         op = cls(result)
-    op.initarglist(args)
+    for _arg in args:
+        assert _arg.type != VOID
+    op._args = args
     if descr is not None:
         assert isinstance(op, ResOpWithDescr)
         assert not op.is_guard()
@@ -76,6 +78,7 @@
         op = cls()
     else:
         op = cls(result)
+    assert arg0.type != VOID
     op._arg0 = arg0
     if descr is not None:
         assert isinstance(op, ResOpWithDescr)
@@ -94,6 +97,8 @@
         op = cls()
     else:
         op = cls(result)
+    assert arg0.type != VOID
+    assert arg1.type != VOID
     op._arg0 = arg0
     op._arg1 = arg1
     if descr is not None:
@@ -113,6 +118,9 @@
         op = cls()
     else:
         op = cls(result)
+    assert arg0.type != VOID
+    assert arg1.type != VOID
+    assert arg2.type != VOID
     op._arg0 = arg0
     op._arg1 = arg1
     op._arg2 = arg2
@@ -653,10 +661,6 @@
     # methods implemented by the arity mixins
     # ---------------------------------------
 
-    def initarglist(self, args):
-        "This is supposed to be called only just after the ResOp has been created"
-        raise NotImplementedError
-
     def getarglist(self):
         raise NotImplementedError
 
@@ -973,9 +977,6 @@
 
     NUMARGS = 0
 
-    def initarglist(self, args):
-        assert len(args) == 0
-
     def getarglist(self):
         return []
 
@@ -1012,10 +1013,6 @@
 
     NUMARGS = 1
 
-    def initarglist(self, args):
-        assert len(args) == 1
-        self._arg0, = args
-
     def getarglist(self):
         return [self._arg0]
 
@@ -1067,10 +1064,6 @@
 
     NUMARGS = 2
 
-    def initarglist(self, args):
-        assert len(args) == 2
-        self._arg0, self._arg1 = args
-
     def numargs(self):
         return 2
 
@@ -1131,10 +1124,6 @@
 
     NUMARGS = 3
 
-    def initarglist(self, args):
-        assert len(args) == 3
-        self._arg0, self._arg1, self._arg2 = args
-
     def getarglist(self):
         return [self._arg0, self._arg1, self._arg2]
 
@@ -1196,9 +1185,6 @@
 
     NUMARGS = -1
 
-    def initarglist(self, args):
-        self._args = args
-
     def getarglist(self):
         return self._args
 
diff --git a/pypy/jit/tool/oparser.py b/pypy/jit/tool/oparser.py
--- a/pypy/jit/tool/oparser.py
+++ b/pypy/jit/tool/oparser.py
@@ -20,7 +20,7 @@
     def __init__(self, opnum, args, result, descr=None):
         assert opnum == self.OPNUM
         self.result = result
-        self.initarglist(args)
+        self._args = args
         self.setdescr(descr)
 
     @classmethod


More information about the pypy-commit mailing list