[pypy-svn] r65432 - in pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp: . test

fijal at codespeak.net fijal at codespeak.net
Tue May 26 21:10:06 CEST 2009


Author: fijal
Date: Tue May 26 21:10:04 2009
New Revision: 65432

Modified:
   pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/optimize2.py
   pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/oparser.py
   pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_optimize2.py
Log:
make guard_nonvirtualizable yield a class. That's mostly to make llgraph
backend a bit happier, I'm not too happy about it


Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/optimize2.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/optimize2.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/optimize2.py	Tue May 26 21:10:04 2009
@@ -110,7 +110,7 @@
         for node, d in self.additional_stores.iteritems():
             for field, fieldnode in d.iteritems():
                 gop = ResOperation(rop.GUARD_NONVIRTUALIZED,
-                                   [node.source], None)
+                                   [node.source, node.cls], None)
                 gop.vdesc = node.vdesc
                 gop.suboperations = [ResOperation(rop.FAIL, [], None)]
                 op.suboperations.append(gop)
@@ -120,7 +120,7 @@
             for field, (fieldnode, descr) in d.iteritems():
                 box = fieldnode.source
                 gop = ResOperation(rop.GUARD_NONVIRTUALIZED,
-                                   [node.source], None)
+                                   [node.source, node.cls], None)
                 gop.suboperations = [ResOperation(rop.FAIL, [], None)]
                 gop.vdesc = node.vdesc
                 op.suboperations.append(gop) 
@@ -186,6 +186,7 @@
     def optimize_guard_nonvirtualized(op, spec):
         instnode = spec.getnode(op.args[0])
         instnode.virtualized = True
+        instnode.cls = op.args[1]
         instnode.vdesc = op.vdesc
         return True
 

Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/oparser.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/oparser.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/oparser.py	Tue May 26 21:10:04 2009
@@ -4,7 +4,7 @@
 """
 
 from pypy.jit.metainterp.history import TreeLoop, BoxInt, BoxPtr, ConstInt,\
-     ConstAddr, ConstObj
+     ConstAddr, ConstObj, ConstPtr
 from pypy.jit.metainterp.resoperation import rop, ResOperation
 from pypy.rpython.lltypesystem import lltype, llmemory
 from pypy.rpython.ootypesystem import ootype
@@ -59,6 +59,8 @@
                                      self.cpu)
                 else:
                     return ConstObj(ootype.cast_to_object(self.consts[name]))
+            elif arg == 'None':
+                return None
             return self.vars[arg]
 
     def parse_op(self, line):

Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_optimize2.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_optimize2.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_optimize2.py	Tue May 26 21:10:04 2009
@@ -59,7 +59,8 @@
 
     TP = lltype.GcArray(lltype.Signed)
 
-    XY = lltype.GcStruct('XY', ('inst_field', lltype.Signed),
+    XY = lltype.GcStruct('XY', ('parent', OBJECT),
+                         ('inst_field', lltype.Signed),
                          ('inst_other_field', lltype.Signed),
                          ('inst_list', lltype.Ptr(TP)),
                          hints= {'virtualizable2': True,
@@ -69,6 +70,7 @@
     list_desc = cpu.fielddescrof(XY, 'inst_list')
     other_field_desc = cpu.fielddescrof(XY, 'inst_other_field')
     vdesc = VirtualizableDesc(cpu, XY, XY)
+    xy_vtable = lltype.malloc(OBJECT_VTABLE, immortal=True)
 
     namespace = locals()
 
@@ -102,6 +104,7 @@
     list_desc = cpu.fielddescrof(XY, 'olist')
     other_field_desc = cpu.fielddescrof(XY, 'oother_field')
     vdesc = VirtualizableDesc(cpu, XY, XY)
+    xy_vtable = ootype.runtimeClass(XY)
 
     namespace = locals()
 
@@ -151,7 +154,7 @@
     def test_basic_virtualizable(self):
         pre_op = """
         [p0]
-        guard_nonvirtualized(p0, vdesc=vdesc)
+        guard_nonvirtualized(p0, ConstClass(xy_vtable), vdesc=vdesc)
             fail()
         i1 = getfield_gc(p0, descr=field_desc)
         i2 = getfield_gc(p0, descr=field_desc)
@@ -168,7 +171,7 @@
     def test_virtualizable_setfield_rebuild_ops(self):
         pre_op = """
         [p0]
-        guard_nonvirtualized(p0, vdesc=vdesc)
+        guard_nonvirtualized(p0, ConstClass(xy_vtable), vdesc=vdesc)
             fail()
         i1 = getfield_gc(p0, descr=field_desc)
         i2 = getfield_gc(p0, descr=other_field_desc)
@@ -184,7 +187,8 @@
         i1 = getfield_gc(p0, descr=field_desc)
         i2 = getfield_gc(p0, descr=other_field_desc)
         guard_true(i2)
-            guard_nonvirtualized(p0)
+            guard_nonvirtualized(p0, ConstClass(xy_vtable))
+                fail()
             setfield_gc(p0, i2, descr=field_desc)
             fail()
         """
@@ -211,7 +215,7 @@
     def test_virtualized_list_on_virtualizable(self):
         pre_op = """
         [p0]
-        guard_nonvirtualized(p0, vdesc=vdesc)
+        guard_nonvirtualized(p0, ConstClass(xy_vtable), vdesc=vdesc)
             fail()
         p1 = getfield_gc(p0, descr=list_desc)
         setarrayitem_gc(p1, 0, 1, descr=array_descr)
@@ -235,7 +239,7 @@
     def test_virtualized_list_on_virtualizable_2(self):
         pre_op = """
         [p0, i0]
-        guard_nonvirtualized(p0, vdesc=vdesc)
+        guard_nonvirtualized(p0, ConstClass(xy_vtable), vdesc=vdesc)
             fail()
         p1 = getfield_gc(p0, descr=list_desc)
         setarrayitem_gc(p1, 0, i0, descr=array_descr)
@@ -252,7 +256,8 @@
         i2 = int_add(i0, i0)
         i3 = int_is_true(i2)
         guard_true(i3)
-            guard_nonvirtualized(p1)
+            guard_nonvirtualized(p1, None)
+                fail()
             setarrayitem_gc(p1, 0, i0, descr=array_descr)
             fail()
         """
@@ -262,7 +267,7 @@
     def test_virtualized_list_on_virtualizable_3(self):
         pre_op = """
         [p0, i0, i1]
-        guard_nonvirtualized(p0, vdesc=vdesc)
+        guard_nonvirtualized(p0, ConstClass(xy_vtable), vdesc=vdesc)
             fail()
         p1 = getfield_gc(p0, descr=list_desc)
         setarrayitem_gc(p1, 0, i0, descr=array_descr)
@@ -281,7 +286,8 @@
         i4 = int_add(i0, i1)
         i5 = int_is_true(i4)
         guard_true(i5)
-            guard_nonvirtualized(p1)
+            guard_nonvirtualized(p1, None)
+                fail()
             setarrayitem_gc(p1, 0, i1, descr=array_descr)
             fail()
         """
@@ -348,4 +354,5 @@
     pass
 
 class TestOOtype(OOtypeMixin, BaseTestOptimize2):
-    pass
+    def setup_class(cls):
+        py.test.skip("XXX")



More information about the Pypy-commit mailing list