[pypy-svn] pypy jit-unroll-loops: New test of the blackholeinterp cache not relying on "continue tracing after fail compilation". Patched op_function lltypesystem/opimpl to accept AddressAsInt as int arguments.

hakanardo commits-noreply at bitbucket.org
Sun Jan 2 10:14:53 CET 2011


Author: Hakan Ardo <hakan at debian.org>
Branch: jit-unroll-loops
Changeset: r40312:080b96a0cf02
Date: 2011-01-02 10:12 +0100
http://bitbucket.org/pypy/pypy/changeset/080b96a0cf02/

Log:	New test of the blackholeinterp cache not relying on "continue
	tracing after fail compilation". Patched op_function
	lltypesystem/opimpl to accept AddressAsInt as int arguments.

diff --git a/pypy/jit/metainterp/optimizeopt/unroll.py b/pypy/jit/metainterp/optimizeopt/unroll.py
--- a/pypy/jit/metainterp/optimizeopt/unroll.py
+++ b/pypy/jit/metainterp/optimizeopt/unroll.py
@@ -5,6 +5,7 @@
 from pypy.jit.metainterp.history import TreeLoop, LoopToken
 from pypy.rlib.debug import debug_start, debug_stop, debug_print
 from pypy.jit.metainterp.optimizeutil import InvalidLoop, RetraceLoop
+from pypy.jit.metainterp.jitexc import JitException
 
 # FIXME: Introduce some VirtualOptimizer super class instead
 
@@ -367,7 +368,7 @@
             return
         self.heap_dirty = True
 
-class ImpossibleLink(Exception):
+class ImpossibleLink(JitException):
     pass
 
 class BoxMap(object):

diff --git a/pypy/rpython/lltypesystem/opimpl.py b/pypy/rpython/lltypesystem/opimpl.py
--- a/pypy/rpython/lltypesystem/opimpl.py
+++ b/pypy/rpython/lltypesystem/opimpl.py
@@ -19,6 +19,7 @@
 # global synonyms for some types
 from pypy.rlib.rarithmetic import intmask
 from pypy.rlib.rarithmetic import r_int, r_uint, r_longlong, r_ulonglong
+from pypy.rpython.lltypesystem.llmemory import AddressAsInt
 
 if r_longlong is r_int:
     r_longlong_arg = (r_longlong, int)
@@ -75,12 +76,14 @@
                 return adjust_result(func(x))
         else:
             def op_function(x, y):
-                if not isinstance(x, argtype):
-                    raise TypeError("%r arg 1 must be %s, got %r instead" % (
-                        fullopname, typname, type(x).__name__))
-                if not isinstance(y, argtype):
-                    raise TypeError("%r arg 2 must be %s, got %r instead" % (
-                        fullopname, typname, type(y).__name__))
+                if not (isinstance(x, AddressAsInt) and argtype is int):
+                    if not isinstance(x, argtype):
+                        raise TypeError("%r arg 1 must be %s, got %r instead" % (
+                            fullopname, typname, type(x).__name__))
+                if not (isinstance(y, AddressAsInt) and argtype is int):
+                    if not isinstance(y, argtype):
+                        raise TypeError("%r arg 2 must be %s, got %r instead" % (
+                            fullopname, typname, type(y).__name__))
                 return adjust_result(func(x, y))
 
     return func_with_new_name(op_function, 'op_' + fullopname)

diff --git a/pypy/jit/metainterp/test/test_blackhole.py b/pypy/jit/metainterp/test/test_blackhole.py
--- a/pypy/jit/metainterp/test/test_blackhole.py
+++ b/pypy/jit/metainterp/test/test_blackhole.py
@@ -145,6 +145,18 @@
 
 class TestBlackhole(LLJitMixin):
 
+    def test_blackholeinterp_cache_basic(self):
+        class FakeJitcode:
+            def num_regs_r(self):
+                return 0
+        interp1 = getblackholeinterp({})
+        interp1.jitcode = FakeJitcode()
+        builder = interp1.builder
+        interp2 = builder.acquire_interp()
+        builder.release_interp(interp1)
+        interp3 = builder.acquire_interp()
+        assert builder.num_interpreters == 2
+        
     def test_blackholeinterp_cache(self):
         myjitdriver = JitDriver(greens = [], reds = ['x', 'y'])
         def choices(x):
@@ -177,8 +189,8 @@
         #
         assert res == sum([choices(x) for x in range(1, 8)])
         builder = pyjitpl._warmrunnerdesc.metainterp_sd.blackholeinterpbuilder
-        assert builder.num_interpreters == 2
-        assert len(seen) == 2 * 3
+        assert builder.num_interpreters == 1
+        assert len(seen) == 1 * 3
 
     def test_blackholeinterp_cache_exc(self):
         myjitdriver = JitDriver(greens = [], reds = ['x', 'y'])
@@ -208,4 +220,4 @@
         assert res == sum([py.test.raises(FooError, choices, x).value.num
                            for x in range(1, 8)])
         builder = pyjitpl._warmrunnerdesc.metainterp_sd.blackholeinterpbuilder
-        assert builder.num_interpreters == 2
+        assert builder.num_interpreters == 1


More information about the Pypy-commit mailing list