[pypy-svn] pypy default: Rename test_basic into test_ajit. Introduce support.py that contains JitMixin

fijal commits-noreply at bitbucket.org
Tue Apr 12 15:55:48 CEST 2011


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: 
Changeset: r43310:f38e5dab3fd4
Date: 2011-04-12 15:54 +0200
http://bitbucket.org/pypy/pypy/changeset/f38e5dab3fd4/

Log:	Rename test_basic into test_ajit. Introduce support.py that contains
	JitMixin (mwahahaha, evil laugh)

diff --git a/pypy/jit/metainterp/test/test_list.py b/pypy/jit/metainterp/test/test_list.py
--- a/pypy/jit/metainterp/test/test_list.py
+++ b/pypy/jit/metainterp/test/test_list.py
@@ -1,6 +1,6 @@
 import py
 from pypy.rlib.jit import JitDriver
-from pypy.jit.metainterp.test.test_basic import LLJitMixin, OOJitMixin
+from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
 
 
 class ListTests:

diff --git a/pypy/jit/metainterp/test/test_basic.py b/pypy/jit/metainterp/test/test_ajit.py
copy from pypy/jit/metainterp/test/test_basic.py
copy to pypy/jit/metainterp/test/test_ajit.py
--- a/pypy/jit/metainterp/test/test_basic.py
+++ b/pypy/jit/metainterp/test/test_ajit.py
@@ -4,269 +4,17 @@
 from pypy.rlib.jit import loop_invariant
 from pypy.rlib.jit import jit_debug, assert_green, AssertGreenFailed
 from pypy.rlib.jit import unroll_safe, current_trace_length
-from pypy.jit.metainterp.warmspot import ll_meta_interp, get_stats
-from pypy.jit.backend.llgraph import runner
 from pypy.jit.metainterp import pyjitpl, history
 from pypy.jit.metainterp.warmstate import set_future_value
+from pypy.jit.metainterp.warmspot import get_stats
 from pypy.jit.codewriter.policy import JitPolicy, StopAtXPolicy
-from pypy.jit.codewriter import longlong
 from pypy import conftest
 from pypy.rlib.rarithmetic import ovfcheck
 from pypy.jit.metainterp.typesystem import LLTypeHelper, OOTypeHelper
 from pypy.rpython.lltypesystem import lltype, llmemory
 from pypy.rpython.ootypesystem import ootype
 from pypy.jit.metainterp.optimizeopt import ALL_OPTS_DICT
-
-def _get_jitcodes(testself, CPUClass, func, values, type_system,
-                  supports_longlong=False, **kwds):
-    from pypy.jit.codewriter import support, codewriter
-
-    class FakeJitCell:
-        __compiled_merge_points = []
-        def get_compiled_merge_points(self):
-            return self.__compiled_merge_points[:]
-        def set_compiled_merge_points(self, lst):
-            self.__compiled_merge_points = lst
-
-    class FakeWarmRunnerState:
-        def attach_unoptimized_bridge_from_interp(self, greenkey, newloop):
-            pass
-
-        def jit_cell_at_key(self, greenkey):
-            assert greenkey == []
-            return self._cell
-        _cell = FakeJitCell()
-
-        trace_limit = sys.maxint
-        enable_opts = ALL_OPTS_DICT
-
-    func._jit_unroll_safe_ = True
-    rtyper = support.annotate(func, values, type_system=type_system)
-    graphs = rtyper.annotator.translator.graphs
-    result_kind = history.getkind(graphs[0].getreturnvar().concretetype)[0]
-
-    class FakeJitDriverSD:
-        num_green_args = 0
-        portal_graph = graphs[0]
-        virtualizable_info = None
-        greenfield_info = None
-        result_type = result_kind
-        portal_runner_ptr = "???"
-
-    stats = history.Stats()
-    cpu = CPUClass(rtyper, stats, None, False)
-    cw = codewriter.CodeWriter(cpu, [FakeJitDriverSD()])
-    testself.cw = cw
-    policy = JitPolicy()
-    policy.set_supports_longlong(supports_longlong)
-    cw.find_all_graphs(policy)
-    #
-    testself.warmrunnerstate = FakeWarmRunnerState()
-    testself.warmrunnerstate.cpu = cpu
-    FakeJitDriverSD.warmstate = testself.warmrunnerstate
-    if hasattr(testself, 'finish_setup_for_interp_operations'):
-        testself.finish_setup_for_interp_operations()
-    #
-    cw.make_jitcodes(verbose=True)
-
-def _run_with_blackhole(testself, args):
-    from pypy.jit.metainterp.blackhole import BlackholeInterpBuilder
-    cw = testself.cw
-    blackholeinterpbuilder = BlackholeInterpBuilder(cw)
-    blackholeinterp = blackholeinterpbuilder.acquire_interp()
-    count_i = count_r = count_f = 0
-    for value in args:
-        T = lltype.typeOf(value)
-        if T == lltype.Signed:
-            blackholeinterp.setarg_i(count_i, value)
-            count_i += 1
-        elif T == llmemory.GCREF:
-            blackholeinterp.setarg_r(count_r, value)
-            count_r += 1
-        elif T == lltype.Float:
-            value = longlong.getfloatstorage(value)
-            blackholeinterp.setarg_f(count_f, value)
-            count_f += 1
-        else:
-            raise TypeError(T)
-    [jitdriver_sd] = cw.callcontrol.jitdrivers_sd
-    blackholeinterp.setposition(jitdriver_sd.mainjitcode, 0)
-    blackholeinterp.run()
-    return blackholeinterp._final_result_anytype()
-
-def _run_with_pyjitpl(testself, args):
-
-    class DoneWithThisFrame(Exception):
-        pass
-
-    class DoneWithThisFrameRef(DoneWithThisFrame):
-        def __init__(self, cpu, *args):
-            DoneWithThisFrame.__init__(self, *args)
-
-    cw = testself.cw
-    opt = history.Options(listops=True)
-    metainterp_sd = pyjitpl.MetaInterpStaticData(cw.cpu, opt)
-    metainterp_sd.finish_setup(cw)
-    [jitdriver_sd] = metainterp_sd.jitdrivers_sd
-    metainterp = pyjitpl.MetaInterp(metainterp_sd, jitdriver_sd)
-    metainterp_sd.DoneWithThisFrameInt = DoneWithThisFrame
-    metainterp_sd.DoneWithThisFrameRef = DoneWithThisFrameRef
-    metainterp_sd.DoneWithThisFrameFloat = DoneWithThisFrame
-    testself.metainterp = metainterp
-    try:
-        metainterp.compile_and_run_once(jitdriver_sd, *args)
-    except DoneWithThisFrame, e:
-        #if conftest.option.view:
-        #    metainterp.stats.view()
-        return e.args[0]
-    else:
-        raise Exception("FAILED")
-
-def _run_with_machine_code(testself, args):
-    metainterp = testself.metainterp
-    num_green_args = metainterp.jitdriver_sd.num_green_args
-    loop_tokens = metainterp.get_compiled_merge_points(args[:num_green_args])
-    if len(loop_tokens) != 1:
-        return NotImplemented
-    # a loop was successfully created by _run_with_pyjitpl(); call it
-    cpu = metainterp.cpu
-    for i in range(len(args) - num_green_args):
-        x = args[num_green_args + i]
-        typecode = history.getkind(lltype.typeOf(x))
-        set_future_value(cpu, i, x, typecode)
-    faildescr = cpu.execute_token(loop_tokens[0])
-    assert faildescr.__class__.__name__.startswith('DoneWithThisFrameDescr')
-    if metainterp.jitdriver_sd.result_type == history.INT:
-        return cpu.get_latest_value_int(0)
-    elif metainterp.jitdriver_sd.result_type == history.REF:
-        return cpu.get_latest_value_ref(0)
-    elif metainterp.jitdriver_sd.result_type == history.FLOAT:
-        return cpu.get_latest_value_float(0)
-    else:
-        return None
-
-
-class JitMixin:
-    basic = True
-    def check_loops(self, expected=None, everywhere=False, **check):
-        get_stats().check_loops(expected=expected, everywhere=everywhere,
-                                **check)
-    def check_loop_count(self, count):
-        """NB. This is a hack; use check_tree_loop_count() or
-        check_enter_count() for the real thing.
-        This counts as 1 every bridge in addition to every loop; and it does
-        not count at all the entry bridges from interpreter, although they
-        are TreeLoops as well."""
-        assert get_stats().compiled_count == count
-    def check_tree_loop_count(self, count):
-        assert len(get_stats().loops) == count
-    def check_loop_count_at_most(self, count):
-        assert get_stats().compiled_count <= count
-    def check_enter_count(self, count):
-        assert get_stats().enter_count == count
-    def check_enter_count_at_most(self, count):
-        assert get_stats().enter_count <= count
-    def check_jumps(self, maxcount):
-        assert get_stats().exec_jumps <= maxcount
-    def check_aborted_count(self, count):
-        assert get_stats().aborted_count == count
-    def check_aborted_count_at_least(self, count):
-        assert get_stats().aborted_count >= count
-
-    def meta_interp(self, *args, **kwds):
-        kwds['CPUClass'] = self.CPUClass
-        kwds['type_system'] = self.type_system
-        if "backendopt" not in kwds:
-            kwds["backendopt"] = False
-        return ll_meta_interp(*args, **kwds)
-
-    def interp_operations(self, f, args, **kwds):
-        # get the JitCodes for the function f
-        _get_jitcodes(self, self.CPUClass, f, args, self.type_system, **kwds)
-        # try to run it with blackhole.py
-        result1 = _run_with_blackhole(self, args)
-        # try to run it with pyjitpl.py
-        result2 = _run_with_pyjitpl(self, args)
-        assert result1 == result2
-        # try to run it by running the code compiled just before
-        result3 = _run_with_machine_code(self, args)
-        assert result1 == result3 or result3 == NotImplemented
-        #
-        if (longlong.supports_longlong and
-            isinstance(result1, longlong.r_float_storage)):
-            result1 = longlong.getrealfloat(result1)
-        return result1
-
-    def check_history(self, expected=None, **isns):
-        # this can be used after calling meta_interp
-        get_stats().check_history(expected, **isns)
-
-    def check_operations_history(self, expected=None, **isns):
-        # this can be used after interp_operations
-        if expected is not None:
-            expected = dict(expected)
-            expected['jump'] = 1
-        self.metainterp.staticdata.stats.check_history(expected, **isns)
-
-
-class LLJitMixin(JitMixin):
-    type_system = 'lltype'
-    CPUClass = runner.LLtypeCPU
-
-    @staticmethod
-    def Ptr(T):
-        return lltype.Ptr(T)
-
-    @staticmethod
-    def GcStruct(name, *fields, **kwds):
-        S = lltype.GcStruct(name, *fields, **kwds)
-        return S
-
-    malloc = staticmethod(lltype.malloc)
-    nullptr = staticmethod(lltype.nullptr)
-
-    @staticmethod
-    def malloc_immortal(T):
-        return lltype.malloc(T, immortal=True)
-
-    def _get_NODE(self):
-        NODE = lltype.GcForwardReference()
-        NODE.become(lltype.GcStruct('NODE', ('value', lltype.Signed),
-                                            ('next', lltype.Ptr(NODE))))
-        return NODE
-    
-class OOJitMixin(JitMixin):
-    type_system = 'ootype'
-    #CPUClass = runner.OOtypeCPU
-
-    def setup_class(cls):
-        py.test.skip("ootype tests skipped for now")
-
-    @staticmethod
-    def Ptr(T):
-        return T
-
-    @staticmethod
-    def GcStruct(name, *fields, **kwds):
-        if 'hints' in kwds:
-            kwds['_hints'] = kwds['hints']
-            del kwds['hints']
-        I = ootype.Instance(name, ootype.ROOT, dict(fields), **kwds)
-        return I
-
-    malloc = staticmethod(ootype.new)
-    nullptr = staticmethod(ootype.null)
-
-    @staticmethod
-    def malloc_immortal(T):
-        return ootype.new(T)
-
-    def _get_NODE(self):
-        NODE = ootype.Instance('NODE', ootype.ROOT, {})
-        NODE._add_fields({'value': ootype.Signed,
-                          'next': NODE})
-        return NODE
-
+from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
 
 class BasicTests:    
 

diff --git a/pypy/jit/metainterp/test/test_virtualizable.py b/pypy/jit/metainterp/test/test_virtualizable.py
--- a/pypy/jit/metainterp/test/test_virtualizable.py
+++ b/pypy/jit/metainterp/test/test_virtualizable.py
@@ -6,7 +6,7 @@
 from pypy.jit.codewriter import heaptracker
 from pypy.rlib.jit import JitDriver, hint, dont_look_inside
 from pypy.rlib.rarithmetic import intmask
-from pypy.jit.metainterp.test.test_basic import LLJitMixin, OOJitMixin
+from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
 from pypy.rpython.rclass import FieldListAccessor
 from pypy.jit.metainterp.warmspot import get_stats, get_translator
 from pypy.jit.metainterp import history

diff --git a/pypy/jit/metainterp/test/test_longlong.py b/pypy/jit/metainterp/test/test_longlong.py
--- a/pypy/jit/metainterp/test/test_longlong.py
+++ b/pypy/jit/metainterp/test/test_longlong.py
@@ -1,6 +1,6 @@
 import py, sys
 from pypy.rlib.rarithmetic import r_longlong, r_ulonglong, r_uint, intmask
-from pypy.jit.metainterp.test.test_basic import LLJitMixin
+from pypy.jit.metainterp.test.support import LLJitMixin
 
 class WrongResult(Exception):
     pass

diff --git a/pypy/jit/metainterp/test/test_jitdriver.py b/pypy/jit/metainterp/test/test_jitdriver.py
--- a/pypy/jit/metainterp/test/test_jitdriver.py
+++ b/pypy/jit/metainterp/test/test_jitdriver.py
@@ -1,6 +1,6 @@
 """Tests for multiple JitDrivers."""
 from pypy.rlib.jit import JitDriver, unroll_safe
-from pypy.jit.metainterp.test.test_basic import LLJitMixin, OOJitMixin
+from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
 from pypy.jit.metainterp.warmspot import get_stats
 
 

diff --git a/pypy/jit/metainterp/test/test_basic.py b/pypy/jit/metainterp/test/test_basic.py
deleted file mode 100644
--- a/pypy/jit/metainterp/test/test_basic.py
+++ /dev/null
@@ -1,2411 +0,0 @@
-import py
-import sys
-from pypy.rlib.jit import JitDriver, we_are_jitted, hint, dont_look_inside
-from pypy.rlib.jit import loop_invariant
-from pypy.rlib.jit import jit_debug, assert_green, AssertGreenFailed
-from pypy.rlib.jit import unroll_safe, current_trace_length
-from pypy.jit.metainterp.warmspot import ll_meta_interp, get_stats
-from pypy.jit.backend.llgraph import runner
-from pypy.jit.metainterp import pyjitpl, history
-from pypy.jit.metainterp.warmstate import set_future_value
-from pypy.jit.codewriter.policy import JitPolicy, StopAtXPolicy
-from pypy.jit.codewriter import longlong
-from pypy import conftest
-from pypy.rlib.rarithmetic import ovfcheck
-from pypy.jit.metainterp.typesystem import LLTypeHelper, OOTypeHelper
-from pypy.rpython.lltypesystem import lltype, llmemory
-from pypy.rpython.ootypesystem import ootype
-from pypy.jit.metainterp.optimizeopt import ALL_OPTS_DICT
-
-def _get_jitcodes(testself, CPUClass, func, values, type_system,
-                  supports_longlong=False, **kwds):
-    from pypy.jit.codewriter import support, codewriter
-
-    class FakeJitCell:
-        __compiled_merge_points = []
-        def get_compiled_merge_points(self):
-            return self.__compiled_merge_points[:]
-        def set_compiled_merge_points(self, lst):
-            self.__compiled_merge_points = lst
-
-    class FakeWarmRunnerState:
-        def attach_unoptimized_bridge_from_interp(self, greenkey, newloop):
-            pass
-
-        def jit_cell_at_key(self, greenkey):
-            assert greenkey == []
-            return self._cell
-        _cell = FakeJitCell()
-
-        trace_limit = sys.maxint
-        enable_opts = ALL_OPTS_DICT
-
-    func._jit_unroll_safe_ = True
-    rtyper = support.annotate(func, values, type_system=type_system)
-    graphs = rtyper.annotator.translator.graphs
-    result_kind = history.getkind(graphs[0].getreturnvar().concretetype)[0]
-
-    class FakeJitDriverSD:
-        num_green_args = 0
-        portal_graph = graphs[0]
-        virtualizable_info = None
-        greenfield_info = None
-        result_type = result_kind
-        portal_runner_ptr = "???"
-
-    stats = history.Stats()
-    cpu = CPUClass(rtyper, stats, None, False)
-    cw = codewriter.CodeWriter(cpu, [FakeJitDriverSD()])
-    testself.cw = cw
-    policy = JitPolicy()
-    policy.set_supports_longlong(supports_longlong)
-    cw.find_all_graphs(policy)
-    #
-    testself.warmrunnerstate = FakeWarmRunnerState()
-    testself.warmrunnerstate.cpu = cpu
-    FakeJitDriverSD.warmstate = testself.warmrunnerstate
-    if hasattr(testself, 'finish_setup_for_interp_operations'):
-        testself.finish_setup_for_interp_operations()
-    #
-    cw.make_jitcodes(verbose=True)
-
-def _run_with_blackhole(testself, args):
-    from pypy.jit.metainterp.blackhole import BlackholeInterpBuilder
-    cw = testself.cw
-    blackholeinterpbuilder = BlackholeInterpBuilder(cw)
-    blackholeinterp = blackholeinterpbuilder.acquire_interp()
-    count_i = count_r = count_f = 0
-    for value in args:
-        T = lltype.typeOf(value)
-        if T == lltype.Signed:
-            blackholeinterp.setarg_i(count_i, value)
-            count_i += 1
-        elif T == llmemory.GCREF:
-            blackholeinterp.setarg_r(count_r, value)
-            count_r += 1
-        elif T == lltype.Float:
-            value = longlong.getfloatstorage(value)
-            blackholeinterp.setarg_f(count_f, value)
-            count_f += 1
-        else:
-            raise TypeError(T)
-    [jitdriver_sd] = cw.callcontrol.jitdrivers_sd
-    blackholeinterp.setposition(jitdriver_sd.mainjitcode, 0)
-    blackholeinterp.run()
-    return blackholeinterp._final_result_anytype()
-
-def _run_with_pyjitpl(testself, args):
-
-    class DoneWithThisFrame(Exception):
-        pass
-
-    class DoneWithThisFrameRef(DoneWithThisFrame):
-        def __init__(self, cpu, *args):
-            DoneWithThisFrame.__init__(self, *args)
-
-    cw = testself.cw
-    opt = history.Options(listops=True)
-    metainterp_sd = pyjitpl.MetaInterpStaticData(cw.cpu, opt)
-    metainterp_sd.finish_setup(cw)
-    [jitdriver_sd] = metainterp_sd.jitdrivers_sd
-    metainterp = pyjitpl.MetaInterp(metainterp_sd, jitdriver_sd)
-    metainterp_sd.DoneWithThisFrameInt = DoneWithThisFrame
-    metainterp_sd.DoneWithThisFrameRef = DoneWithThisFrameRef
-    metainterp_sd.DoneWithThisFrameFloat = DoneWithThisFrame
-    testself.metainterp = metainterp
-    try:
-        metainterp.compile_and_run_once(jitdriver_sd, *args)
-    except DoneWithThisFrame, e:
-        #if conftest.option.view:
-        #    metainterp.stats.view()
-        return e.args[0]
-    else:
-        raise Exception("FAILED")
-
-def _run_with_machine_code(testself, args):
-    metainterp = testself.metainterp
-    num_green_args = metainterp.jitdriver_sd.num_green_args
-    loop_tokens = metainterp.get_compiled_merge_points(args[:num_green_args])
-    if len(loop_tokens) != 1:
-        return NotImplemented
-    # a loop was successfully created by _run_with_pyjitpl(); call it
-    cpu = metainterp.cpu
-    for i in range(len(args) - num_green_args):
-        x = args[num_green_args + i]
-        typecode = history.getkind(lltype.typeOf(x))
-        set_future_value(cpu, i, x, typecode)
-    faildescr = cpu.execute_token(loop_tokens[0])
-    assert faildescr.__class__.__name__.startswith('DoneWithThisFrameDescr')
-    if metainterp.jitdriver_sd.result_type == history.INT:
-        return cpu.get_latest_value_int(0)
-    elif metainterp.jitdriver_sd.result_type == history.REF:
-        return cpu.get_latest_value_ref(0)
-    elif metainterp.jitdriver_sd.result_type == history.FLOAT:
-        return cpu.get_latest_value_float(0)
-    else:
-        return None
-
-
-class JitMixin:
-    basic = True
-    def check_loops(self, expected=None, everywhere=False, **check):
-        get_stats().check_loops(expected=expected, everywhere=everywhere,
-                                **check)
-    def check_loop_count(self, count):
-        """NB. This is a hack; use check_tree_loop_count() or
-        check_enter_count() for the real thing.
-        This counts as 1 every bridge in addition to every loop; and it does
-        not count at all the entry bridges from interpreter, although they
-        are TreeLoops as well."""
-        assert get_stats().compiled_count == count
-    def check_tree_loop_count(self, count):
-        assert len(get_stats().loops) == count
-    def check_loop_count_at_most(self, count):
-        assert get_stats().compiled_count <= count
-    def check_enter_count(self, count):
-        assert get_stats().enter_count == count
-    def check_enter_count_at_most(self, count):
-        assert get_stats().enter_count <= count
-    def check_jumps(self, maxcount):
-        assert get_stats().exec_jumps <= maxcount
-    def check_aborted_count(self, count):
-        assert get_stats().aborted_count == count
-    def check_aborted_count_at_least(self, count):
-        assert get_stats().aborted_count >= count
-
-    def meta_interp(self, *args, **kwds):
-        kwds['CPUClass'] = self.CPUClass
-        kwds['type_system'] = self.type_system
-        if "backendopt" not in kwds:
-            kwds["backendopt"] = False
-        return ll_meta_interp(*args, **kwds)
-
-    def interp_operations(self, f, args, **kwds):
-        # get the JitCodes for the function f
-        _get_jitcodes(self, self.CPUClass, f, args, self.type_system, **kwds)
-        # try to run it with blackhole.py
-        result1 = _run_with_blackhole(self, args)
-        # try to run it with pyjitpl.py
-        result2 = _run_with_pyjitpl(self, args)
-        assert result1 == result2
-        # try to run it by running the code compiled just before
-        result3 = _run_with_machine_code(self, args)
-        assert result1 == result3 or result3 == NotImplemented
-        #
-        if (longlong.supports_longlong and
-            isinstance(result1, longlong.r_float_storage)):
-            result1 = longlong.getrealfloat(result1)
-        return result1
-
-    def check_history(self, expected=None, **isns):
-        # this can be used after calling meta_interp
-        get_stats().check_history(expected, **isns)
-
-    def check_operations_history(self, expected=None, **isns):
-        # this can be used after interp_operations
-        if expected is not None:
-            expected = dict(expected)
-            expected['jump'] = 1
-        self.metainterp.staticdata.stats.check_history(expected, **isns)
-
-
-class LLJitMixin(JitMixin):
-    type_system = 'lltype'
-    CPUClass = runner.LLtypeCPU
-
-    @staticmethod
-    def Ptr(T):
-        return lltype.Ptr(T)
-
-    @staticmethod
-    def GcStruct(name, *fields, **kwds):
-        S = lltype.GcStruct(name, *fields, **kwds)
-        return S
-
-    malloc = staticmethod(lltype.malloc)
-    nullptr = staticmethod(lltype.nullptr)
-
-    @staticmethod
-    def malloc_immortal(T):
-        return lltype.malloc(T, immortal=True)
-
-    def _get_NODE(self):
-        NODE = lltype.GcForwardReference()
-        NODE.become(lltype.GcStruct('NODE', ('value', lltype.Signed),
-                                            ('next', lltype.Ptr(NODE))))
-        return NODE
-    
-class OOJitMixin(JitMixin):
-    type_system = 'ootype'
-    #CPUClass = runner.OOtypeCPU
-
-    def setup_class(cls):
-        py.test.skip("ootype tests skipped for now")
-
-    @staticmethod
-    def Ptr(T):
-        return T
-
-    @staticmethod
-    def GcStruct(name, *fields, **kwds):
-        if 'hints' in kwds:
-            kwds['_hints'] = kwds['hints']
-            del kwds['hints']
-        I = ootype.Instance(name, ootype.ROOT, dict(fields), **kwds)
-        return I
-
-    malloc = staticmethod(ootype.new)
-    nullptr = staticmethod(ootype.null)
-
-    @staticmethod
-    def malloc_immortal(T):
-        return ootype.new(T)
-
-    def _get_NODE(self):
-        NODE = ootype.Instance('NODE', ootype.ROOT, {})
-        NODE._add_fields({'value': ootype.Signed,
-                          'next': NODE})
-        return NODE
-
-
-class BasicTests:    
-
-    def test_basic(self):
-        def f(x, y):
-            return x + y
-        res = self.interp_operations(f, [40, 2])
-        assert res == 42
-
-    def test_basic_inst(self):
-        class A:
-            pass
-        def f(n):
-            a = A()
-            a.x = n
-            return a.x
-        res = self.interp_operations(f, [42])
-        assert res == 42
-
-    def test_uint_floordiv(self):
-        from pypy.rlib.rarithmetic import r_uint
-        
-        def f(a, b):
-            a = r_uint(a)
-            b = r_uint(b)
-            return a/b
-
-        res = self.interp_operations(f, [-4, 3])
-        assert res == long(r_uint(-4)) // 3
-
-    def test_direct_call(self):
-        def g(n):
-            return n + 2
-        def f(a, b):
-            return g(a) + g(b)
-        res = self.interp_operations(f, [8, 98])
-        assert res == 110
-
-    def test_direct_call_with_guard(self):
-        def g(n):
-            if n < 0:
-                return 0
-            return n + 2
-        def f(a, b):
-            return g(a) + g(b)
-        res = self.interp_operations(f, [8, 98])
-        assert res == 110
-
-    def test_loop(self):
-        myjitdriver = JitDriver(greens = [], reds = ['x', 'y', 'res'])
-        def f(x, y):
-            res = 0
-            while y > 0:
-                myjitdriver.can_enter_jit(x=x, y=y, res=res)
-                myjitdriver.jit_merge_point(x=x, y=y, res=res)
-                res += x
-                y -= 1
-            return res
-        res = self.meta_interp(f, [6, 7])
-        assert res == 42
-        self.check_loop_count(1)
-        self.check_loops({'guard_true': 1,
-                          'int_add': 1, 'int_sub': 1, 'int_gt': 1,
-                          'jump': 1})
-        if self.basic:
-            found = 0
-            for op in get_stats().loops[0]._all_operations():
-                if op.getopname() == 'guard_true':
-                    liveboxes = op.getfailargs()
-                    assert len(liveboxes) == 3
-                    for box in liveboxes:
-                        assert isinstance(box, history.BoxInt)
-                    found += 1
-            assert found == 1
-
-    def test_loop_invariant_mul1(self):
-        myjitdriver = JitDriver(greens = [], reds = ['y', 'res', 'x'])
-        def f(x, y):
-            res = 0
-            while y > 0:
-                myjitdriver.can_enter_jit(x=x, y=y, res=res)
-                myjitdriver.jit_merge_point(x=x, y=y, res=res)
-                res += x * x
-                y -= 1
-            return res
-        res = self.meta_interp(f, [6, 7])
-        assert res == 252
-        self.check_loop_count(1)
-        self.check_loops({'guard_true': 1,
-                          'int_add': 1, 'int_sub': 1, 'int_gt': 1,
-                          'jump': 1})
-
-    def test_loop_invariant_mul_ovf(self):
-        myjitdriver = JitDriver(greens = [], reds = ['y', 'res', 'x'])
-        def f(x, y):
-            res = 0
-            while y > 0:
-                myjitdriver.can_enter_jit(x=x, y=y, res=res)
-                myjitdriver.jit_merge_point(x=x, y=y, res=res)
-                b = y * 2
-                res += ovfcheck(x * x) + b
-                y -= 1
-            return res
-        res = self.meta_interp(f, [6, 7])
-        assert res == 308
-        self.check_loop_count(1)
-        self.check_loops({'guard_true': 1,
-                          'int_add': 2, 'int_sub': 1, 'int_gt': 1,
-                          'int_lshift': 1,
-                          'jump': 1})
-
-    def test_loop_invariant_mul_bridge1(self):
-        myjitdriver = JitDriver(greens = [], reds = ['y', 'res', 'x'])
-        def f(x, y):
-            res = 0
-            while y > 0:
-                myjitdriver.can_enter_jit(x=x, y=y, res=res)
-                myjitdriver.jit_merge_point(x=x, y=y, res=res)
-                res += x * x
-                if y<16:
-                    x += 1
-                y -= 1
-            return res
-        res = self.meta_interp(f, [6, 32])
-        assert res == 3427
-        self.check_loop_count(3)
-
-    def test_loop_invariant_mul_bridge_maintaining1(self):
-        myjitdriver = JitDriver(greens = [], reds = ['y', 'res', 'x'])
-        def f(x, y):
-            res = 0
-            while y > 0:
-                myjitdriver.can_enter_jit(x=x, y=y, res=res)
-                myjitdriver.jit_merge_point(x=x, y=y, res=res)
-                res += x * x
-                if y<16:
-                    res += 1
-                y -= 1
-            return res
-        res = self.meta_interp(f, [6, 32])
-        assert res == 1167
-        self.check_loop_count(3)
-        self.check_loops({'int_add': 3, 'int_lt': 2,
-                          'int_sub': 2, 'guard_false': 1,
-                          'jump': 2,
-                          'int_gt': 1, 'guard_true': 2})
-
-
-    def test_loop_invariant_mul_bridge_maintaining2(self):
-        myjitdriver = JitDriver(greens = [], reds = ['y', 'res', 'x'])
-        def f(x, y):
-            res = 0
-            while y > 0:
-                myjitdriver.can_enter_jit(x=x, y=y, res=res)
-                myjitdriver.jit_merge_point(x=x, y=y, res=res)
-                z = x * x
-                res += z
-                if y<16:
-                    res += z
-                y -= 1
-            return res
-        res = self.meta_interp(f, [6, 32])
-        assert res == 1692
-        self.check_loop_count(3)
-        self.check_loops({'int_add': 3, 'int_lt': 2,
-                          'int_sub': 2, 'guard_false': 1,
-                          'jump': 2,
-                          'int_gt': 1, 'guard_true': 2})
-
-    def test_loop_invariant_mul_bridge_maintaining3(self):
-        myjitdriver = JitDriver(greens = [], reds = ['y', 'res', 'x', 'm'])
-        def f(x, y, m):
-            res = 0
-            while y > 0:
-                myjitdriver.can_enter_jit(x=x, y=y, res=res, m=m)
-                myjitdriver.jit_merge_point(x=x, y=y, res=res, m=m)
-                z = x * x
-                res += z
-                if y<m:
-                    res += z
-                y -= 1
-            return res
-        res = self.meta_interp(f, [6, 32, 16])
-        assert res == 1692
-        self.check_loop_count(3)
-        self.check_loops({'int_add': 2, 'int_lt': 1,
-                          'int_sub': 2, 'guard_false': 1,
-                          'jump': 2, 'int_mul': 1,
-                          'int_gt': 2, 'guard_true': 2})
-
-    def test_loop_invariant_intbox(self):
-        myjitdriver = JitDriver(greens = [], reds = ['y', 'res', 'x'])
-        class I:
-            __slots__ = 'intval'
-            _immutable_ = True
-            def __init__(self, intval):
-                self.intval = intval
-        def f(i, y):
-            res = 0
-            x = I(i)
-            while y > 0:
-                myjitdriver.can_enter_jit(x=x, y=y, res=res)
-                myjitdriver.jit_merge_point(x=x, y=y, res=res)
-                res += x.intval * x.intval
-                y -= 1
-            return res
-        res = self.meta_interp(f, [6, 7])
-        assert res == 252
-        self.check_loop_count(1)
-        self.check_loops({'guard_true': 1,
-                          'int_add': 1, 'int_sub': 1, 'int_gt': 1,
-                          'jump': 1})
-
-    def test_loops_are_transient(self):
-        import gc, weakref
-        myjitdriver = JitDriver(greens = [], reds = ['x', 'y', 'res'])
-        def f(x, y):
-            res = 0
-            while y > 0:
-                myjitdriver.can_enter_jit(x=x, y=y, res=res)
-                myjitdriver.jit_merge_point(x=x, y=y, res=res)
-                res += x
-                if y%2:
-                    res *= 2
-                y -= 1
-            return res
-        wr_loops = []
-        old_init = history.TreeLoop.__init__.im_func
-        try:
-            def track_init(self, name):
-                old_init(self, name)
-                wr_loops.append(weakref.ref(self))
-            history.TreeLoop.__init__ = track_init
-            res = self.meta_interp(f, [6, 15], no_stats=True)
-        finally:
-            history.TreeLoop.__init__ = old_init
-            
-        assert res == f(6, 15)
-        gc.collect()
-
-        #assert not [wr for wr in wr_loops if wr()]
-        for loop in [wr for wr in wr_loops if wr()]:
-            assert loop().name == 'short preamble'
-
-    def test_string(self):
-        def f(n):
-            bytecode = 'adlfkj' + chr(n)
-            if n < len(bytecode):
-                return bytecode[n]
-            else:
-                return "?"
-        res = self.interp_operations(f, [1])
-        assert res == ord("d") # XXX should be "d"
-        res = self.interp_operations(f, [6])
-        assert res == 6
-        res = self.interp_operations(f, [42])
-        assert res == ord("?")
-
-    def test_chr2str(self):
-        def f(n):
-            s = chr(n)
-            return s[0]
-        res = self.interp_operations(f, [3])
-        assert res == 3
-
-    def test_unicode(self):
-        def f(n):
-            bytecode = u'adlfkj' + unichr(n)
-            if n < len(bytecode):
-                return bytecode[n]
-            else:
-                return u"?"
-        res = self.interp_operations(f, [1])
-        assert res == ord(u"d") # XXX should be "d"
-        res = self.interp_operations(f, [6])
-        assert res == 6
-        res = self.interp_operations(f, [42])
-        assert res == ord(u"?")
-
-    def test_residual_call(self):
-        @dont_look_inside
-        def externfn(x, y):
-            return x * y
-        def f(n):
-            return externfn(n, n+1)
-        res = self.interp_operations(f, [6])
-        assert res == 42
-        self.check_operations_history(int_add=1, int_mul=0, call=1, guard_no_exception=0)
-
-    def test_residual_call_pure(self):
-        def externfn(x, y):
-            return x * y
-        externfn._pure_function_ = True
-        def f(n):
-            n = hint(n, promote=True)
-            return externfn(n, n+1)
-        res = self.interp_operations(f, [6])
-        assert res == 42
-        # CALL_PURE is not recorded in the history if all-constant args
-        self.check_operations_history(int_add=0, int_mul=0,
-                                      call=0, call_pure=0)
-
-    def test_residual_call_pure_1(self):
-        def externfn(x, y):
-            return x * y
-        externfn._pure_function_ = True
-        def f(n):
-            return externfn(n, n+1)
-        res = self.interp_operations(f, [6])
-        assert res == 42
-        # CALL_PURE is recorded in the history if not-all-constant args
-        self.check_operations_history(int_add=1, int_mul=0,
-                                      call=0, call_pure=1)
-
-    def test_residual_call_pure_2(self):
-        myjitdriver = JitDriver(greens = [], reds = ['n'])
-        def externfn(x):
-            return x - 1
-        externfn._pure_function_ = True
-        def f(n):
-            while n > 0:
-                myjitdriver.can_enter_jit(n=n)
-                myjitdriver.jit_merge_point(n=n)
-                n = externfn(n)
-            return n
-        res = self.meta_interp(f, [7])
-        assert res == 0
-        # CALL_PURE is recorded in the history, but turned into a CALL
-        # by optimizeopt.py
-        self.check_loops(int_sub=0, call=1, call_pure=0)
-
-    def test_constfold_call_pure(self):
-        myjitdriver = JitDriver(greens = ['m'], reds = ['n'])
-        def externfn(x):
-            return x - 3
-        externfn._pure_function_ = True
-        def f(n, m):
-            while n > 0:
-                myjitdriver.can_enter_jit(n=n, m=m)
-                myjitdriver.jit_merge_point(n=n, m=m)
-                n -= externfn(m)
-            return n
-        res = self.meta_interp(f, [21, 5])
-        assert res == -1
-        # the CALL_PURE is constant-folded away by optimizeopt.py
-        self.check_loops(int_sub=1, call=0, call_pure=0)
-
-    def test_constfold_call_pure_2(self):
-        myjitdriver = JitDriver(greens = ['m'], reds = ['n'])
-        def externfn(x):
-            return x - 3
-        externfn._pure_function_ = True
-        class V:
-            def __init__(self, value):
-                self.value = value
-        def f(n, m):
-            while n > 0:
-                myjitdriver.can_enter_jit(n=n, m=m)
-                myjitdriver.jit_merge_point(n=n, m=m)
-                v = V(m)
-                n -= externfn(v.value)
-            return n
-        res = self.meta_interp(f, [21, 5])
-        assert res == -1
-        # the CALL_PURE is constant-folded away by optimizeopt.py
-        self.check_loops(int_sub=1, call=0, call_pure=0)
-
-    def test_pure_function_returning_object(self):
-        myjitdriver = JitDriver(greens = ['m'], reds = ['n'])
-        class V:
-            def __init__(self, x):
-                self.x = x
-        v1 = V(1)
-        v2 = V(2)
-        def externfn(x):
-            if x:
-                return v1
-            else:
-                return v2
-        externfn._pure_function_ = True
-        def f(n, m):
-            while n > 0:
-                myjitdriver.can_enter_jit(n=n, m=m)
-                myjitdriver.jit_merge_point(n=n, m=m)
-                m = V(m).x
-                n -= externfn(m).x + externfn(m + m - m).x
-            return n
-        res = self.meta_interp(f, [21, 5])
-        assert res == -1
-        # the CALL_PURE is constant-folded away by optimizeopt.py
-        self.check_loops(int_sub=1, call=0, call_pure=0, getfield_gc=0)
-
-    def test_constant_across_mp(self):
-        myjitdriver = JitDriver(greens = [], reds = ['n'])
-        class X(object):
-            pass
-        def f(n):
-            while n > -100:
-                myjitdriver.can_enter_jit(n=n)
-                myjitdriver.jit_merge_point(n=n)
-                x = X()
-                x.arg = 5
-                if n <= 0: break
-                n -= x.arg
-                x.arg = 6   # prevents 'x.arg' from being annotated as constant
-            return n
-        res = self.meta_interp(f, [31])
-        assert res == -4
-
-    def test_stopatxpolicy(self):
-        myjitdriver = JitDriver(greens = [], reds = ['y'])
-        def internfn(y):
-            return y * 3
-        def externfn(y):
-            return y % 4
-        def f(y):
-            while y >= 0:
-                myjitdriver.can_enter_jit(y=y)
-                myjitdriver.jit_merge_point(y=y)
-                if y & 7:
-                    f = internfn
-                else:
-                    f = externfn
-                f(y)
-                y -= 1
-            return 42
-        policy = StopAtXPolicy(externfn)
-        res = self.meta_interp(f, [31], policy=policy)
-        assert res == 42
-        self.check_loops(int_mul=1, int_mod=0)
-
-    def test_we_are_jitted(self):
-        myjitdriver = JitDriver(greens = [], reds = ['y'])
-        def f(y):
-            while y >= 0:
-                myjitdriver.can_enter_jit(y=y)
-                myjitdriver.jit_merge_point(y=y)
-                if we_are_jitted():
-                    x = 1
-                else:
-                    x = 10
-                y -= x
-            return y
-        assert f(55) == -5
-        res = self.meta_interp(f, [55])
-        assert res == -1
-
-    def test_confirm_enter_jit(self):
-        def confirm_enter_jit(x, y):
-            return x <= 5
-        myjitdriver = JitDriver(greens = ['x'], reds = ['y'],
-                                confirm_enter_jit = confirm_enter_jit)
-        def f(x, y):
-            while y >= 0:
-                myjitdriver.can_enter_jit(x=x, y=y)
-                myjitdriver.jit_merge_point(x=x, y=y)
-                y -= x
-            return y
-        #
-        res = self.meta_interp(f, [10, 84])
-        assert res == -6
-        self.check_loop_count(0)
-        #
-        res = self.meta_interp(f, [3, 19])
-        assert res == -2
-        self.check_loop_count(1)
-
-    def test_can_never_inline(self):
-        def can_never_inline(x):
-            return x > 50
-        myjitdriver = JitDriver(greens = ['x'], reds = ['y'],
-                                can_never_inline = can_never_inline)
-        @dont_look_inside
-        def marker():
-            pass
-        def f(x, y):
-            while y >= 0:
-                myjitdriver.can_enter_jit(x=x, y=y)
-                myjitdriver.jit_merge_point(x=x, y=y)
-                x += 1
-                if x == 4 or x == 61:
-                    marker()
-                y -= x
-            return y
-        #
-        res = self.meta_interp(f, [3, 6], repeat=7)
-        assert res == 6 - 4 - 5
-        self.check_history(call=0)   # because the trace starts in the middle
-        #
-        res = self.meta_interp(f, [60, 84], repeat=7)
-        assert res == 84 - 61 - 62
-        self.check_history(call=1)   # because the trace starts immediately
-
-    def test_format(self):
-        def f(n):
-            return len("<%d>" % n)
-        res = self.interp_operations(f, [421])
-        assert res == 5
-
-    def test_switch(self):
-        def f(n):
-            if n == -5:  return 12
-            elif n == 2: return 51
-            elif n == 7: return 1212
-            else:        return 42
-        res = self.interp_operations(f, [7])
-        assert res == 1212
-        res = self.interp_operations(f, [12311])
-        assert res == 42
-
-    def test_r_uint(self):
-        from pypy.rlib.rarithmetic import r_uint
-        myjitdriver = JitDriver(greens = [], reds = ['y'])
-        def f(y):
-            y = r_uint(y)
-            while y > 0:
-                myjitdriver.can_enter_jit(y=y)
-                myjitdriver.jit_merge_point(y=y)
-                y -= 1
-            return y
-        res = self.meta_interp(f, [10])
-        assert res == 0
-
-    def test_uint_operations(self):
-        from pypy.rlib.rarithmetic import r_uint
-        def f(n):
-            return ((r_uint(n) - 123) >> 1) <= r_uint(456)
-        res = self.interp_operations(f, [50])
-        assert res == False
-        self.check_operations_history(int_rshift=0, uint_rshift=1,
-                                      int_le=0, uint_le=1,
-                                      int_sub=1)
-
-    def test_uint_condition(self):
-        from pypy.rlib.rarithmetic import r_uint
-        def f(n):
-            if ((r_uint(n) - 123) >> 1) <= r_uint(456):
-                return 24
-            else:
-                return 12
-        res = self.interp_operations(f, [50])
-        assert res == 12
-        self.check_operations_history(int_rshift=0, uint_rshift=1,
-                                      int_le=0, uint_le=1,
-                                      int_sub=1)
-
-    def test_int_between(self):
-        #
-        def check(arg1, arg2, arg3, expect_result, **expect_operations):
-            from pypy.rpython.lltypesystem import lltype
-            from pypy.rpython.lltypesystem.lloperation import llop
-            loc = locals().copy()
-            exec py.code.Source("""
-                def f(n, m, p):
-                    arg1 = %(arg1)s
-                    arg2 = %(arg2)s
-                    arg3 = %(arg3)s
-                    return llop.int_between(lltype.Bool, arg1, arg2, arg3)
-            """ % locals()).compile() in loc
-            res = self.interp_operations(loc['f'], [5, 6, 7])
-            assert res == expect_result
-            self.check_operations_history(expect_operations)
-        #
-        check('n', 'm', 'p', True,  int_sub=2, uint_lt=1)
-        check('n', 'p', 'm', False, int_sub=2, uint_lt=1)
-        #
-        check('n', 'm', 6, False, int_sub=2, uint_lt=1)
-        #
-        check('n', 4, 'p', False, int_sub=2, uint_lt=1)
-        check('n', 5, 'p', True,  int_sub=2, uint_lt=1)
-        check('n', 8, 'p', False, int_sub=2, uint_lt=1)
-        #
-        check('n', 6, 7, True, int_sub=2, uint_lt=1)
-        #
-        check(-2, 'n', 'p', True,  int_sub=2, uint_lt=1)
-        check(-2, 'm', 'p', True,  int_sub=2, uint_lt=1)
-        check(-2, 'p', 'm', False, int_sub=2, uint_lt=1)
-        #check(0, 'n', 'p', True,  uint_lt=1)   xxx implement me
-        #check(0, 'm', 'p', True,  uint_lt=1)
-        #check(0, 'p', 'm', False, uint_lt=1)
-        #
-        check(2, 'n', 6, True,  int_sub=1, uint_lt=1)
-        check(2, 'm', 6, False, int_sub=1, uint_lt=1)
-        check(2, 'p', 6, False, int_sub=1, uint_lt=1)
-        check(5, 'n', 6, True,  int_eq=1)    # 6 == 5+1
-        check(5, 'm', 6, False, int_eq=1)    # 6 == 5+1
-        #
-        check(2, 6, 'm', False, int_sub=1, uint_lt=1)
-        check(2, 6, 'p', True,  int_sub=1, uint_lt=1)
-        #
-        check(2, 40, 6,  False)
-        check(2, 40, 60, True)
-
-    def test_getfield(self):
-        class A:
-            pass
-        a1 = A()
-        a1.foo = 5
-        a2 = A()
-        a2.foo = 8
-        def f(x):
-            if x > 5:
-                a = a1
-            else:
-                a = a2
-            return a.foo * x
-        res = self.interp_operations(f, [42])
-        assert res == 210
-        self.check_operations_history(getfield_gc=1)
-
-    def test_getfield_immutable(self):
-        class A:
-            _immutable_ = True
-        a1 = A()
-        a1.foo = 5
-        a2 = A()
-        a2.foo = 8
-        def f(x):
-            if x > 5:
-                a = a1
-            else:
-                a = a2
-            return a.foo * x
-        res = self.interp_operations(f, [42])
-        assert res == 210
-        self.check_operations_history(getfield_gc=0)
-
-    def test_setfield_bool(self):
-        class A:
-            def __init__(self):
-                self.flag = True
-        myjitdriver = JitDriver(greens = [], reds = ['n', 'obj'])
-        def f(n):
-            obj = A()
-            res = False
-            while n > 0:
-                myjitdriver.can_enter_jit(n=n, obj=obj)
-                myjitdriver.jit_merge_point(n=n, obj=obj)
-                obj.flag = False
-                n -= 1
-            return res
-        res = self.meta_interp(f, [7])
-        assert type(res) == bool
-        assert not res
-
-    def test_switch_dict(self):
-        def f(x):
-            if   x == 1: return 61
-            elif x == 2: return 511
-            elif x == 3: return -22
-            elif x == 4: return 81
-            elif x == 5: return 17
-            elif x == 6: return 54
-            elif x == 7: return 987
-            elif x == 8: return -12
-            elif x == 9: return 321
-            return -1
-        res = self.interp_operations(f, [5])
-        assert res == 17
-        res = self.interp_operations(f, [15])
-        assert res == -1
-
-    def test_int_add_ovf(self):
-        def f(x, y):
-            try:
-                return ovfcheck(x + y)
-            except OverflowError:
-                return -42
-        res = self.interp_operations(f, [-100, 2])
-        assert res == -98
-        res = self.interp_operations(f, [1, sys.maxint])
-        assert res == -42
-
-    def test_int_sub_ovf(self):
-        def f(x, y):
-            try:
-                return ovfcheck(x - y)
-            except OverflowError:
-                return -42
-        res = self.interp_operations(f, [-100, 2])
-        assert res == -102
-        res = self.interp_operations(f, [1, -sys.maxint])
-        assert res == -42
-
-    def test_int_mul_ovf(self):
-        def f(x, y):
-            try:
-                return ovfcheck(x * y)
-            except OverflowError:
-                return -42
-        res = self.interp_operations(f, [-100, 2])
-        assert res == -200
-        res = self.interp_operations(f, [-3, sys.maxint//2])
-        assert res == -42
-
-    def test_mod_ovf(self):
-        myjitdriver = JitDriver(greens = [], reds = ['n', 'x', 'y'])
-        def f(n, x, y):
-            while n > 0:
-                myjitdriver.can_enter_jit(x=x, y=y, n=n)
-                myjitdriver.jit_merge_point(x=x, y=y, n=n)
-                n -= ovfcheck(x % y)
-            return n
-        res = self.meta_interp(f, [20, 1, 2])
-        assert res == 0
-        self.check_loops(call=0)
-
-    def test_abs(self):
-        myjitdriver = JitDriver(greens = [], reds = ['i', 't'])
-        def f(i):
-            t = 0
-            while i < 10:
-                myjitdriver.can_enter_jit(i=i, t=t)
-                myjitdriver.jit_merge_point(i=i, t=t)
-                t += abs(i)
-                i += 1
-            return t
-        res = self.meta_interp(f, [-5])
-        assert res == 5+4+3+2+1+0+1+2+3+4+5+6+7+8+9
-
-    def test_float(self):
-        myjitdriver = JitDriver(greens = [], reds = ['x', 'y', 'res'])
-        def f(x, y):
-            x = float(x)
-            y = float(y)
-            res = 0.0
-            while y > 0.0:
-                myjitdriver.can_enter_jit(x=x, y=y, res=res)
-                myjitdriver.jit_merge_point(x=x, y=y, res=res)
-                res += x
-                y -= 1.0
-            return res
-        res = self.meta_interp(f, [6, 7])
-        assert res == 42.0
-        self.check_loop_count(1)
-        self.check_loops({'guard_true': 1,
-                          'float_add': 1, 'float_sub': 1, 'float_gt': 1,
-                          'jump': 1})
-
-    def test_print(self):
-        myjitdriver = JitDriver(greens = [], reds = ['n'])
-        def f(n):
-            while n > 0:
-                myjitdriver.can_enter_jit(n=n)
-                myjitdriver.jit_merge_point(n=n)
-                print n
-                n -= 1
-            return n
-        res = self.meta_interp(f, [7])
-        assert res == 0
-
-    def test_bridge_from_interpreter(self):
-        mydriver = JitDriver(reds = ['n'], greens = [])
-
-        def f(n):
-            while n > 0:
-                mydriver.can_enter_jit(n=n)
-                mydriver.jit_merge_point(n=n)
-                n -= 1
-
-        self.meta_interp(f, [20], repeat=7)
-        self.check_tree_loop_count(2)      # the loop and the entry path
-        # we get:
-        #    ENTER             - compile the new loop and the entry bridge
-        #    ENTER             - compile the leaving path
-        self.check_enter_count(2)
-
-    def test_bridge_from_interpreter_2(self):
-        # one case for backend - computing of framesize on guard failure
-        mydriver = JitDriver(reds = ['n'], greens = [])
-        glob = [1]
-
-        def f(n):
-            while n > 0:
-                mydriver.can_enter_jit(n=n)
-                mydriver.jit_merge_point(n=n)
-                if n == 17 and glob[0]:
-                    glob[0] = 0
-                    x = n + 1
-                    y = n + 2
-                    z = n + 3
-                    k = n + 4
-                    n -= 1
-                    n += x + y + z + k
-                    n -= x + y + z + k
-                n -= 1
-
-        self.meta_interp(f, [20], repeat=7)
-
-    def test_bridge_from_interpreter_3(self):
-        # one case for backend - computing of framesize on guard failure
-        mydriver = JitDriver(reds = ['n', 'x', 'y', 'z', 'k'], greens = [])
-        class Global:
-            pass
-        glob = Global()
-
-        def f(n):
-            glob.x = 1
-            x = 0
-            y = 0
-            z = 0
-            k = 0
-            while n > 0:
-                mydriver.can_enter_jit(n=n, x=x, y=y, z=z, k=k)
-                mydriver.jit_merge_point(n=n, x=x, y=y, z=z, k=k)
-                x += 10
-                y += 3
-                z -= 15
-                k += 4
-                if n == 17 and glob.x:
-                    glob.x = 0
-                    x += n + 1
-                    y += n + 2
-                    z += n + 3
-                    k += n + 4
-                    n -= 1
-                n -= 1
-            return x + 2*y + 3*z + 5*k + 13*n
-
-        res = self.meta_interp(f, [20], repeat=7)
-        assert res == f(20)
-
-    def test_bridge_from_interpreter_4(self):
-        jitdriver = JitDriver(reds = ['n', 'k'], greens = [])
-        
-        def f(n, k):
-            while n > 0:
-                jitdriver.can_enter_jit(n=n, k=k)
-                jitdriver.jit_merge_point(n=n, k=k)
-                if k:
-                    n -= 2
-                else:
-                    n -= 1
-            return n + k
-
-        from pypy.rpython.test.test_llinterp import get_interpreter, clear_tcache
-        from pypy.jit.metainterp.warmspot import WarmRunnerDesc
-        
-        interp, graph = get_interpreter(f, [0, 0], backendopt=False,
-                                        inline_threshold=0, type_system=self.type_system)
-        clear_tcache()
-        translator = interp.typer.annotator.translator
-        translator.config.translation.gc = "boehm"
-        warmrunnerdesc = WarmRunnerDesc(translator,
-                                        CPUClass=self.CPUClass)
-        state = warmrunnerdesc.jitdrivers_sd[0].warmstate
-        state.set_param_threshold(3)          # for tests
-        state.set_param_trace_eagerness(0)    # for tests
-        warmrunnerdesc.finish()
-        for n, k in [(20, 0), (20, 1)]:
-            interp.eval_graph(graph, [n, k])
-
-    def test_bridge_leaving_interpreter_5(self):
-        mydriver = JitDriver(reds = ['n', 'x'], greens = [])
-        class Global:
-            pass
-        glob = Global()
-
-        def f(n):
-            x = 0
-            glob.x = 1
-            while n > 0:
-                mydriver.can_enter_jit(n=n, x=x)
-                mydriver.jit_merge_point(n=n, x=x)
-                glob.x += 1
-                x += 3
-                n -= 1
-            glob.x += 100
-            return glob.x + x
-        res = self.meta_interp(f, [20], repeat=7)
-        assert res == f(20)
-
-    def test_instantiate_classes(self):
-        class Base: pass
-        class A(Base): foo = 72
-        class B(Base): foo = 8
-        def f(n):
-            if n > 5:
-                cls = A
-            else:
-                cls = B
-            return cls().foo
-        res = self.interp_operations(f, [3])
-        assert res == 8
-        res = self.interp_operations(f, [13])
-        assert res == 72
-
-    def test_instantiate_does_not_call(self):
-        mydriver = JitDriver(reds = ['n', 'x'], greens = [])
-        class Base: pass
-        class A(Base): foo = 72
-        class B(Base): foo = 8
-
-        def f(n):
-            x = 0
-            while n > 0:
-                mydriver.can_enter_jit(n=n, x=x)
-                mydriver.jit_merge_point(n=n, x=x)
-                if n % 2 == 0:
-                    cls = A
-                else:
-                    cls = B
-                inst = cls()
-                x += inst.foo
-                n -= 1
-            return x
-        res = self.meta_interp(f, [20], enable_opts='')
-        assert res == f(20)
-        self.check_loops(call=0)
-
-    def test_zerodivisionerror(self):
-        # test the case of exception-raising operation that is not delegated
-        # to the backend at all: ZeroDivisionError
-        #
-        def f(n):
-            assert n >= 0
-            try:
-                return ovfcheck(5 % n)
-            except ZeroDivisionError:
-                return -666
-            except OverflowError:
-                return -777
-        res = self.interp_operations(f, [0])
-        assert res == -666
-        #
-        def f(n):
-            assert n >= 0
-            try:
-                return ovfcheck(6 // n)
-            except ZeroDivisionError:
-                return -667
-            except OverflowError:
-                return -778
-        res = self.interp_operations(f, [0])
-        assert res == -667
-
-    def test_div_overflow(self):
-        import sys
-        from pypy.rpython.lltypesystem.lloperation import llop
-        myjitdriver = JitDriver(greens = [], reds = ['x', 'y', 'res'])
-        def f(x, y):
-            res = 0
-            while y > 0:
-                myjitdriver.can_enter_jit(x=x, y=y, res=res)
-                myjitdriver.jit_merge_point(x=x, y=y, res=res)
-                try:
-                    res += llop.int_floordiv_ovf(lltype.Signed,
-                                                 -sys.maxint-1, x)
-                    x += 5
-                except OverflowError:
-                    res += 100
-                y -= 1
-            return res
-        res = self.meta_interp(f, [-41, 16])
-        assert res == ((-sys.maxint-1) // (-41) +
-                       (-sys.maxint-1) // (-36) +
-                       (-sys.maxint-1) // (-31) +
-                       (-sys.maxint-1) // (-26) +
-                       (-sys.maxint-1) // (-21) +
-                       (-sys.maxint-1) // (-16) +
-                       (-sys.maxint-1) // (-11) +
-                       (-sys.maxint-1) // (-6) +
-                       100 * 8)
-
-    def test_isinstance(self):
-        class A:
-            pass
-        class B(A):
-            pass
-        def fn(n):
-            if n:
-                obj = A()
-            else:
-                obj = B()
-            return isinstance(obj, B)
-        res = self.interp_operations(fn, [0])
-        assert res
-        self.check_operations_history(guard_class=1)
-        res = self.interp_operations(fn, [1])
-        assert not res
-
-    def test_isinstance_2(self):
-        driver = JitDriver(greens = [], reds = ['n', 'sum', 'x'])
-        class A:
-            pass
-        class B(A):
-            pass
-        class C(B):
-            pass
-
-        def main():
-            return f(5, B()) * 10 + f(5, C()) + f(5, A()) * 100
-
-        def f(n, x):
-            sum = 0
-            while n > 0:
-                driver.can_enter_jit(x=x, n=n, sum=sum)
-                driver.jit_merge_point(x=x, n=n, sum=sum)
-                if isinstance(x, B):
-                    sum += 1
-                n -= 1
-            return sum
-
-        res = self.meta_interp(main, [])
-        assert res == 55
-
-    def test_assert_isinstance(self):
-        class A:
-            pass
-        class B(A):
-            pass
-        def fn(n):
-            # this should only be called with n != 0
-            if n:
-                obj = B()
-                obj.a = n
-            else:
-                obj = A()
-                obj.a = 17
-            assert isinstance(obj, B)
-            return obj.a
-        res = self.interp_operations(fn, [1])
-        assert res == 1
-        self.check_operations_history(guard_class=0)
-        if self.type_system == 'ootype':
-            self.check_operations_history(instanceof=0)
-
-    def test_r_dict(self):
-        from pypy.rlib.objectmodel import r_dict
-        class FooError(Exception):
-            pass
-        def myeq(n, m):
-            return n == m
-        def myhash(n):
-            if n < 0:
-                raise FooError
-            return -n
-        def f(n):
-            d = r_dict(myeq, myhash)
-            for i in range(10):
-                d[i] = i*i
-            try:
-                return d[n]
-            except FooError:
-                return 99
-        res = self.interp_operations(f, [5])
-        assert res == f(5)
-
-    def test_free_object(self):
-        import weakref
-        from pypy.rlib import rgc
-        from pypy.rpython.lltypesystem.lloperation import llop
-        myjitdriver = JitDriver(greens = [], reds = ['n', 'x'])
-        class X(object):
-            pass
-        def main(n, x):
-            while n > 0:
-                myjitdriver.can_enter_jit(n=n, x=x)
-                myjitdriver.jit_merge_point(n=n, x=x)
-                n -= x.foo
-        def g(n):
-            x = X()
-            x.foo = 2
-            main(n, x)
-            x.foo = 5
-            return weakref.ref(x)
-        def f(n):
-            r = g(n)
-            rgc.collect(); rgc.collect(); rgc.collect()
-            return r() is None
-        #
-        assert f(30) == 1
-        res = self.meta_interp(f, [30], no_stats=True)
-        assert res == 1
-
-    def test_pass_around(self):
-        myjitdriver = JitDriver(greens = [], reds = ['n', 'x'])
-
-        def call():
-            pass
-
-        def f(n, x):
-            while n > 0:
-                myjitdriver.can_enter_jit(n=n, x=x)
-                myjitdriver.jit_merge_point(n=n, x=x)
-                if n % 2:
-                    call()
-                    if n == 8:
-                        return x
-                    x = 3
-                else:
-                    x = 5
-                n -= 1
-            return 0
-
-        self.meta_interp(f, [40, 0])
-
-    def test_const_inputargs(self):
-        myjitdriver = JitDriver(greens = ['m'], reds = ['n', 'x'])
-        def f(n, x):
-            m = 0x7FFFFFFF
-            while n > 0:
-                myjitdriver.can_enter_jit(m=m, n=n, x=x)
-                myjitdriver.jit_merge_point(m=m, n=n, x=x)
-                x = 42
-                n -= 1
-                m = m >> 1
-            return x
-
-        res = self.meta_interp(f, [50, 1], enable_opts='')
-        assert res == 42
-
-    def test_set_param(self):
-        myjitdriver = JitDriver(greens = [], reds = ['n', 'x'])
-        def g(n):
-            x = 0
-            while n > 0:
-                myjitdriver.can_enter_jit(n=n, x=x)
-                myjitdriver.jit_merge_point(n=n, x=x)
-                n -= 1
-                x += n
-            return x
-        def f(n, threshold):
-            myjitdriver.set_param('threshold', threshold)
-            return g(n)
-
-        res = self.meta_interp(f, [10, 3])
-        assert res == 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1 + 0
-        self.check_tree_loop_count(2)
-
-        res = self.meta_interp(f, [10, 13])
-        assert res == 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1 + 0
-        self.check_tree_loop_count(0)
-
-    def test_dont_look_inside(self):
-        @dont_look_inside
-        def g(a, b):
-            return a + b
-        def f(a, b):
-            return g(a, b)
-        res = self.interp_operations(f, [3, 5])
-        assert res == 8
-        self.check_operations_history(int_add=0, call=1)
-
-    def test_listcomp(self):
-        myjitdriver = JitDriver(greens = [], reds = ['x', 'y', 'lst'])
-        def f(x, y):
-            lst = [0, 0, 0]
-            while y > 0:
-                myjitdriver.can_enter_jit(x=x, y=y, lst=lst)
-                myjitdriver.jit_merge_point(x=x, y=y, lst=lst)
-                lst = [i+x for i in lst if i >=0]
-                y -= 1
-            return lst[0]
-        res = self.meta_interp(f, [6, 7], listcomp=True, backendopt=True, listops=True)
-        # XXX: the loop looks inefficient
-        assert res == 42
-
-    def test_tuple_immutable(self):
-        def new(a, b):
-            return a, b
-        def f(a, b):
-            tup = new(a, b)
-            return tup[1]
-        res = self.interp_operations(f, [3, 5])
-        assert res == 5
-        self.check_operations_history(setfield_gc=2, getfield_gc_pure=1)
-
-    def test_oosend_look_inside_only_one(self):
-        class A:
-            pass
-        class B(A):
-            def g(self):
-                return 123
-        class C(A):
-            @dont_look_inside
-            def g(self):
-                return 456
-        def f(n):
-            if n > 3:
-                x = B()
-            else:
-                x = C()
-            return x.g() + x.g()
-        res = self.interp_operations(f, [10])
-        assert res == 123 * 2
-        res = self.interp_operations(f, [-10])
-        assert res == 456 * 2
-
-    def test_residual_external_call(self):
-        import math
-        myjitdriver = JitDriver(greens = [], reds = ['y', 'x', 'res'])
-        def f(x, y):
-            x = float(x)
-            res = 0.0
-            while y > 0:
-                myjitdriver.can_enter_jit(x=x, y=y, res=res)
-                myjitdriver.jit_merge_point(x=x, y=y, res=res)
-                # this is an external call that the default policy ignores
-                rpart, ipart = math.modf(x)
-                res += ipart
-                y -= 1
-            return res
-        res = self.meta_interp(f, [6, 7])
-        assert res == 42
-        self.check_loop_count(1)
-        self.check_loops(call=1)
-
-    def test_merge_guardclass_guardvalue(self):
-        from pypy.rlib.objectmodel import instantiate
-        myjitdriver = JitDriver(greens = [], reds = ['x', 'l'])
-
-        class A(object):
-            def g(self, x):
-                return x - 5
-        class B(A):
-            def g(self, y):
-                return y - 3
-
-        a1 = A()
-        a2 = A()
-        b = B()
-        def f(x):
-            l = [a1] * 100 + [a2] * 100 + [b] * 100
-            while x > 0:
-                myjitdriver.can_enter_jit(x=x, l=l)
-                myjitdriver.jit_merge_point(x=x, l=l)
-                a = l[x]
-                x = a.g(x)
-                hint(a, promote=True)
-            return x
-        res = self.meta_interp(f, [299], listops=True)
-        assert res == f(299)
-        self.check_loops(guard_class=0, guard_value=2)        
-        self.check_loops(guard_class=0, guard_value=5, everywhere=True)
-
-    def test_merge_guardnonnull_guardclass(self):
-        from pypy.rlib.objectmodel import instantiate
-        myjitdriver = JitDriver(greens = [], reds = ['x', 'l'])
-
-        class A(object):
-            def g(self, x):
-                return x - 3
-        class B(A):
-            def g(self, y):
-                return y - 5
-
-        a1 = A()
-        b1 = B()
-        def f(x):
-            l = [None] * 100 + [b1] * 100 + [a1] * 100
-            while x > 0:
-                myjitdriver.can_enter_jit(x=x, l=l)
-                myjitdriver.jit_merge_point(x=x, l=l)
-                a = l[x]
-                if a:
-                    x = a.g(x)
-                else:
-                    x -= 7
-            return x
-        res = self.meta_interp(f, [299], listops=True)
-        assert res == f(299)
-        self.check_loops(guard_class=0, guard_nonnull=0,
-                         guard_nonnull_class=2, guard_isnull=0)
-        self.check_loops(guard_class=0, guard_nonnull=0,
-                         guard_nonnull_class=4, guard_isnull=1,
-                         everywhere=True)
-
-    def test_merge_guardnonnull_guardvalue(self):
-        from pypy.rlib.objectmodel import instantiate
-        myjitdriver = JitDriver(greens = [], reds = ['x', 'l'])
-
-        class A(object):
-            pass
-        class B(A):
-            pass
-
-        a1 = A()
-        b1 = B()
-        def f(x):
-            l = [b1] * 100 + [None] * 100 + [a1] * 100
-            while x > 0:
-                myjitdriver.can_enter_jit(x=x, l=l)
-                myjitdriver.jit_merge_point(x=x, l=l)
-                a = l[x]
-                if a:
-                    x -= 5
-                else:
-                    x -= 7
-                hint(a, promote=True)
-            return x
-        res = self.meta_interp(f, [299], listops=True)
-        assert res == f(299)
-        self.check_loops(guard_class=0, guard_nonnull=0, guard_value=1,
-                         guard_nonnull_class=0, guard_isnull=1)
-        self.check_loops(guard_class=0, guard_nonnull=0, guard_value=3,
-                         guard_nonnull_class=0, guard_isnull=2,
-                         everywhere=True)
-
-    def test_merge_guardnonnull_guardvalue_2(self):
-        from pypy.rlib.objectmodel import instantiate
-        myjitdriver = JitDriver(greens = [], reds = ['x', 'l'])
-
-        class A(object):
-            pass
-        class B(A):
-            pass
-
-        a1 = A()
-        b1 = B()
-        def f(x):
-            l = [None] * 100 + [b1] * 100 + [a1] * 100
-            while x > 0:
-                myjitdriver.can_enter_jit(x=x, l=l)
-                myjitdriver.jit_merge_point(x=x, l=l)
-                a = l[x]
-                if a:
-                    x -= 5
-                else:
-                    x -= 7
-                hint(a, promote=True)
-            return x
-        res = self.meta_interp(f, [299], listops=True)
-        assert res == f(299)
-        self.check_loops(guard_class=0, guard_nonnull=0, guard_value=2,
-                         guard_nonnull_class=0, guard_isnull=0)
-        self.check_loops(guard_class=0, guard_nonnull=0, guard_value=4,
-                         guard_nonnull_class=0, guard_isnull=1,
-                         everywhere=True)
-
-    def test_merge_guardnonnull_guardclass_guardvalue(self):
-        from pypy.rlib.objectmodel import instantiate
-        myjitdriver = JitDriver(greens = [], reds = ['x', 'l'])
-
-        class A(object):
-            def g(self, x):
-                return x - 3
-        class B(A):
-            def g(self, y):
-                return y - 5
-
-        a1 = A()
-        a2 = A()
-        b1 = B()
-        def f(x):
-            l = [a2] * 100 + [None] * 100 + [b1] * 100 + [a1] * 100
-            while x > 0:
-                myjitdriver.can_enter_jit(x=x, l=l)
-                myjitdriver.jit_merge_point(x=x, l=l)
-                a = l[x]
-                if a:
-                    x = a.g(x)
-                else:
-                    x -= 7
-                hint(a, promote=True)
-            return x
-        res = self.meta_interp(f, [399], listops=True)
-        assert res == f(399)
-        self.check_loops(guard_class=0, guard_nonnull=0, guard_value=2,
-                         guard_nonnull_class=0, guard_isnull=0)
-        self.check_loops(guard_class=0, guard_nonnull=0, guard_value=5,
-                         guard_nonnull_class=0, guard_isnull=1,
-                         everywhere=True)
-
-    def test_residual_call_doesnt_lose_info(self):
-        myjitdriver = JitDriver(greens = [], reds = ['x', 'y', 'l'])
-
-        class A(object):
-            pass
-
-        globall = [""]
-        @dont_look_inside
-        def g(x):
-            globall[0] = str(x)
-            return x
-
-        def f(x):
-            y = A()
-            y.v = x
-            l = [0]
-            while y.v > 0:
-                myjitdriver.can_enter_jit(x=x, y=y, l=l)
-                myjitdriver.jit_merge_point(x=x, y=y, l=l)
-                l[0] = y.v
-                lc = l[0]
-                y.v = g(y.v) - y.v/y.v + lc/l[0] - 1
-            return y.v
-        res = self.meta_interp(f, [20], listops=True)
-        self.check_loops(getfield_gc=0, getarrayitem_gc=0)
-        self.check_loops(getfield_gc=1, getarrayitem_gc=0, everywhere=True)
-
-    def test_guard_isnull_nonnull(self):
-        myjitdriver = JitDriver(greens = [], reds = ['x', 'res'])
-        class A(object):
-            pass
-
-        @dont_look_inside
-        def create(x):
-            if x >= -40:
-                return A()
-            return None
-
-        def f(x):
-            res = 0
-            while x > 0:
-                myjitdriver.can_enter_jit(x=x, res=res)
-                myjitdriver.jit_merge_point(x=x, res=res)
-                obj = create(x-1)
-                if obj is not None:
-                    res += 1
-                obj2 = create(x-1000)
-                if obj2 is None:
-                    res += 1
-                x -= 1
-            return res
-        res = self.meta_interp(f, [21])
-        assert res == 42
-        self.check_loops(guard_nonnull=1, guard_isnull=1)
-
-    def test_loop_invariant1(self):
-        myjitdriver = JitDriver(greens = [], reds = ['x', 'res'])
-        class A(object):
-            pass
-        a = A()
-        a.current_a = A()
-        a.current_a.x = 1
-        @loop_invariant
-        def f():
-            return a.current_a
-
-        def g(x):
-            res = 0
-            while x > 0:
-                myjitdriver.can_enter_jit(x=x, res=res)
-                myjitdriver.jit_merge_point(x=x, res=res)
-                res += f().x
-                res += f().x
-                res += f().x
-                x -= 1
-            a.current_a = A()
-            a.current_a.x = 2
-            return res
-        res = self.meta_interp(g, [21])
-        assert res == 3 * 21
-        self.check_loops(call=0)
-        self.check_loops(call=1, everywhere=True)
-
-    def test_bug_optimizeopt_mutates_ops(self):
-        myjitdriver = JitDriver(greens = [], reds = ['x', 'res', 'const', 'a'])
-        class A(object):
-            pass
-        class B(A):
-            pass
-
-        glob = A()
-        glob.a = None
-        def f(x):
-            res = 0
-            a = A()
-            a.x = 0
-            glob.a = A()
-            const = 2
-            while x > 0:
-                myjitdriver.can_enter_jit(x=x, res=res, a=a, const=const)
-                myjitdriver.jit_merge_point(x=x, res=res, a=a, const=const)
-                if type(glob.a) is B:
-                    res += 1
-                if a is None:
-                    a = A()
-                    a.x = x
-                    glob.a = B()
-                    const = 2
-                else:
-                    const = hint(const, promote=True)
-                    x -= const
-                    res += a.x
-                    a = None
-                    glob.a = A()
-                    const = 1
-            return res
-        res = self.meta_interp(f, [21])
-        assert res == f(21)
-
-    def test_getitem_indexerror(self):
-        lst = [10, 4, 9, 16]
-        def f(n):
-            try:
-                return lst[n]
-            except IndexError:
-                return -2
-        res = self.interp_operations(f, [2])
-        assert res == 9
-        res = self.interp_operations(f, [4])
-        assert res == -2
-        res = self.interp_operations(f, [-4])
-        assert res == 10
-        res = self.interp_operations(f, [-5])
-        assert res == -2
-
-    def test_guard_always_changing_value(self):
-        myjitdriver = JitDriver(greens = [], reds = ['x'])
-        class A:
-            pass
-        def f(x):
-            while x > 0:
-                myjitdriver.can_enter_jit(x=x)
-                myjitdriver.jit_merge_point(x=x)
-                a = A()
-                hint(a, promote=True)
-                x -= 1
-        self.meta_interp(f, [50])
-        self.check_loop_count(1)
-        # this checks that the logic triggered by make_a_counter_per_value()
-        # works and prevents generating tons of bridges
-
-    def test_swap_values(self):
-        def f(x, y):
-            if x > 5:
-                x, y = y, x
-            return x - y
-        res = self.interp_operations(f, [10, 2])
-        assert res == -8
-        res = self.interp_operations(f, [3, 2])
-        assert res == 1
-
-    def test_raw_malloc_and_access(self):
-        from pypy.rpython.lltypesystem import rffi
-        
-        TP = rffi.CArray(lltype.Signed)
-        
-        def f(n):
-            a = lltype.malloc(TP, n, flavor='raw')
-            a[0] = n
-            res = a[0]
-            lltype.free(a, flavor='raw')
-            return res
-
-        res = self.interp_operations(f, [10])
-        assert res == 10
-
-    def test_raw_malloc_and_access_float(self):
-        from pypy.rpython.lltypesystem import rffi
-        
-        TP = rffi.CArray(lltype.Float)
-        
-        def f(n, f):
-            a = lltype.malloc(TP, n, flavor='raw')
-            a[0] = f
-            res = a[0]
-            lltype.free(a, flavor='raw')
-            return res
-
-        res = self.interp_operations(f, [10, 3.5])
-        assert res == 3.5
-
-    def test_jit_debug(self):
-        myjitdriver = JitDriver(greens = [], reds = ['x'])
-        class A:
-            pass
-        def f(x):
-            while x > 0:
-                myjitdriver.can_enter_jit(x=x)
-                myjitdriver.jit_merge_point(x=x)
-                jit_debug("hi there:", x)
-                jit_debug("foobar")
-                x -= 1
-            return x
-        res = self.meta_interp(f, [8])
-        assert res == 0
-        self.check_loops(jit_debug=2)
-
-    def test_assert_green(self):
-        def f(x, promote):
-            if promote:
-                x = hint(x, promote=True)
-            assert_green(x)
-            return x
-        res = self.interp_operations(f, [8, 1])
-        assert res == 8
-        py.test.raises(AssertGreenFailed, self.interp_operations, f, [8, 0])
-
-    def test_multiple_specialied_versions1(self):
-        myjitdriver = JitDriver(greens = [], reds = ['y', 'x', 'res'])
-        class Base:
-            def __init__(self, val):
-                self.val = val
-        class A(Base):
-            def binop(self, other):
-                return A(self.val + other.val)
-        class B(Base):
-            def binop(self, other):
-                return B(self.val * other.val)
-        def f(x, y):
-            res = x
-            while y > 0:
-                myjitdriver.can_enter_jit(y=y, x=x, res=res)
-                myjitdriver.jit_merge_point(y=y, x=x, res=res)
-                res = res.binop(x)
-                y -= 1
-            return res
-        def g(x, y):
-            a1 = f(A(x), y)
-            a2 = f(A(x), y)
-            b1 = f(B(x), y)
-            b2 = f(B(x), y)
-            assert a1.val == a2.val
-            assert b1.val == b2.val
-            return a1.val + b1.val
-        res = self.meta_interp(g, [6, 7])
-        assert res == 6*8 + 6**8
-        self.check_loop_count(5)
-        self.check_loops({'guard_true': 2,
-                          'int_add': 1, 'int_mul': 1, 'int_sub': 2,
-                          'int_gt': 2, 'jump': 2})
-
-    def test_multiple_specialied_versions_array(self):
-        myjitdriver = JitDriver(greens = [], reds = ['idx', 'y', 'x', 'res',
-                                                     'array'])
-        class Base:
-            def __init__(self, val):
-                self.val = val
-        class A(Base):
-            def binop(self, other):
-                return A(self.val + other.val)
-        class B(Base):
-            def binop(self, other):
-                return B(self.val - other.val)
-        def f(x, y):
-            res = x
-            array = [1, 2, 3]
-            array[1] = 7
-            idx = 0
-            while y > 0:
-                myjitdriver.can_enter_jit(idx=idx, y=y, x=x, res=res,
-                                          array=array)
-                myjitdriver.jit_merge_point(idx=idx, y=y, x=x, res=res,
-                                            array=array)
-                res = res.binop(x)
-                res.val += array[idx] + array[1]
-                if y < 7:
-                    idx = 2
-                y -= 1
-            return res
-        def g(x, y):
-            a1 = f(A(x), y)
-            a2 = f(A(x), y)
-            b1 = f(B(x), y)
-            b2 = f(B(x), y)
-            assert a1.val == a2.val
-            assert b1.val == b2.val
-            return a1.val + b1.val
-        res = self.meta_interp(g, [6, 14])
-        assert res == g(6, 14)
-        self.check_loop_count(9)
-        self.check_loops(getarrayitem_gc=6, everywhere=True)
-
-    def test_multiple_specialied_versions_bridge(self):
-        myjitdriver = JitDriver(greens = [], reds = ['y', 'x', 'z', 'res'])
-        class Base:
-            def __init__(self, val):
-                self.val = val
-            def getval(self):
-                return self.val
-        class A(Base):
-            def binop(self, other):
-                return A(self.getval() + other.getval())
-        class B(Base):
-            def binop(self, other):
-                return B(self.getval() * other.getval())
-        def f(x, y, z):
-            res = x
-            while y > 0:
-                myjitdriver.can_enter_jit(y=y, x=x, z=z, res=res)
-                myjitdriver.jit_merge_point(y=y, x=x, z=z, res=res)
-                res = res.binop(x)
-                y -= 1
-                if y < 7:
-                    x = z
-            return res
-        def g(x, y):
-            a1 = f(A(x), y, A(x))
-            a2 = f(A(x), y, A(x))
-            assert a1.val == a2.val
-            b1 = f(B(x), y, B(x))
-            b2 = f(B(x), y, B(x))
-            assert b1.val == b2.val
-            c1 = f(B(x), y, A(x))
-            c2 = f(B(x), y, A(x))
-            assert c1.val == c2.val
-            d1 = f(A(x), y, B(x))
-            d2 = f(A(x), y, B(x))
-            assert d1.val == d2.val
-            return a1.val + b1.val + c1.val + d1.val
-        res = self.meta_interp(g, [3, 14])
-        assert res == g(3, 14)
-
-    def test_failing_inlined_guard(self):
-        myjitdriver = JitDriver(greens = [], reds = ['y', 'x', 'z', 'res'])
-        class Base:
-            def __init__(self, val):
-                self.val = val
-            def getval(self):
-                return self.val
-        class A(Base):
-            def binop(self, other):
-                return A(self.getval() + other.getval())
-        class B(Base):
-            def binop(self, other):
-                return B(self.getval() * other.getval())
-        def f(x, y, z):
-            res = x
-            while y > 0:
-                myjitdriver.can_enter_jit(y=y, x=x, z=z, res=res)
-                myjitdriver.jit_merge_point(y=y, x=x, z=z, res=res)
-                res = res.binop(x)
-                y -= 1
-                if y < 8:
-                    x = z
-            return res
-        def g(x, y):
-            c1 = f(A(x), y, B(x))
-            c2 = f(A(x), y, B(x))
-            assert c1.val == c2.val
-            return c1.val
-        res = self.meta_interp(g, [3, 16])
-        assert res == g(3, 16)
-
-    def test_inlined_guard_in_short_preamble(self):
-        myjitdriver = JitDriver(greens = [], reds = ['y', 'x', 'z', 'res'])
-        class A:
-            def __init__(self, val):
-                self.val = val
-            def getval(self):
-                return self.val
-            def binop(self, other):
-                return A(self.getval() + other.getval())
-        def f(x, y, z):
-            res = x
-            while y > 0:
-                myjitdriver.can_enter_jit(y=y, x=x, z=z, res=res)
-                myjitdriver.jit_merge_point(y=y, x=x, z=z, res=res)
-                res = res.binop(x)
-                y -= 1
-                if y < 7:
-                    x = z
-            return res
-        def g(x, y):
-            a1 = f(A(x), y, A(x))
-            a2 = f(A(x), y, A(x))
-            assert a1.val == a2.val
-            return a1.val
-        res = self.meta_interp(g, [3, 14])
-        assert res == g(3, 14)
-
-    def test_specialied_bridge(self):
-        myjitdriver = JitDriver(greens = [], reds = ['y', 'x', 'res'])
-        class A:
-            def __init__(self, val):
-                self.val = val
-            def binop(self, other):
-                return A(self.val + other.val)
-        def f(x, y):
-            res = A(0)
-            while y > 0:
-                myjitdriver.can_enter_jit(y=y, x=x, res=res)
-                myjitdriver.jit_merge_point(y=y, x=x, res=res)
-                res = res.binop(A(y))
-                if y<7:
-                    res = x
-                y -= 1
-            return res
-        def g(x, y):
-            a1 = f(A(x), y)
-            a2 = f(A(x), y)
-            assert a1.val == a2.val
-            return a1.val
-        res = self.meta_interp(g, [6, 14])
-        assert res == g(6, 14)
-
-    def test_specialied_bridge_const(self):
-        myjitdriver = JitDriver(greens = [], reds = ['y', 'const', 'x', 'res'])
-        class A:
-            def __init__(self, val):
-                self.val = val
-            def binop(self, other):
-                return A(self.val + other.val)
-        def f(x, y):
-            res = A(0)
-            const = 7
-            while y > 0:
-                myjitdriver.can_enter_jit(y=y, x=x, res=res, const=const)
-                myjitdriver.jit_merge_point(y=y, x=x, res=res, const=const)
-                const = hint(const, promote=True)
-                res = res.binop(A(const))
-                if y<7:
-                    res = x
-                y -= 1
-            return res
-        def g(x, y):
-            a1 = f(A(x), y)
-            a2 = f(A(x), y)
-            assert a1.val == a2.val
-            return a1.val
-        res = self.meta_interp(g, [6, 14])
-        assert res == g(6, 14)
-
-    def test_multiple_specialied_zigzag(self):
-        myjitdriver = JitDriver(greens = [], reds = ['y', 'x', 'res'])
-        class Base:
-            def __init__(self, val):
-                self.val = val
-        class A(Base):
-            def binop(self, other):
-                return A(self.val + other.val)
-            def switch(self):
-                return B(self.val)
-        class B(Base):
-            def binop(self, other):
-                return B(self.val * other.val)
-            def switch(self):
-                return A(self.val)
-        def f(x, y):
-            res = x
-            while y > 0:
-                myjitdriver.can_enter_jit(y=y, x=x, res=res)
-                myjitdriver.jit_merge_point(y=y, x=x, res=res)
-                if y % 4 == 0:
-                    res = res.switch()
-                res = res.binop(x)
-                y -= 1
-            return res
-        def g(x, y):
-            a1 = f(A(x), y)
-            a2 = f(A(x), y)
-            b1 = f(B(x), y)
-            b2 = f(B(x), y)
-            assert a1.val == a2.val
-            assert b1.val == b2.val
-            return a1.val + b1.val
-        res = self.meta_interp(g, [3, 23])
-        assert res == 7068153
-        self.check_loop_count(6)
-        self.check_loops(guard_true=4, guard_class=0, int_add=2, int_mul=2,
-                         guard_false=2)
-
-    def test_dont_trace_every_iteration(self):
-        myjitdriver = JitDriver(greens = [], reds = ['a', 'b', 'i', 'sa'])
-        
-        def main(a, b):
-            i = sa = 0
-            #while i < 200:
-            while i < 200:
-                myjitdriver.can_enter_jit(a=a, b=b, i=i, sa=sa)
-                myjitdriver.jit_merge_point(a=a, b=b, i=i, sa=sa)
-                if a > 0: pass
-                if b < 2: pass
-                sa += a % b
-                i += 1
-            return sa
-        def g():
-            return main(10, 20) + main(-10, -20)
-        res = self.meta_interp(g, [])
-        assert res == g()
-        self.check_enter_count(2)
-
-    def test_current_trace_length(self):
-        myjitdriver = JitDriver(greens = ['g'], reds = ['x'])
-        @dont_look_inside
-        def residual():
-            print "hi there"
-        @unroll_safe
-        def loop(g):
-            y = 0
-            while y < g:
-                residual()
-                y += 1
-        def f(x, g):
-            n = 0
-            while x > 0:
-                myjitdriver.can_enter_jit(x=x, g=g)
-                myjitdriver.jit_merge_point(x=x, g=g)
-                loop(g)
-                x -= 1
-                n = current_trace_length()
-            return n
-        res = self.meta_interp(f, [5, 8])
-        assert 14 < res < 42
-        res = self.meta_interp(f, [5, 2])
-        assert 4 < res < 14
-
-    def test_compute_identity_hash(self):
-        from pypy.rlib.objectmodel import compute_identity_hash
-        class A(object):
-            pass
-        def f():
-            a = A()
-            return compute_identity_hash(a) == compute_identity_hash(a)
-        res = self.interp_operations(f, [])
-        assert res
-        # a "did not crash" kind of test
-
-    def test_compute_unique_id(self):
-        from pypy.rlib.objectmodel import compute_unique_id
-        class A(object):
-            pass
-        def f():
-            a1 = A()
-            a2 = A()
-            return (compute_unique_id(a1) == compute_unique_id(a1) and
-                    compute_unique_id(a1) != compute_unique_id(a2))
-        res = self.interp_operations(f, [])
-        assert res
-
-    def test_wrap_around_add(self):
-        myjitdriver = JitDriver(greens = [], reds = ['x', 'n'])
-        class A:
-            pass
-        def f(x):
-            n = 0
-            while x > 0:
-                myjitdriver.can_enter_jit(x=x, n=n)
-                myjitdriver.jit_merge_point(x=x, n=n)
-                x += 1
-                n += 1
-            return n
-        res = self.meta_interp(f, [sys.maxint-10])
-        assert res == 11
-        self.check_tree_loop_count(2)
-
-    def test_wrap_around_mul(self):
-        myjitdriver = JitDriver(greens = [], reds = ['x', 'n'])
-        class A:
-            pass
-        def f(x):
-            n = 0
-            while x > 0:
-                myjitdriver.can_enter_jit(x=x, n=n)
-                myjitdriver.jit_merge_point(x=x, n=n)
-                x *= 2
-                n += 1
-            return n
-        res = self.meta_interp(f, [sys.maxint>>10])
-        assert res == 11
-        self.check_tree_loop_count(2)        
-
-    def test_wrap_around_sub(self):
-        myjitdriver = JitDriver(greens = [], reds = ['x', 'n'])
-        class A:
-            pass
-        def f(x):
-            n = 0
-            while x < 0:
-                myjitdriver.can_enter_jit(x=x, n=n)
-                myjitdriver.jit_merge_point(x=x, n=n)
-                x -= 1
-                n += 1
-            return n
-        res = self.meta_interp(f, [10-sys.maxint])
-        assert res == 12
-        self.check_tree_loop_count(2)        
-
-
-
-class TestOOtype(BasicTests, OOJitMixin):
-
-    def test_oohash(self):
-        def f(n):
-            s = ootype.oostring(n, -1)
-            return s.ll_hash()
-        res = self.interp_operations(f, [5])
-        assert res == ootype.oostring(5, -1).ll_hash()
-
-    def test_identityhash(self):
-        A = ootype.Instance("A", ootype.ROOT)
-        def f():
-            obj1 = ootype.new(A)
-            obj2 = ootype.new(A)
-            return ootype.identityhash(obj1) == ootype.identityhash(obj2)
-        assert not f()
-        res = self.interp_operations(f, [])
-        assert not res
-
-    def test_oois(self):
-        A = ootype.Instance("A", ootype.ROOT)
-        def f(n):
-            obj1 = ootype.new(A)
-            if n:
-                obj2 = obj1
-            else:
-                obj2 = ootype.new(A)
-            return obj1 is obj2
-        res = self.interp_operations(f, [0])
-        assert not res
-        res = self.interp_operations(f, [1])
-        assert res
-
-    def test_oostring_instance(self):
-        A = ootype.Instance("A", ootype.ROOT)
-        B = ootype.Instance("B", ootype.ROOT)
-        def f(n):
-            obj1 = ootype.new(A)
-            obj2 = ootype.new(B)
-            s1 = ootype.oostring(obj1, -1)
-            s2 = ootype.oostring(obj2, -1)
-            ch1 = s1.ll_stritem_nonneg(1)
-            ch2 = s2.ll_stritem_nonneg(1)
-            return ord(ch1) + ord(ch2)
-        res = self.interp_operations(f, [0])
-        assert res == ord('A') + ord('B')
-
-    def test_subclassof(self):
-        A = ootype.Instance("A", ootype.ROOT)
-        B = ootype.Instance("B", A)
-        clsA = ootype.runtimeClass(A)
-        clsB = ootype.runtimeClass(B)
-        myjitdriver = JitDriver(greens = [], reds = ['n', 'flag', 'res'])
-
-        def getcls(flag):
-            if flag:
-                return clsA
-            else:
-                return clsB
-
-        def f(flag, n):
-            res = True
-            while n > -100:
-                myjitdriver.can_enter_jit(n=n, flag=flag, res=res)
-                myjitdriver.jit_merge_point(n=n, flag=flag, res=res)
-                cls = getcls(flag)
-                n -= 1
-                res = ootype.subclassof(cls, clsB)
-            return res
-
-        res = self.meta_interp(f, [1, 100],
-                               policy=StopAtXPolicy(getcls),
-                               enable_opts='')
-        assert not res
-        
-        res = self.meta_interp(f, [0, 100],
-                               policy=StopAtXPolicy(getcls),
-                               enable_opts='')
-        assert res
-
-class BaseLLtypeTests(BasicTests):
-
-    def test_identityhash(self):
-        A = lltype.GcStruct("A")
-        def f():
-            obj1 = lltype.malloc(A)
-            obj2 = lltype.malloc(A)
-            return lltype.identityhash(obj1) == lltype.identityhash(obj2)
-        assert not f()
-        res = self.interp_operations(f, [])
-        assert not res
-
-    def test_oops_on_nongc(self):
-        from pypy.rpython.lltypesystem import lltype
-        
-        TP = lltype.Struct('x')
-        def f(i1, i2):
-            p1 = prebuilt[i1]
-            p2 = prebuilt[i2]
-            a = p1 is p2
-            b = p1 is not p2
-            c = bool(p1)
-            d = not bool(p2)
-            return 1000*a + 100*b + 10*c + d
-        prebuilt = [lltype.malloc(TP, flavor='raw', immortal=True)] * 2
-        expected = f(0, 1)
-        assert self.interp_operations(f, [0, 1]) == expected
-
-    def test_casts(self):
-        py.test.skip("xxx fix or kill")
-        if not self.basic:
-            py.test.skip("test written in a style that "
-                         "means it's frontend only")
-        from pypy.rpython.lltypesystem import lltype, llmemory, rffi
-
-        TP = lltype.GcStruct('S1')
-        def f(p):
-            n = lltype.cast_ptr_to_int(p)
-            return n
-        x = lltype.malloc(TP)
-        xref = lltype.cast_opaque_ptr(llmemory.GCREF, x)
-        res = self.interp_operations(f, [xref])
-        y = llmemory.cast_ptr_to_adr(x)
-        y = llmemory.cast_adr_to_int(y)
-        assert rffi.get_real_int(res) == rffi.get_real_int(y)
-        #
-        TP = lltype.Struct('S2')
-        prebuilt = [lltype.malloc(TP, immortal=True),
-                    lltype.malloc(TP, immortal=True)]
-        def f(x):
-            p = prebuilt[x]
-            n = lltype.cast_ptr_to_int(p)
-            return n
-        res = self.interp_operations(f, [1])
-        y = llmemory.cast_ptr_to_adr(prebuilt[1])
-        y = llmemory.cast_adr_to_int(y)
-        assert rffi.get_real_int(res) == rffi.get_real_int(y)
-
-    def test_collapsing_ptr_eq(self):
-        S = lltype.GcStruct('S')
-        p = lltype.malloc(S)
-        driver = JitDriver(greens = [], reds = ['n', 'x'])
-
-        def f(n, x):
-            while n > 0:
-                driver.can_enter_jit(n=n, x=x)
-                driver.jit_merge_point(n=n, x=x)
-                if x:
-                    n -= 1
-                n -= 1
-
-        def main():
-            f(10, p)
-            f(10, lltype.nullptr(S))
-
-        self.meta_interp(main, [])
-
-    def test_enable_opts(self):
-        jitdriver = JitDriver(greens = [], reds = ['a'])
-
-        class A(object):
-            def __init__(self, i):
-                self.i = i
-
-        def f():
-            a = A(0)
-            
-            while a.i < 10:
-                jitdriver.jit_merge_point(a=a)
-                jitdriver.can_enter_jit(a=a)
-                a = A(a.i + 1)
-
-        self.meta_interp(f, [])
-        self.check_loops(new_with_vtable=0)
-        self.meta_interp(f, [], enable_opts='')
-        self.check_loops(new_with_vtable=1)
-
-class TestLLtype(BaseLLtypeTests, LLJitMixin):
-    pass

diff --git a/pypy/jit/metainterp/test/test_send.py b/pypy/jit/metainterp/test/test_send.py
--- a/pypy/jit/metainterp/test/test_send.py
+++ b/pypy/jit/metainterp/test/test_send.py
@@ -1,7 +1,7 @@
 import py
 from pypy.rlib.jit import JitDriver, hint, purefunction
 from pypy.jit.codewriter.policy import StopAtXPolicy
-from pypy.jit.metainterp.test.test_basic import LLJitMixin, OOJitMixin
+from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
 
 class SendTests(object):
     

diff --git a/pypy/jit/backend/cli/test/test_basic.py b/pypy/jit/backend/cli/test/test_basic.py
--- a/pypy/jit/backend/cli/test/test_basic.py
+++ b/pypy/jit/backend/cli/test/test_basic.py
@@ -1,14 +1,14 @@
 import py
 from pypy.jit.backend.cli.runner import CliCPU
-from pypy.jit.metainterp.test import test_basic
+from pypy.jit.metainterp.test import support, test_ajit
 
-class CliJitMixin(test_basic.OOJitMixin):
+class CliJitMixin(suport.OOJitMixin):
     CPUClass = CliCPU
     def setup_class(cls):
         from pypy.translator.cli.support import PythonNet
         PythonNet.System     # possibly raises Skip
 
-class TestBasic(CliJitMixin, test_basic.TestOOtype):
+class TestBasic(CliJitMixin, test_ajit.TestOOtype):
     # for the individual tests see
     # ====> ../../../metainterp/test/test_basic.py
 

diff --git a/pypy/jit/metainterp/test/test_dict.py b/pypy/jit/metainterp/test/test_dict.py
--- a/pypy/jit/metainterp/test/test_dict.py
+++ b/pypy/jit/metainterp/test/test_dict.py
@@ -1,5 +1,5 @@
 import py
-from pypy.jit.metainterp.test.test_basic import LLJitMixin, OOJitMixin
+from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
 from pypy.rlib.jit import JitDriver
 from pypy.rlib import objectmodel
 

diff --git a/pypy/jit/metainterp/test/test_jitprof.py b/pypy/jit/metainterp/test/test_jitprof.py
--- a/pypy/jit/metainterp/test/test_jitprof.py
+++ b/pypy/jit/metainterp/test/test_jitprof.py
@@ -1,7 +1,7 @@
 
 from pypy.jit.metainterp.warmspot import ll_meta_interp
 from pypy.rlib.jit import JitDriver, dont_look_inside, purefunction
-from pypy.jit.metainterp.test.test_basic import LLJitMixin
+from pypy.jit.metainterp.test.support import LLJitMixin
 from pypy.jit.metainterp import pyjitpl
 from pypy.jit.metainterp.jitprof import *
 

diff --git a/pypy/jit/metainterp/test/test_del.py b/pypy/jit/metainterp/test/test_del.py
--- a/pypy/jit/metainterp/test/test_del.py
+++ b/pypy/jit/metainterp/test/test_del.py
@@ -1,6 +1,6 @@
 import py
 from pypy.rlib.jit import JitDriver
-from pypy.jit.metainterp.test.test_basic import LLJitMixin, OOJitMixin
+from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
 
 
 class DelTests:

diff --git a/pypy/jit/metainterp/test/test_fficall.py b/pypy/jit/metainterp/test/test_fficall.py
--- a/pypy/jit/metainterp/test/test_fficall.py
+++ b/pypy/jit/metainterp/test/test_fficall.py
@@ -5,7 +5,7 @@
 from pypy.rlib.libffi import ArgChain
 from pypy.rlib.test.test_libffi import TestLibffiCall as _TestLibffiCall
 from pypy.rpython.lltypesystem import lltype, rffi
-from pypy.jit.metainterp.test.test_basic import LLJitMixin
+from pypy.jit.metainterp.test.support import LLJitMixin
 
 
 class TestFfiCall(LLJitMixin, _TestLibffiCall):

diff --git a/pypy/jit/tl/tla/test_tla.py b/pypy/jit/tl/tla/test_tla.py
--- a/pypy/jit/tl/tla/test_tla.py
+++ b/pypy/jit/tl/tla/test_tla.py
@@ -155,7 +155,7 @@
 
 # ____________________________________________________________
 
-from pypy.jit.metainterp.test.test_basic import LLJitMixin
+from pypy.jit.metainterp.test.support import LLJitMixin
 
 class TestLLtype(LLJitMixin):
     def test_loop(self):

diff --git a/pypy/jit/metainterp/test/test_tl.py b/pypy/jit/metainterp/test/test_tl.py
--- a/pypy/jit/metainterp/test/test_tl.py
+++ b/pypy/jit/metainterp/test/test_tl.py
@@ -1,6 +1,6 @@
 import py
 from pypy.jit.codewriter.policy import StopAtXPolicy
-from pypy.jit.metainterp.test.test_basic import OOJitMixin, LLJitMixin
+from pypy.jit.metainterp.test.support import OOJitMixin, LLJitMixin
 
 
 class ToyLanguageTests:

diff --git a/pypy/jit/metainterp/test/test_loop_unroll.py b/pypy/jit/metainterp/test/test_loop_unroll.py
--- a/pypy/jit/metainterp/test/test_loop_unroll.py
+++ b/pypy/jit/metainterp/test/test_loop_unroll.py
@@ -1,7 +1,7 @@
 import py
 from pypy.rlib.jit import JitDriver
 from pypy.jit.metainterp.test import test_loop
-from pypy.jit.metainterp.test.test_basic import LLJitMixin, OOJitMixin
+from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
 from pypy.jit.metainterp.optimizeopt import ALL_OPTS_NAMES
 
 class LoopUnrollTest(test_loop.LoopTest):

diff --git a/pypy/jit/metainterp/test/test_recursive.py b/pypy/jit/metainterp/test/test_recursive.py
--- a/pypy/jit/metainterp/test/test_recursive.py
+++ b/pypy/jit/metainterp/test/test_recursive.py
@@ -3,7 +3,7 @@
 from pypy.rlib.jit import unroll_safe, dont_look_inside
 from pypy.rlib.objectmodel import we_are_translated
 from pypy.rlib.debug import fatalerror
-from pypy.jit.metainterp.test.test_basic import LLJitMixin, OOJitMixin
+from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
 from pypy.jit.codewriter.policy import StopAtXPolicy
 from pypy.rpython.annlowlevel import hlstr
 from pypy.jit.metainterp.warmspot import get_stats

diff --git a/pypy/jit/metainterp/test/test_loop.py b/pypy/jit/metainterp/test/test_loop.py
--- a/pypy/jit/metainterp/test/test_loop.py
+++ b/pypy/jit/metainterp/test/test_loop.py
@@ -2,7 +2,7 @@
 from pypy.rlib.jit import JitDriver
 from pypy.rlib.objectmodel import compute_hash
 from pypy.jit.metainterp.warmspot import ll_meta_interp, get_stats
-from pypy.jit.metainterp.test.test_basic import LLJitMixin, OOJitMixin
+from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
 from pypy.jit.codewriter.policy import StopAtXPolicy
 from pypy.jit.metainterp.resoperation import rop
 from pypy.jit.metainterp import history

diff --git a/pypy/jit/metainterp/test/test_immutable.py b/pypy/jit/metainterp/test/test_immutable.py
--- a/pypy/jit/metainterp/test/test_immutable.py
+++ b/pypy/jit/metainterp/test/test_immutable.py
@@ -1,4 +1,4 @@
-from pypy.jit.metainterp.test.test_basic import LLJitMixin, OOJitMixin
+from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
 
 
 class ImmutableFieldsTests:

diff --git a/pypy/jit/tl/spli/test/test_jit.py b/pypy/jit/tl/spli/test/test_jit.py
--- a/pypy/jit/tl/spli/test/test_jit.py
+++ b/pypy/jit/tl/spli/test/test_jit.py
@@ -1,6 +1,6 @@
 
 import py
-from pypy.jit.metainterp.test.test_basic import JitMixin
+from pypy.jit.metainterp.test.support import JitMixin
 from pypy.jit.tl.spli import interpreter, objects, serializer
 from pypy.jit.metainterp.typesystem import LLTypeHelper, OOTypeHelper
 from pypy.jit.backend.llgraph import runner

diff --git a/pypy/jit/metainterp/test/test_memmgr.py b/pypy/jit/metainterp/test/test_memmgr.py
--- a/pypy/jit/metainterp/test/test_memmgr.py
+++ b/pypy/jit/metainterp/test/test_memmgr.py
@@ -12,7 +12,7 @@
 
 import py
 from pypy.jit.metainterp.memmgr import MemoryManager
-from pypy.jit.metainterp.test.test_basic import LLJitMixin
+from pypy.jit.metainterp.test.support import LLJitMixin
 from pypy.rlib.jit import JitDriver, dont_look_inside
 
 

diff --git a/pypy/jit/backend/x86/test/test_basic.py b/pypy/jit/backend/x86/test/test_basic.py
--- a/pypy/jit/backend/x86/test/test_basic.py
+++ b/pypy/jit/backend/x86/test/test_basic.py
@@ -1,18 +1,18 @@
 import py
 from pypy.jit.backend.detect_cpu import getcpuclass
 from pypy.jit.metainterp.warmspot import ll_meta_interp
-from pypy.jit.metainterp.test import test_basic
+from pypy.jit.metainterp.test import support, test_ajit
 from pypy.jit.codewriter.policy import StopAtXPolicy
 from pypy.rlib.jit import JitDriver
 
-class Jit386Mixin(test_basic.LLJitMixin):
+class Jit386Mixin(support.LLJitMixin):
     type_system = 'lltype'
     CPUClass = getcpuclass()
 
     def check_jumps(self, maxcount):
         pass
 
-class TestBasic(Jit386Mixin, test_basic.BaseLLtypeTests):
+class TestBasic(Jit386Mixin, test_ajit.BaseLLtypeTests):
     # for the individual tests see
     # ====> ../../../metainterp/test/test_basic.py
     def test_bug(self):

diff --git a/pypy/jit/metainterp/test/test_virtual.py b/pypy/jit/metainterp/test/test_virtual.py
--- a/pypy/jit/metainterp/test/test_virtual.py
+++ b/pypy/jit/metainterp/test/test_virtual.py
@@ -2,7 +2,7 @@
 from pypy.rlib.jit import JitDriver, hint
 from pypy.rlib.objectmodel import compute_unique_id
 from pypy.jit.codewriter.policy import StopAtXPolicy
-from pypy.jit.metainterp.test.test_basic import LLJitMixin, OOJitMixin
+from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
 from pypy.rpython.lltypesystem import lltype, rclass
 from pypy.rpython.lltypesystem.lloperation import llop
 from pypy.rpython.ootypesystem import ootype

diff --git a/pypy/jit/metainterp/test/test_float.py b/pypy/jit/metainterp/test/test_float.py
--- a/pypy/jit/metainterp/test/test_float.py
+++ b/pypy/jit/metainterp/test/test_float.py
@@ -1,5 +1,5 @@
 import math
-from pypy.jit.metainterp.test.test_basic import LLJitMixin, OOJitMixin
+from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
 
 
 class FloatTests:

diff --git a/pypy/jit/metainterp/test/test_warmspot.py b/pypy/jit/metainterp/test/test_warmspot.py
--- a/pypy/jit/metainterp/test/test_warmspot.py
+++ b/pypy/jit/metainterp/test/test_warmspot.py
@@ -6,7 +6,7 @@
 from pypy.jit.backend.llgraph import runner
 from pypy.jit.metainterp.history import BoxInt
 
-from pypy.jit.metainterp.test.test_basic import LLJitMixin, OOJitMixin
+from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
 from pypy.jit.metainterp.optimizeopt import ALL_OPTS_NAMES
 
 

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
@@ -1,6 +1,6 @@
 import py
 from pypy.rlib.jit import JitDriver
-from pypy.jit.metainterp.test.test_basic import LLJitMixin, OOJitMixin
+from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
 from pypy.jit.metainterp.blackhole import BlackholeInterpBuilder
 from pypy.jit.metainterp.blackhole import BlackholeInterpreter
 from pypy.jit.metainterp.blackhole import convert_and_run_from_pyjitpl

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
@@ -3,7 +3,7 @@
 from pypy.rlib.jit import JitDriver, dont_look_inside, vref_None
 from pypy.rlib.jit import virtual_ref, virtual_ref_finish
 from pypy.rlib.objectmodel import compute_unique_id
-from pypy.jit.metainterp.test.test_basic import LLJitMixin, OOJitMixin
+from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
 from pypy.jit.metainterp.resoperation import rop
 from pypy.jit.metainterp.virtualref import VirtualRefInfo
 

diff --git a/pypy/jit/metainterp/test/test_string.py b/pypy/jit/metainterp/test/test_string.py
--- a/pypy/jit/metainterp/test/test_string.py
+++ b/pypy/jit/metainterp/test/test_string.py
@@ -2,7 +2,7 @@
 from pypy.rlib.jit import JitDriver, dont_look_inside, we_are_jitted
 from pypy.jit.codewriter.policy import StopAtXPolicy
 from pypy.rpython.ootypesystem import ootype
-from pypy.jit.metainterp.test.test_basic import LLJitMixin, OOJitMixin
+from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
 
 
 class StringTests:

diff --git a/pypy/jit/metainterp/test/test_tlc.py b/pypy/jit/metainterp/test/test_tlc.py
--- a/pypy/jit/metainterp/test/test_tlc.py
+++ b/pypy/jit/metainterp/test/test_tlc.py
@@ -3,7 +3,7 @@
 
 from pypy.jit.tl import tlc
 
-from pypy.jit.metainterp.test.test_basic import OOJitMixin, LLJitMixin
+from pypy.jit.metainterp.test.support import OOJitMixin, LLJitMixin
 
 
 class TLCTests:

diff --git a/pypy/jit/metainterp/test/test_greenfield.py b/pypy/jit/metainterp/test/test_greenfield.py
--- a/pypy/jit/metainterp/test/test_greenfield.py
+++ b/pypy/jit/metainterp/test/test_greenfield.py
@@ -1,4 +1,4 @@
-from pypy.jit.metainterp.test.test_basic import LLJitMixin, OOJitMixin
+from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
 from pypy.rlib.jit import JitDriver
 
 

diff --git a/pypy/jit/metainterp/test/test_slist.py b/pypy/jit/metainterp/test/test_slist.py
--- a/pypy/jit/metainterp/test/test_slist.py
+++ b/pypy/jit/metainterp/test/test_slist.py
@@ -1,5 +1,5 @@
 import py
-from pypy.jit.metainterp.test.test_basic import LLJitMixin, OOJitMixin
+from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
 from pypy.rlib.jit import JitDriver
 
 class ListTests(object):

diff --git a/pypy/jit/metainterp/test/test_exception.py b/pypy/jit/metainterp/test/test_exception.py
--- a/pypy/jit/metainterp/test/test_exception.py
+++ b/pypy/jit/metainterp/test/test_exception.py
@@ -1,5 +1,5 @@
 import py, sys
-from pypy.jit.metainterp.test.test_basic import LLJitMixin, OOJitMixin
+from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
 from pypy.rlib.jit import JitDriver, dont_look_inside
 from pypy.rlib.rarithmetic import ovfcheck, LONG_BIT, intmask
 from pypy.jit.codewriter.policy import StopAtXPolicy


More information about the Pypy-commit mailing list