[pypy-svn] r71510 - in pypy/trunk/pypy/jit/metainterp: . test

arigo at codespeak.net arigo at codespeak.net
Fri Feb 26 06:29:00 CET 2010


Author: arigo
Date: Fri Feb 26 06:28:58 2010
New Revision: 71510

Modified:
   pypy/trunk/pypy/jit/metainterp/pyjitpl.py
   pypy/trunk/pypy/jit/metainterp/test/test_virtualizable.py
   pypy/trunk/pypy/jit/metainterp/virtualizable.py
   pypy/trunk/pypy/jit/metainterp/warmstate.py
Log:
Merge branch/fix-blackhole-virt.

This removes 'globaldata.blackhole_virtualizable',
which is not thread- or recursion-safe.

This is mostly a revert of r67161, but the test that r67161 tried to fix
just works nowadays, because we are doing "the right thing" about
virtualizables (it is correctly in the state TOKEN_NONE when
blackholing).  So I think that the test really just passes, and it would
not fail in more complicated cases either.



Modified: pypy/trunk/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/pyjitpl.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/pyjitpl.py	Fri Feb 26 06:28:58 2010
@@ -611,23 +611,16 @@
             jitcode.calldescr is not None):
             # when producing only a BlackHole, we can implement this by
             # calling the subfunction directly instead of interpreting it
-            staticdata = self.metainterp.staticdata
-            globaldata = staticdata.globaldata
-            vi = staticdata.virtualizable_info
-            if vi:
-                globaldata.blackhole_virtualizable = vi.unwrap_virtualizable_box(self.metainterp.virtualizable_boxes[-1])
             if jitcode.cfnptr is not None:
                 # for non-oosends
                 varargs = [jitcode.cfnptr] + varargs
                 res = self.execute_varargs(rop.CALL, varargs,
                                              descr=jitcode.calldescr, exc=True)
-                self.metainterp.load_fields_from_virtualizable()
             else:
                 # for oosends (ootype only): calldescr is a MethDescr
                 res = self.execute_varargs(rop.OOSEND, varargs,
                                              descr=jitcode.calldescr, exc=True)
-            if vi:
-                globaldata.blackhole_virtualizable = vi.null_vable
+            self.metainterp.load_fields_from_virtualizable()
             return res
         else:
             # when tracing, this bytecode causes the subfunction to be entered
@@ -1250,6 +1243,18 @@
 # ____________________________________________________________
 
 class MetaInterpGlobalData(object):
+    """This object contains the JIT's global, mutable data.
+
+    Warning: for any data that you put here, think that there might be
+    multiple MetaInterps accessing it at the same time.  As usual we are
+    safe from corruption thanks to the GIL, but keep in mind that any
+    MetaInterp might modify any of these fields while another MetaInterp
+    is, say, currently in a residual call to a function.  Multiple
+    MetaInterps occur either with threads or, in single-threaded cases,
+    with recursion.  This is a case that is not well-tested, so please
+    be careful :-(  But thankfully this is one of the very few places
+    where multiple concurrent MetaInterps may interact with each other.
+    """
     def __init__(self, staticdata):
         self.initialized = False
         self.indirectcall_dict = None
@@ -1269,8 +1274,6 @@
                 greenkey = tuple(greenkey)
                 return _jitcell_dict.setdefault(greenkey, JitCell())
             self.jit_cell_at_key = jit_cell_at_key
-        if staticdata.virtualizable_info:
-            self.blackhole_virtualizable = staticdata.virtualizable_info.null_vable
 
     def get_compiled_merge_points(self, greenkey):
         cell = self.jit_cell_at_key(greenkey)

Modified: pypy/trunk/pypy/jit/metainterp/test/test_virtualizable.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/test/test_virtualizable.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/test/test_virtualizable.py	Fri Feb 26 06:28:58 2010
@@ -1193,8 +1193,6 @@
         self.check_loops(getfield_gc=0, setfield_gc=0)
 
     def test_blackhole_should_not_reenter(self):
-        # Armin thinks this can occur and does not make interpreters slower
-        # so we don't check for assertionerror, to be discussed
         if not self.basic:
             py.test.skip("purely frontend test")
 
@@ -1230,15 +1228,19 @@
             return somewhere_else.top_frame.y
 
         def main():
-            f(10, True)
-            f(10, True)
-            f(10, True)
-            f(10, True)
-            return f(10, False)
-
-        self.meta_interp(main, [])
-        #einfo = py.test.raises(AssertionError, self.meta_interp, main, [])
-        #assert einfo.value.args[0] == "reentering same frame via blackhole"
+            a = f(10, True)
+            b = f(10, True)
+            c = f(10, True)
+            d = f(10, True)
+            e = f(10, False)
+            return a + 17*b + 17*17*c + 17*17*17*d + 17*17*17*17*e
+
+        # the situation is: blackholing starts at the "if" above, then
+        # really calls jump_back(), which ends up calling
+        # can_enter_jit() for the same frame as the one we are currently
+        # blackholing.  It should just work fine, though.
+        res = self.meta_interp(main, [])
+        assert res == main()
 
     def test_inlining(self):
         class Frame(object):

Modified: pypy/trunk/pypy/jit/metainterp/virtualizable.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/virtualizable.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/virtualizable.py	Fri Feb 26 06:28:58 2010
@@ -33,7 +33,6 @@
             VTYPEPTR = cpu.ts.get_superclass(VTYPEPTR)
         self.VTYPEPTR = VTYPEPTR
         self.VTYPE = VTYPE = deref(VTYPEPTR)
-        self.null_vable = cpu.ts.nullptr(VTYPE)
         self.vable_token_descr = cpu.fielddescrof(VTYPE, 'vable_token')
         #
         accessor = VTYPE._hints['virtualizable2_accessor']

Modified: pypy/trunk/pypy/jit/metainterp/warmstate.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/warmstate.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/warmstate.py	Fri Feb 26 06:28:58 2010
@@ -212,8 +212,6 @@
             if vinfo is not None:
                 virtualizable = args[vinfo.index_of_virtualizable]
                 virtualizable = vinfo.cast_to_vtype(virtualizable)
-                if globaldata.blackhole_virtualizable == virtualizable:
-                    return
             else:
                 virtualizable = None
 



More information about the Pypy-commit mailing list