[pypy-svn] r70333 - pypy/branch/virtual-forcing/pypy/jit/metainterp/test

arigo at codespeak.net arigo at codespeak.net
Tue Dec 29 11:20:41 CET 2009


Author: arigo
Date: Tue Dec 29 11:20:41 2009
New Revision: 70333

Modified:
   pypy/branch/virtual-forcing/pypy/jit/metainterp/test/test_optimizefindnode.py
   pypy/branch/virtual-forcing/pypy/jit/metainterp/test/test_optimizeopt.py
Log:
Finish fixing the tests.


Modified: pypy/branch/virtual-forcing/pypy/jit/metainterp/test/test_optimizefindnode.py
==============================================================================
--- pypy/branch/virtual-forcing/pypy/jit/metainterp/test/test_optimizefindnode.py	(original)
+++ pypy/branch/virtual-forcing/pypy/jit/metainterp/test/test_optimizefindnode.py	Tue Dec 29 11:20:41 2009
@@ -68,6 +68,12 @@
     nextdescr = cpu.fielddescrof(NODE, 'next')
     otherdescr = cpu.fielddescrof(NODE2, 'other')
 
+    NODEOBJ = lltype.GcStruct('NODEOBJ', ('parent', OBJECT),
+                                         ('ref', lltype.Ptr(OBJECT)))
+    nodeobj = lltype.malloc(NODEOBJ)
+    nodeobjvalue = lltype.cast_opaque_ptr(llmemory.GCREF, nodeobj)
+    refdescr = cpu.fielddescrof(NODEOBJ, 'ref')
+
     arraydescr = cpu.arraydescrof(lltype.GcArray(lltype.Signed))
     floatarraydescr = cpu.arraydescrof(lltype.GcArray(lltype.Float))
 
@@ -114,10 +120,14 @@
     virtualtokendescr = cpu.fielddescrof(JIT_VIRTUAL_REF, 'virtual_token')
     virtualrefindexdescr = cpu.fielddescrof(JIT_VIRTUAL_REF,'virtualref_index')
     virtualforceddescr = cpu.fielddescrof(JIT_VIRTUAL_REF, 'forced')
+    jvr_vtable_adr = llmemory.cast_ptr_to_adr(jit_virtual_ref_vtable)
 
-    cpu.class_sizes = {cpu.cast_adr_to_int(node_vtable_adr): cpu.sizeof(NODE),
-                      cpu.cast_adr_to_int(node_vtable_adr2): cpu.sizeof(NODE2),
-                       cpu.cast_adr_to_int(u_vtable_adr): cpu.sizeof(U)}
+    cpu.class_sizes = {
+        cpu.cast_adr_to_int(node_vtable_adr): cpu.sizeof(NODE),
+        cpu.cast_adr_to_int(node_vtable_adr2): cpu.sizeof(NODE2),
+        cpu.cast_adr_to_int(u_vtable_adr): cpu.sizeof(U),
+        cpu.cast_adr_to_int(jvr_vtable_adr): cpu.sizeof(JIT_VIRTUAL_REF),
+        }
     namespace = locals()
 
 class OOtypeMixin(object):

Modified: pypy/branch/virtual-forcing/pypy/jit/metainterp/test/test_optimizeopt.py
==============================================================================
--- pypy/branch/virtual-forcing/pypy/jit/metainterp/test/test_optimizeopt.py	(original)
+++ pypy/branch/virtual-forcing/pypy/jit/metainterp/test/test_optimizeopt.py	Tue Dec 29 11:20:41 2009
@@ -2381,19 +2381,30 @@
         setfield_gc(p0, p2, descr=nextdescr)
         call_may_force(i1, descr=mayforcevirtdescr)
         guard_not_forced() [i1]
+        virtual_ref_finish(p2, p1)
         setfield_gc(p0, NULL, descr=nextdescr)
         jump(p0, i1)
         """
         expected = """
         [p0, i1]
         i3 = force_token()
+        #
         p2 = new_with_vtable(ConstClass(jit_virtual_ref_vtable))
         setfield_gc(p2, i3, descr=virtualtokendescr)
         setfield_gc(p2, 3, descr=virtualrefindexdescr)
         setfield_gc(p0, p2, descr=nextdescr)
+        #
         call_may_force(i1, descr=mayforcevirtdescr)
         guard_not_forced() [i1]
         setfield_gc(p0, NULL, descr=nextdescr)
+        #
+        p1 = new_with_vtable(ConstClass(node_vtable))
+        p1b = new_with_vtable(ConstClass(node_vtable))
+        setfield_gc(p1b, 252, descr=valuedescr)
+        setfield_gc(p1, p1b, descr=nextdescr)
+        setfield_gc(p2, p1, descr=virtualforceddescr)
+        setfield_gc(p2, 0, descr=virtualtokendescr)
+        #
         jump(p0, i1)
         """
         self.optimize_loop(ops, 'Not, Not', expected)
@@ -2411,26 +2422,76 @@
         p2 = virtual_ref(p1, 2)
         setfield_gc(p0, p2, descr=nextdescr)
         call_may_force(i1, descr=mayforcevirtdescr)
-        guard_not_forced(descr=fdescr) [p1]
+        guard_not_forced(descr=fdescr) [p2, p1]
+        virtual_ref_finish(p2, p1)
         setfield_gc(p0, NULL, descr=nextdescr)
         jump(p0, i1)
         """
         expected = """
         [p0, i1]
         i3 = force_token()
+        #
         p2 = new_with_vtable(ConstClass(jit_virtual_ref_vtable))
         setfield_gc(p2, i3, descr=virtualtokendescr)
         setfield_gc(p2, 2, descr=virtualrefindexdescr)
         setfield_gc(p0, p2, descr=nextdescr)
+        #
         call_may_force(i1, descr=mayforcevirtdescr)
-        guard_not_forced(descr=fdescr) [i1]
+        guard_not_forced(descr=fdescr) [p2, i1]
         setfield_gc(p0, NULL, descr=nextdescr)
+        #
+        p1 = new_with_vtable(ConstClass(node_vtable))
+        p1b = new_with_vtable(ConstClass(node_vtable))
+        setfield_gc(p1b, i1, descr=valuedescr)
+        setfield_gc(p1, p1b, descr=nextdescr)
+        setfield_gc(p2, p1, descr=virtualforceddescr)
+        setfield_gc(p2, 0, descr=virtualtokendescr)
+        #
         jump(p0, i1)
         """
         # the point of this test is that 'i1' should show up in the fail_args
         # of 'guard_not_forced', because it was stored in the virtual 'p1b'.
         self.optimize_loop(ops, 'Not, Not', expected)
-        self.check_expanded_fail_descr('''p1
+        self.check_expanded_fail_descr('''p2, p1
+            where p1 is a node_vtable, nextdescr=p1b
+            where p1b is a node_vtable, valuedescr=i1
+            ''')
+
+    def test_vref_virtual_and_lazy_setfield(self):
+        self.make_fail_descr()
+        ops = """
+        [p0, i1]
+        #
+        p1 = new_with_vtable(ConstClass(node_vtable))
+        p1b = new_with_vtable(ConstClass(node_vtable))
+        setfield_gc(p1b, i1, descr=valuedescr)
+        setfield_gc(p1, p1b, descr=nextdescr)
+        #
+        p2 = virtual_ref(p1, 2)
+        setfield_gc(p0, p2, descr=refdescr)
+        call(i1, descr=nonwritedescr)
+        guard_no_exception(descr=fdescr) [p2, p1]
+        virtual_ref_finish(p2, p1)
+        setfield_gc(p0, NULL, descr=refdescr)
+        jump(p0, i1)
+        """
+        expected = """
+        [p0, i1]
+        i3 = force_token()
+        call(i1, descr=nonwritedescr)
+        guard_no_exception(descr=fdescr) [i3, i1, p0]
+        setfield_gc(p0, NULL, descr=refdescr)
+        jump(p0, i1)
+        """
+        self.optimize_loop(ops, 'Not, Not', expected)
+        # the fail_args contain [i3, i1, p0]:
+        #  - i3 is from the virtual expansion of p2
+        #  - i1 is from the virtual expansion of p1
+        #  - p0 is from the extra pendingfields
+        self.loop.inputargs[0].value = self.nodeobjvalue
+        self.check_expanded_fail_descr('''p2, p1
+            p0.refdescr = p2
+            where p2 is a jit_virtual_ref_vtable, virtualtokendescr=i3, virtualrefindexdescr=2
             where p1 is a node_vtable, nextdescr=p1b
             where p1b is a node_vtable, valuedescr=i1
             ''')



More information about the Pypy-commit mailing list