Author: Antonio Cuni <[email protected]>
Branch: invalidate-virtualrefs
Changeset: r44508:09933bd5c878
Date: 2011-05-26 14:21 +0200
http://bitbucket.org/pypy/pypy/changeset/09933bd5c878/

Log:    partially (and manually) revert 9ad031b5b63e, but keep the about
        replace_force_virtual_with_call

diff --git a/pypy/jit/metainterp/blackhole.py b/pypy/jit/metainterp/blackhole.py
--- a/pypy/jit/metainterp/blackhole.py
+++ b/pypy/jit/metainterp/blackhole.py
@@ -1183,14 +1183,6 @@
         from pypy.jit.metainterp import quasiimmut
         quasiimmut.do_force_quasi_immutable(cpu, struct, mutatefielddescr)
 
-    @arguments("cpu", "r")
-    def bhimpl_jit_invalidate_vref_maybe(cpu, struct):
-        # this op is rewritten into a call by metainter/virtualref.py, so we
-        # don't need an implementation.  This can only be called during tests
-        # by interp_operations, because the graphs are not rewritten in that
-        # case
-        assert not we_are_translated()
-
     @arguments("cpu", "d", returns="r")
     def bhimpl_new(cpu, descr):
         return cpu.bh_new(descr)
diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py
--- a/pypy/jit/metainterp/pyjitpl.py
+++ b/pypy/jit/metainterp/pyjitpl.py
@@ -584,14 +584,6 @@
             raise SwitchToBlackhole(ABORT_FORCE_QUASIIMMUT)
         self.generate_guard(rop.GUARD_ISNULL, mutatebox, resumepc=orgpc)
 
-    @arguments("box")
-    def opimpl_jit_invalidate_vref_maybe(self, box):
-        # this op is rewritten into a call by metainter/virtualref.py, so we
-        # don't need an implementation.  This can only be called during tests
-        # by interp_operations, because the graphs are not rewritten in that
-        # case
-        assert not we_are_translated()
-
     def _nonstandard_virtualizable(self, pc, box):
         # returns True if 'box' is actually not the "standard" virtualizable
         # that is stored in metainterp.virtualizable_boxes[-1]
diff --git a/pypy/jit/metainterp/test/test_virtualref.py 
b/pypy/jit/metainterp/test/test_virtualref.py
--- a/pypy/jit/metainterp/test/test_virtualref.py
+++ b/pypy/jit/metainterp/test/test_virtualref.py
@@ -23,22 +23,21 @@
             x = X()
             vref = virtual_ref(x)
             x1 = vref()                  # jit_force_virtual
-            virtual_ref_finish(vref, x)  # jit_invalidate_vref_maybe + call 
vref_finish
+            virtual_ref_finish(vref, x)
         #
         _get_jitcodes(self, self.CPUClass, fn, [], self.type_system)
         graph = self.all_graphs[0]
         assert graph.name == 'fn'
-        self.vrefinfo.rewrite_graphs([graph])
+        self.vrefinfo.replace_force_virtual_with_call([graph])
         #
         def check_call(op, fname):
             assert op.opname == 'direct_call'
-            assert op.args[0].value._obj._name.startswith(fname)
+            assert op.args[0].value._obj._name == fname
         #
         ops = [op for block, op in graph.iterblockops()]
-        check_call(ops[-4], 'virtual_ref')
-        check_call(ops[-3], 'force_virtual_if_necessary')
-        check_call(ops[-2], 'invalidate_vref_maybe')
-        check_call(ops[-1], 'll_virtual_ref_finish')
+        check_call(ops[-3], 'virtual_ref')
+        check_call(ops[-2], 'force_virtual_if_necessary')
+        check_call(ops[-1], 'virtual_ref_finish')
 
     def test_make_vref_simple(self):
         class X:
diff --git a/pypy/jit/metainterp/virtualref.py 
b/pypy/jit/metainterp/virtualref.py
--- a/pypy/jit/metainterp/virtualref.py
+++ b/pypy/jit/metainterp/virtualref.py
@@ -36,20 +36,13 @@
     def _freeze_(self):
         return True
 
-    def rewrite_graphs(self, graphs):
-        """
-        Replace jit_force_virtual and jit_invalidate_vref_maybe with
-        direct_calls to helpers
-        """
+    def replace_force_virtual_with_call(self, graphs):
         # similar to rvirtualizable2.replace_force_virtualizable_with_call().
         c_force_virtual_ptr = None
         force_virtual_count = 0
-        c_invalidate_vref_ptr = None
-        invalidate_vref_count = 0
         for graph in graphs:
             for block in graph.iterblocks():
                 for op in block.operations:
-                    # 
---------------------------------------------------------------
                     if op.opname == 'jit_force_virtual':
                         # first compute c_funcptr, but only if there is any
                         # 'jit_force_virtual' around
@@ -59,25 +52,10 @@
                         op.opname = 'direct_call'
                         op.args = [c_force_virtual_ptr, op.args[0]]
                         force_virtual_count += 1
-                    #
-                    # 
---------------------------------------------------------------
-                    if op.opname == 'jit_invalidate_vref_maybe':
-                        if c_invalidate_vref_ptr is None:
-                            c_invalidate_vref_ptr = 
self.get_invalidate_vref_fnptr()
-                        #
-                        op.opname = 'direct_call'
-                        op.args = [c_invalidate_vref_ptr, op.args[0]]
-                        invalidate_vref_count += 1
         #
         if c_force_virtual_ptr is not None:
-            log("replaced %d 'jit_force_virtual' with %r" % (
-                    force_virtual_count,
-                    c_force_virtual_ptr.value))
-        if c_invalidate_vref_ptr is not None:
-            log("replaced %d 'jit_invalidate_vref_maybe' with %r" % (
-                    invalidate_vref_count,
-                    c_invalidate_vref_ptr.value))
-
+            log("replaced %d 'jit_force_virtual' with %r" % 
(force_virtual_count,
+                                                             
c_force_virtual_ptr.value))
 
     # ____________________________________________________________
 
@@ -172,14 +150,3 @@
             assert vref.forced
         return vref.forced
     force_virtual._dont_inline_ = True
-
-    def get_invalidate_vref_fnptr(self):
-        #
-        def invalidate_vref_maybe(inst):
-            return
-        #
-        FUNC = lltype.FuncType([rclass.OBJECTPTR], lltype.Void)
-        funcptr = self.warmrunnerdesc.helper_func(
-            lltype.Ptr(FUNC),
-            invalidate_vref_maybe)
-        return inputconst(lltype.typeOf(funcptr), funcptr)
diff --git a/pypy/jit/metainterp/warmspot.py b/pypy/jit/metainterp/warmspot.py
--- a/pypy/jit/metainterp/warmspot.py
+++ b/pypy/jit/metainterp/warmspot.py
@@ -851,7 +851,7 @@
         if self.cpu.ts.name != 'lltype':
             py.test.skip("rewrite_force_virtual: port it to ootype")
         all_graphs = self.translator.graphs
-        vrefinfo.rewrite_graphs(all_graphs)
+        vrefinfo.replace_force_virtual_with_call(all_graphs)
 
     def replace_force_quasiimmut_with_direct_call(self, op):
         ARG = op.args[0].concretetype
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to