[pypy-svn] r66556 - pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test

arigo at codespeak.net arigo at codespeak.net
Thu Jul 23 20:21:32 CEST 2009


Author: arigo
Date: Thu Jul 23 20:21:31 2009
New Revision: 66556

Modified:
   pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/oparser.py
   pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/test_optimizefindnode.py
   pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/test_optimizeopt.py
Log:
test_expand_fail_3 passes, after fixing some issue of sharing old data
in global dicts that get confused if we run both the lltype and the
ootype tests.


Modified: pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/oparser.py
==============================================================================
--- pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/oparser.py	(original)
+++ pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/oparser.py	Thu Jul 23 20:21:31 2009
@@ -4,12 +4,13 @@
 """
 
 from pypy.jit.metainterp.history import TreeLoop, BoxInt, BoxPtr, ConstInt,\
-     ConstAddr, ConstObj, ConstPtr, Box
+     ConstAddr, ConstObj, ConstPtr, Box, BoxObj
 from pypy.jit.metainterp.resoperation import rop, ResOperation
 from pypy.rpython.lltypesystem import lltype, llmemory
 from pypy.rpython.ootypesystem import ootype
 
 _cache = {}
+_default_namespace = {'lltype': {}, 'ootype': {}}
 
 class ParseError(Exception):
     pass
@@ -58,7 +59,7 @@
 
     def box_for_var(self, elem):
         try:
-            return _cache[elem]
+            return _cache[self.type_system, elem]
         except KeyError:
             pass
         if elem.startswith('i'):
@@ -67,7 +68,10 @@
             _box_counter_more_than(elem[1:])
         elif elem.startswith('p'):
             # pointer
-            box = BoxPtr()
+            if self.cpu.is_oo:
+                box = BoxObj()
+            else:
+                box = BoxPtr()
             _box_counter_more_than(elem[1:])
         else:
             for prefix, boxclass in self.boxkinds.iteritems():
@@ -76,7 +80,7 @@
                     break
             else:
                 raise ParseError("Unknown variable type: %s" % elem)
-        _cache[elem] = box
+        _cache[self.type_system, elem] = box
         box._str = elem
         return box
 
@@ -220,8 +224,10 @@
         inpargs = self.parse_header_line(line[1:-1])
         return base_indent, inpargs
 
-def parse(descr, cpu=None, namespace={}, type_system='lltype',
+def parse(descr, cpu=None, namespace=None, type_system='lltype',
           boxkinds=None):
+    if namespace is None:
+        namespace = _default_namespace[type_system]
     return OpParser(descr, cpu, namespace, type_system, boxkinds).parse()
 
 def _box_counter_more_than(s):

Modified: pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/test_optimizefindnode.py
==============================================================================
--- pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/test_optimizefindnode.py	(original)
+++ pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/test_optimizefindnode.py	Thu Jul 23 20:21:31 2009
@@ -82,6 +82,10 @@
     nodesize = cpu.typedescrof(NODE)
     nodesize2 = cpu.typedescrof(NODE2)
 
+    # force a consistent order
+    valuedescr.sort_key()
+    nextdescr.sort_key()
+
     cpu.class_sizes = {node_vtable_adr: cpu.typedescrof(NODE),
                        node_vtable_adr2: cpu.typedescrof(NODE2)}
     namespace = locals()

Modified: pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/test_optimizeopt.py
==============================================================================
--- pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/test_optimizeopt.py	(original)
+++ pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/test_optimizeopt.py	Thu Jul 23 20:21:31 2009
@@ -6,7 +6,7 @@
                                                             OOtypeMixin,
                                                             BaseTest)
 from pypy.jit.metainterp.optimizeopt import optimize
-from pypy.jit.metainterp.history import AbstractDescr, ConstInt, BoxPtr
+from pypy.jit.metainterp.history import AbstractDescr, ConstInt
 from pypy.jit.metainterp import resume, executor
 from pypy.jit.metainterp.resoperation import rop, opname
 from pypy.jit.metainterp.test.oparser import parse
@@ -630,7 +630,9 @@
         for box, varname in zip(boxes, varnames):
             _variables_equal(box, varname, strict=True)
         #
-        for cls_vtable, resolved, fieldstext in virtuals.values():
+        for match in parts:
+            pvar = match.group(1)
+            cls_vtable, resolved, fieldstext = virtuals[pvar]
             assert resolved is not None
             for fieldtext in fieldstext.split(','):
                 fieldtext = fieldtext.strip()
@@ -697,7 +699,7 @@
             ''')
 
     def test_expand_fail_3(self):
-        py.test.skip("in-progress")
+        self.make_fail_descr()
         ops = """
         [i1, i2, i3, p3]
         p1 = new_with_vtable(ConstClass(node_vtable))
@@ -707,22 +709,20 @@
         setfield_gc(p2, i2, descr=valuedescr)
         setfield_gc(p2, p3, descr=nextdescr)
         guard_true(i1)
-            fail(p1, i3)
+            fail(p1, i3, descr=fdescr)
         jump(i2, i1, i3, p3)
         """
         expected = """
         [i1, i2, i3, p3]
         guard_true(i1)
-            p1 = new_with_vtable(ConstClass(node_vtable), descr=nodesize)
-            p2 = new_with_vtable(ConstClass(node_vtable), descr=nodesize)
-            setfield_gc(p1, 1, descr=valuedescr)
-            setfield_gc(p1, p2, descr=nextdescr)
-            setfield_gc(p2, i2, descr=valuedescr)
-            setfield_gc(p2, p3, descr=nextdescr)
-            fail(p1, i3)
+            fail(i3, i2, p3, descr=fdescr)
         jump(i2, 1, i3, p3)
         """
         self.optimize_loop(ops, 'Not, Not, Not, Not', expected, i1=1)
+        self.check_expanded_fail_descr('''p1, i3
+            where p1 is a node_vtable, valuedescr=1, nextdescr=p2
+            where p2 is a node_vtable, valuedescr=i2, nextdescr=p3
+            ''')
 
     def test_expand_fail_4(self):
         py.test.skip("in-progress")



More information about the Pypy-commit mailing list