[pypy-svn] r62790 - in pypy/branch/pyjitpl5/pypy/jit: backend/llgraph metainterp/test

fijal at codespeak.net fijal at codespeak.net
Tue Mar 10 10:02:41 CET 2009


Author: fijal
Date: Tue Mar 10 10:02:40 2009
New Revision: 62790

Modified:
   pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py
   pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py
   pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_list_optimize.py
   pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_optimize.py
   pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_vable_optimize.py
Log:
fix tests


Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py	Tue Mar 10 10:02:40 2009
@@ -19,6 +19,7 @@
 from pypy.jit.metainterp import heaptracker, resoperation, executor
 from pypy.jit.metainterp.resoperation import rop
 from pypy.jit.backend.llgraph import symbolic
+from pypy.jit.metainterp import history
 
 from pypy.rlib.objectmodel import ComputedIntSymbolic
 from pypy.rlib.rarithmetic import r_uint, intmask
@@ -139,6 +140,8 @@
         self.opnum = opnum
         self.args = []
         self.result = None
+        if descr:
+            assert isinstance(descr, history.AbstractValue)
         self.descr = descr
         self.livevars = []   # for guards only
 
@@ -565,7 +568,7 @@
 
     def op_call(self, calldescr, func, *args):
         _call_args[:] = args
-        if calldescr == sys.maxint:
+        if calldescr.getint() == sys.maxint:
             err_result = None
         elif calldescr.getint() & 1:
             err_result = lltype.nullptr(llmemory.GCREF.TO)

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py	Tue Mar 10 10:02:40 2009
@@ -218,12 +218,12 @@
     @staticmethod
     def calldescrof(ARGS, RESULT):
         if RESULT is lltype.Void:
-            return sys.maxint
+            return history.ConstInt(sys.maxint)
         token = history.getkind(RESULT)
         if token == 'ptr':
-            return 1
+            return history.ConstInt(1)
         else:
-            return 0
+            return history.ConstInt(0)
 
     @staticmethod
     def typefor(fielddesc):
@@ -291,9 +291,10 @@
                                                             fielddescr,
                                                             self.memo_cast))
 
-    def do_getfield_raw(self, args, fielddescr):
+    def do_getfield_raw(self, args, fieldbox):
+        fielddescr = fieldbox.getint()
         struct = self.cast_int_to_adr(args[0].getint())
-        if self.typefor(fielddescr) == 'ptr':
+        if self.typefor(fieldbox) == 'ptr':
             return history.BoxPtr(llimpl.do_getfield_raw_ptr(struct,
                                                              fielddescr))
         else:
@@ -359,6 +360,7 @@
         llimpl.do_strsetitem(0, string, index, newvalue)
 
     def do_call(self, args, calldescr):
+        assert isinstance(calldescr, history.ConstInt)
         func = args[0].getint()
         for arg in args[1:]:
             if (isinstance(arg, history.BoxPtr) or

Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_list_optimize.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_list_optimize.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_list_optimize.py	Tue Mar 10 10:02:40 2009
@@ -30,20 +30,20 @@
 
 def test_A_find_nodes():
     spec = PerfectSpecializer(Loop(A.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     node = spec.nodes[A.l]
     assert isinstance(node.cls.source, FixedList)
     assert node.expanded_fields.keys() == [0]
 
 def test_A_intersect():
     spec = PerfectSpecializer(Loop(A.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
     assert isinstance(spec.specnodes[0], DelayedFixedListSpecNode)
 
 def test_A_optimize_loop():
     spec = PerfectSpecializer(Loop(A.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
     spec.optimize_loop(None)
     equaloplists(spec.loop.operations, [
@@ -72,7 +72,7 @@
 
 def test_B_optimize_loop():
     spec = PerfectSpecializer(Loop(B.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
     spec.optimize_loop(None)
     equaloplists(spec.loop.operations, [

Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_optimize.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_optimize.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_optimize.py	Tue Mar 10 10:02:40 2009
@@ -109,7 +109,7 @@
 
 def test_A_find_nodes():
     spec = PerfectSpecializer(Loop(A.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     assert spec.nodes[A.sum] is not spec.nodes[A.sum2]
     assert spec.nodes[A.n1] is not spec.nodes[A.n2]
     assert spec.nodes[A.n1].cls.source.value == node_vtable_adr
@@ -119,21 +119,21 @@
 
 def test_A_intersect_input_and_output():
     spec = PerfectSpecializer(Loop(A.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
     assert len(spec.specnodes) == 2
     spec_sum, spec_n = spec.specnodes
     assert isinstance(spec_sum, NotSpecNode)
     assert isinstance(spec_n, VirtualInstanceSpecNode)
     assert spec_n.known_class.value == node_vtable_adr
-    assert spec_n.fields[0][0] == A.ofs_value
+    assert spec_n.fields[0][0] == A.ofs_value.getint()
     assert isinstance(spec_n.fields[0][1], NotSpecNode)
 
 def test_A_optimize_loop():
     spec = PerfectSpecializer(Loop(A.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
-    spec.optimize_loop(None)
+    spec.optimize_loop(cpu)
     equaloplists(spec.loop.operations, [
         ResOperation('merge_point', [A.sum, A.v], None),
         ResOperation('int_sub', [A.v, ConstInt(1)], A.v2),
@@ -161,7 +161,7 @@
 
 def test_B_find_nodes():
     spec = PerfectSpecializer(Loop(B.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     assert spec.nodes[B.n1].cls.source.value == node_vtable_adr
     assert spec.nodes[B.n1].escaped
     assert spec.nodes[B.n2].cls.source.value == node_vtable_adr
@@ -169,7 +169,7 @@
 
 def test_B_intersect_input_and_output():
     spec = PerfectSpecializer(Loop(B.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
     assert len(spec.specnodes) == 2
     spec_sum, spec_n = spec.specnodes
@@ -179,9 +179,9 @@
 
 def test_B_optimize_loop():
     spec = PerfectSpecializer(Loop(B.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
-    spec.optimize_loop(None)
+    spec.optimize_loop(cpu)
     equaloplists(spec.loop.operations, [
         ResOperation('merge_point', [B.sum, B.n1], None),
         # guard_class is gone
@@ -216,14 +216,14 @@
 
 def test_C_find_nodes():
     spec = PerfectSpecializer(Loop(C.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     assert spec.nodes[C.n1].cls.source.value == node_vtable_adr
     assert spec.nodes[C.n1].escaped
     assert spec.nodes[C.n2].cls.source.value == node_vtable_adr
 
 def test_C_intersect_input_and_output():
     spec = PerfectSpecializer(Loop(C.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
     assert spec.nodes[C.n2].escaped
     assert len(spec.specnodes) == 2
@@ -234,9 +234,9 @@
 
 def test_C_optimize_loop():
     spec = PerfectSpecializer(Loop(C.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
-    spec.optimize_loop(None)
+    spec.optimize_loop(cpu)
     equaloplists(spec.loop.operations, [
         ResOperation('merge_point', [C.sum, C.n1], None),
         # guard_class is gone
@@ -270,7 +270,7 @@
 
 def test_D_intersect_input_and_output():
     spec = PerfectSpecializer(Loop(D.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     py.test.raises(CancelInefficientLoop, spec.intersect_input_and_output)
 
 # ____________________________________________________________
@@ -293,9 +293,9 @@
         
 def test_E_optimize_loop():
     spec = PerfectSpecializer(Loop(E.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
-    spec.optimize_loop(None)
+    spec.optimize_loop(cpu)
     equaloplists(spec.loop.operations, [
         ResOperation('merge_point', [E.sum, E.v], None),
         # guard_class is gone
@@ -309,7 +309,7 @@
     assert guard_op.liveboxes == [E.sum2, E.v2]
     vt = cpu.cast_adr_to_int(node_vtable_adr)
     assert guard_op.storage_info.allocations == [vt]
-    assert guard_op.storage_info.setfields == [(0, E.ofs_value, -2)]
+    assert guard_op.storage_info.setfields == [(0, E.ofs_value.value, -2)]
 
 def test_E_rebuild_after_failure():
     class FakeMetaInterp(object):
@@ -325,9 +325,9 @@
             return 'stuff'
     
     spec = PerfectSpecializer(Loop(E.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
-    spec.optimize_loop(None)
+    spec.optimize_loop(cpu)
     guard_op = spec.loop.operations[-2]
     v_sum_b = BoxInt(13)
     v_v_b = BoxInt(14)
@@ -376,16 +376,16 @@
 
 def test_F_find_nodes():
     spec = PerfectSpecializer(Loop(F.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     assert not spec.nodes[F.n1].escaped
     assert not spec.nodes[F.n2].escaped
 
 def test_F_optimize_loop():
     spec = PerfectSpecializer(Loop(F.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
     assert spec.nodes[F.n3].escaped
-    spec.optimize_loop(None)
+    spec.optimize_loop(cpu)
     equaloplists(spec.loop.operations, [
             ResOperation('merge_point', [F.sum, F.v, F.n3], None),
             ResOperation('int_sub', [F.v, ConstInt(1)], F.v2),
@@ -415,9 +415,9 @@
 
 def test_F2_optimize_loop():
     spec = PerfectSpecializer(Loop(F2.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
-    spec.optimize_loop(None)
+    spec.optimize_loop(cpu)
     equaloplists(spec.loop.operations, F2.ops)
 
 # ____________________________________________________________
@@ -445,9 +445,9 @@
 
 def test_G_optimize_loop():
     spec = PerfectSpecializer(Loop(G.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
-    spec.optimize_loop(None)
+    spec.optimize_loop(cpu)
     equaloplists(spec.loop.operations, [
         ResOperation('merge_point', [G.sum, G.v], None),
         # guard_class is gone
@@ -461,7 +461,7 @@
     assert guard_op.liveboxes == [G.sum2, ConstInt(124)]
     vt = cpu.cast_adr_to_int(node_vtable_adr)
     assert guard_op.storage_info.allocations == [vt]
-    assert guard_op.storage_info.setfields == [(0, G.ofs_value, -2)]
+    assert guard_op.storage_info.setfields == [(0, G.ofs_value.value, -2)]
 
 # ____________________________________________________________
 
@@ -492,7 +492,7 @@
 
 def test_H_intersect_input_and_output():
     spec = PerfectSpecializer(Loop(H.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
     assert spec.nodes[H.n0].escaped
     assert spec.nodes[H.n1].escaped
@@ -520,7 +520,7 @@
 
 def test_I_intersect_input_and_output():
     spec = PerfectSpecializer(Loop(I.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
     assert spec.nodes[I.n0].escaped
     assert spec.nodes[I.n2].escaped
@@ -549,7 +549,7 @@
 
 def test_J_intersect_input_and_output():
     spec = PerfectSpecializer(Loop(J.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
     assert not spec.nodes[J.n0].escaped
     assert spec.nodes[J.n1].escaped
@@ -575,9 +575,9 @@
 
 def test_K0_optimize_loop():
     spec = PerfectSpecializer(Loop(K0.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
-    spec.optimize_loop(None)
+    spec.optimize_loop(cpu)
     v4 = spec.loop.operations[-1].args[-1]
     equaloplists(spec.loop.operations, [
         ResOperation('merge_point', [K0.sum, K0.n1, K0.v], None),
@@ -609,9 +609,9 @@
 
 def test_K1_optimize_loop():
     spec = PerfectSpecializer(Loop(K1.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
-    spec.optimize_loop(None)
+    spec.optimize_loop(cpu)
     v4 = spec.loop.operations[-1].args[-1]
     equaloplists(spec.loop.operations, [
         ResOperation('merge_point', [K1.sum, K1.n1, K1.v], None),
@@ -642,9 +642,9 @@
 
 def test_K_optimize_loop():
     spec = PerfectSpecializer(Loop(K.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
-    spec.optimize_loop(None)
+    spec.optimize_loop(cpu)
     equaloplists(spec.loop.operations, [
         ResOperation('merge_point', [K.sum, K.n1, K.v], None),
         ResOperation('int_sub', [K.v, ConstInt(1)], K.v2),
@@ -673,9 +673,9 @@
 
 def test_L_optimize_loop():
     spec = PerfectSpecializer(Loop(L.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
-    spec.optimize_loop(None)
+    spec.optimize_loop(cpu)
     equaloplists(spec.loop.operations, [
         ResOperation('merge_point', [L.sum, L.n1, L.v], None),
         ResOperation('int_sub', [L.v, ConstInt(1)], L.v2),
@@ -704,9 +704,9 @@
 
 def test_M_optimize_loop():
     spec = PerfectSpecializer(Loop(M.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
-    spec.optimize_loop(None)
+    spec.optimize_loop(cpu)
     v4 = spec.loop.operations[-1].args[-1]
     equaloplists(spec.loop.operations, [
         ResOperation('merge_point', [M.sum, M.n1, M.v], None),
@@ -735,9 +735,9 @@
 
 def test_N_optimize_loop():
     spec = PerfectSpecializer(Loop(N.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
-    spec.optimize_loop(None)
+    spec.optimize_loop(cpu)
     v4 = spec.loop.operations[-1].args[-1]
     equaloplists(spec.loop.operations, [
         ResOperation('merge_point', [N.sum, N.n1, N.v], None),
@@ -764,9 +764,9 @@
 
 def test_O1_optimize_loop():
     spec = PerfectSpecializer(Loop(O1.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
-    spec.optimize_loop(None)
+    spec.optimize_loop(cpu)
     equaloplists(spec.loop.operations, [
         ResOperation('merge_point', [], None),
         ResOperation('escape', [], O1.n1),
@@ -794,9 +794,9 @@
 
 def test_O2_optimize_loop():
     spec = PerfectSpecializer(Loop(O2.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
-    spec.optimize_loop(None)
+    spec.optimize_loop(cpu)
     equaloplists(spec.loop.operations, [
         ResOperation('merge_point', [], None),
         ResOperation('escape', [], O2.n1),
@@ -826,9 +826,9 @@
 
 def test_O3_optimize_loop():
     spec = PerfectSpecializer(Loop(O3.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
-    spec.optimize_loop(None)
+    spec.optimize_loop(cpu)
     equaloplists(spec.loop.operations, [
         ResOperation('merge_point', [], None),
         ResOperation('escape', [], O3.n1),

Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_vable_optimize.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_vable_optimize.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_vable_optimize.py	Tue Mar 10 10:02:40 2009
@@ -101,12 +101,12 @@
 
 def test_A_find_nodes():
     spec = PerfectSpecializer(Loop(A.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     assert spec.nodes[A.fr].virtualized
 
 def test_A_intersect_input_and_output():
     spec = PerfectSpecializer(Loop(A.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
     assert spec.nodes[A.fr].escaped
     assert spec.nodes[A.fr].virtualized
@@ -116,9 +116,9 @@
 
 def test_A_optimize_loop():
     spec = PerfectSpecializer(Loop(A.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
-    spec.optimize_loop(None)
+    spec.optimize_loop(cpu)
     equaloplists(spec.loop.operations, [
         ResOperation('merge_point', [A.sum, A.fr, A.v], None),
         ResOperation('int_sub', [A.v, ConstInt(1)], A.v2),
@@ -152,14 +152,14 @@
 
 def test_B_intersect_input_and_output():
     spec = PerfectSpecializer(Loop(B.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
     assert spec.nodes[B.fr].escaped
     assert spec.nodes[B.fr].virtualized
     assert spec.nodes[B.n1].escaped
     assert isinstance(spec.specnodes[0], VirtualizableSpecNode)
     assert len(spec.specnodes[0].fields) == 1
-    assert spec.specnodes[0].fields[0][0] == B.ofs_node
+    assert spec.specnodes[0].fields[0][0] == B.ofs_node.value
     assert isinstance(spec.specnodes[0].fields[0][1], NotSpecNode)
 
 # ____________________________________________________________
@@ -188,7 +188,7 @@
 
 def test_C_intersect_input_and_output():
     spec = PerfectSpecializer(Loop(C.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
     assert spec.nodes[C.fr].escaped
     assert spec.nodes[C.fr].virtualized
@@ -196,7 +196,7 @@
     assert spec.nodes[C.n2].escaped
     assert isinstance(spec.specnodes[0], VirtualizableSpecNode)
     assert len(spec.specnodes[0].fields) == 1
-    assert spec.specnodes[0].fields[0][0] == C.ofs_node
+    assert spec.specnodes[0].fields[0][0] == C.ofs_node.value
     assert isinstance(spec.specnodes[0].fields[0][1], DelayedSpecNode)
 
 
@@ -228,7 +228,7 @@
 def test_D_intersect_input_and_output():
     py.test.skip("XXX")
     spec = PerfectSpecializer(Loop(D.ops))
-    spec.find_nodes()
+    spec.find_nodes(cpu)
     spec.intersect_input_and_output()
     assert spec.nodes[D.fr].escaped
     assert spec.nodes[D.fr].virtualized



More information about the Pypy-commit mailing list