[pypy-commit] pypy result-in-resops: some minimal fixes to get test_util running

fijal noreply at buildbot.pypy.org
Thu Sep 20 15:31:04 CEST 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: result-in-resops
Changeset: r57405:193aa205e785
Date: 2012-09-20 15:30 +0200
http://bitbucket.org/pypy/pypy/changeset/193aa205e785/

Log:	some minimal fixes to get test_util running

diff --git a/pypy/jit/metainterp/optimizeopt/test/test_util.py b/pypy/jit/metainterp/optimizeopt/test/test_util.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_util.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_util.py
@@ -7,7 +7,8 @@
 from pypy.jit.backend.llgraph import runner
 from pypy.jit.metainterp.history import (TreeLoop, AbstractDescr,
                                          JitCellToken, TargetToken)
-from pypy.jit.metainterp.optimizeopt.util import sort_descrs, equaloplists
+from pypy.jit.metainterp.optimizeopt.util import sort_descrs, equaloplists,\
+     ArgsDict
 from pypy.jit.codewriter.effectinfo import EffectInfo
 from pypy.jit.codewriter.heaptracker import register_known_gctype
 from pypy.jit.tool.oparser import parse, pure_parse
@@ -15,7 +16,8 @@
 from pypy.jit.metainterp import compile, resume, history
 from pypy.jit.metainterp.jitprof import EmptyProfiler
 from pypy.config.pypyoption import get_pypy_config
-from pypy.jit.metainterp.resoperation import rop, create_resop, BoxPtr
+from pypy.jit.metainterp.resoperation import rop, create_resop, BoxPtr,\
+     create_resop_0
 from pypy.jit.metainterp.optimizeopt.unroll import Inliner
 
 def test_sort_descrs():
@@ -69,6 +71,14 @@
     py.test.raises(AssertionError,
                    "equaloplists(loop1.operations, loop3.operations)")
 
+
+def test_argsdict():
+    d = ArgsDict()
+    op = create_resop_0(rop.FORCE_TOKEN, 13)
+    assert d.get(op) is None
+    d.setitem(op)
+    assert d.get(op) is op
+
 # ____________________________________________________________
 
 class LLtypeMixin(object):
diff --git a/pypy/jit/metainterp/optimizeopt/util.py b/pypy/jit/metainterp/optimizeopt/util.py
--- a/pypy/jit/metainterp/optimizeopt/util.py
+++ b/pypy/jit/metainterp/optimizeopt/util.py
@@ -169,34 +169,39 @@
         for i in range(op1.numargs()):
             x = op1.getarg(i)
             y = op2.getarg(i)
-            assert x.same_box(remap.get(y, y))
+            assert x.eq(remap.get(y, y))
         if op2 in remap:
             if op2 is None:
                 assert op1 == remap[op2]
             else:
-                assert op1.same_box(remap[op2])
+                assert op1.eq(remap[op2])
         else:
             remap[op2] = op1
         if op1.getopnum() not in (rop.JUMP, rop.LABEL):      # xxx obscure
             assert op1.getdescr() == op2.getdescr()
-        if op1.getfailargs() or op2.getfailargs():
-            assert len(op1.getfailargs()) == len(op2.getfailargs())
-            if strict_fail_args:
-                for x, y in zip(op1.getfailargs(), op2.getfailargs()):
-                    if x is None:
-                        assert remap.get(y, y) is None
-                    else:
-                        assert x.same_box(remap.get(y, y))
-            else:
-                fail_args1 = set(op1.getfailargs())
-                fail_args2 = set([remap.get(y, y) for y in op2.getfailargs()])
-                for x in fail_args1:
-                    for y in fail_args2:
-                        if x.same_box(y):
-                            fail_args2.remove(y)
-                            break
-                    else:
-                        assert False
+        if op1.is_guard():
+            assert op2.is_guard()
+            if op1.get_extra("failargs") or op2.get_extra("failargs"):
+                assert (len(op1.get_extra("failargs")) ==
+                        len(op2.get_extra("failargs")))
+                if strict_fail_args:
+                    for x, y in zip(op1.get_extra("failargs"),
+                                    op2.get_extra("failargs")):
+                        if x is None:
+                            assert remap.get(y, y) is None
+                        else:
+                            assert x.eq(remap.get(y, y))
+                else:
+                    fail_args1 = set(op1.get_extra("failargs"))
+                    fail_args2 = set([remap.get(y, y) for y in
+                                      op2.get_extra("failargs")])
+                    for x in fail_args1:
+                        for y in fail_args2:
+                            if x.eq(y):
+                                fail_args2.remove(y)
+                                break
+                        else:
+                            assert False
     assert len(oplist1) == len(oplist2)
     print '-'*totwidth
     return True
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
@@ -593,7 +593,8 @@
 
     def __hash__(self):
         import sys
-        if sys._getframe(1).f_code.co_filename.endswith('resume.py'):
+        co_fname = sys._getframe(1).f_code.co_filename
+        if co_fname.endswith('resume.py') or co_fname.endswith('optimizeopt/util.py'):
             return object.__hash__(self)
         raise Exception("Should not hash resops, use get/set extra instead")
 


More information about the pypy-commit mailing list