[pypy-commit] pypy cleanup-llgraph-backend: (fijal, arigo) remove the old llgraph backend

fijal noreply at buildbot.pypy.org
Thu Oct 18 10:48:16 CEST 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: cleanup-llgraph-backend
Changeset: r58197:e49874fae436
Date: 2012-10-18 10:47 +0200
http://bitbucket.org/pypy/pypy/changeset/e49874fae436/

Log:	(fijal, arigo) remove the old llgraph backend

diff too long, truncating to 2000 out of 2922 lines

diff --git a/pypy/jit/backend/llgraph/+runner.py b/pypy/jit/backend/llgraph/+runner.py
deleted file mode 100644
--- a/pypy/jit/backend/llgraph/+runner.py
+++ /dev/null
@@ -1,912 +0,0 @@
-"""
-Minimal-API wrapper around the llinterpreter to run operations.
-"""
-
-from pypy.rlib.unroll import unrolling_iterable
-from pypy.rlib.objectmodel import we_are_translated
-from pypy.rlib.jit_hooks import LOOP_RUN_CONTAINER
-from pypy.rpython.lltypesystem import lltype, llmemory, rclass
-from pypy.rpython.ootypesystem import ootype
-from pypy.rpython.llinterp import LLInterpreter
-from pypy.jit.metainterp import history
-from pypy.jit.metainterp.history import REF, INT, FLOAT, STRUCT
-from pypy.jit.metainterp.warmstate import unwrap
-from pypy.jit.metainterp.resoperation import rop
-from pypy.jit.backend import model
-from pypy.jit.backend.llgraph import llimpl, symbolic
-from pypy.jit.metainterp.typesystem import llhelper, oohelper
-from pypy.jit.codewriter import heaptracker, longlong
-
-class MiniStats:
-    pass
-
-
-class Descr(history.AbstractDescr):
-
-    def __init__(self, ofs, typeinfo, extrainfo=None, name=None,
-                 arg_types=None, count_fields_if_immut=-1, ffi_flags=0, width=-1):
-
-        self.ofs = ofs
-        self.width = width
-        self.typeinfo = typeinfo
-        self.extrainfo = extrainfo
-        self.name = name
-        self.arg_types = arg_types
-        self.count_fields_if_immut = count_fields_if_immut
-        self.ffi_flags = ffi_flags
-        self._debug = False
-
-    def set_debug(self, v):
-        self._debug = True
-
-    def get_arg_types(self):
-        return self.arg_types
-
-    def get_result_type(self):
-        return self.typeinfo
-
-    def get_extra_info(self):
-        return self.extrainfo
-
-    def sort_key(self):
-        """Returns an integer that can be used as a key when sorting the
-        field descrs of a single structure.  The property that this
-        number has is simply that two different field descrs of the same
-        structure give different numbers."""
-        return self.ofs
-
-    def is_pointer_field(self):
-        return self.typeinfo == REF
-
-    def is_float_field(self):
-        return self.typeinfo == FLOAT
-
-    def is_array_of_pointers(self):
-        return self.typeinfo == REF
-
-    def is_array_of_floats(self):
-        return self.typeinfo == FLOAT
-
-    def is_array_of_structs(self):
-        return self.typeinfo == STRUCT
-
-    def as_vtable_size_descr(self):
-        return self
-
-    def count_fields_if_immutable(self):
-        return self.count_fields_if_immut
-
-    def get_ffi_flags(self):
-        return self.ffi_flags
-
-    def __lt__(self, other):
-        raise TypeError("cannot use comparison on Descrs")
-    def __le__(self, other):
-        raise TypeError("cannot use comparison on Descrs")
-    def __gt__(self, other):
-        raise TypeError("cannot use comparison on Descrs")
-    def __ge__(self, other):
-        raise TypeError("cannot use comparison on Descrs")
-
-    def __repr__(self):
-        args = [repr(self.ofs), repr(self.typeinfo)]
-        if self.name is not None:
-            args.append(repr(self.name))
-        if self.extrainfo is not None:
-            args.append('E')
-        return '<Descr %r>' % (', '.join(args),)
-
-
-history.TreeLoop._compiled_version = lltype.nullptr(llimpl.COMPILEDLOOP.TO)
-
-
-class BaseCPU(model.AbstractCPU):
-    supports_floats = True
-    supports_longlong = llimpl.IS_32_BIT
-    supports_singlefloats = True
-
-    def __init__(self, rtyper, stats=None, opts=None,
-                 translate_support_code=False,
-                 annmixlevel=None, gcdescr=None):
-        assert type(opts) is not bool
-        model.AbstractCPU.__init__(self)
-        self.rtyper = rtyper
-        self.translate_support_code = translate_support_code
-        self.stats = stats or MiniStats()
-        self.stats.exec_counters = {}
-        self.stats.exec_jumps = 0
-        self.stats.exec_conditional_jumps = 0
-        llimpl._stats = self.stats
-        llimpl._llinterp = LLInterpreter(self.rtyper)
-        self._future_values = []
-        self._descrs = {}
-
-    def _cleanup_(self):
-        assert self.translate_support_code
-
-    def getdescr(self, ofs, typeinfo='?', extrainfo=None, name=None,
-                 arg_types=None, count_fields_if_immut=-1, ffi_flags=0, width=-1):
-        key = (ofs, typeinfo, extrainfo, name, arg_types,
-               count_fields_if_immut, ffi_flags, width)
-        try:
-            return self._descrs[key]
-        except KeyError:
-            descr = Descr(ofs, typeinfo, extrainfo, name, arg_types,
-                          count_fields_if_immut, ffi_flags, width)
-            self._descrs[key] = descr
-            return descr
-
-    def compile_bridge(self, faildescr, inputargs, operations,
-                       original_loop_token, log=True):
-        c = llimpl.compile_start()
-        clt = original_loop_token.compiled_loop_token
-        clt.loop_and_bridges.append(c)
-        clt.compiling_a_bridge()
-        self._compile_loop_or_bridge(c, inputargs, operations, clt)
-        old, oldindex = faildescr._compiled_fail
-        llimpl.compile_redirect_fail(old, oldindex, c)
-
-    def compile_loop(self, inputargs, operations, jitcell_token,
-                     log=True, name=''):
-        """In a real assembler backend, this should assemble the given
-        list of operations.  Here we just generate a similar CompiledLoop
-        instance.  The code here is RPython, whereas the code in llimpl
-        is not.
-        """
-        c = llimpl.compile_start()
-        clt = model.CompiledLoopToken(self, jitcell_token.number)
-        clt.loop_and_bridges = [c]
-        clt.compiled_version = c
-        jitcell_token.compiled_loop_token = clt
-        self._compile_loop_or_bridge(c, inputargs, operations, clt)
-
-    def free_loop_and_bridges(self, compiled_loop_token):
-        for c in compiled_loop_token.loop_and_bridges:
-            llimpl.mark_as_free(c)
-        model.AbstractCPU.free_loop_and_bridges(self, compiled_loop_token)
-
-    def _compile_loop_or_bridge(self, c, inputargs, operations, clt):
-        var2index = {}
-        for box in inputargs:
-            if isinstance(box, history.BoxInt):
-                var2index[box] = llimpl.compile_start_int_var(c)
-            elif isinstance(box, self.ts.BoxRef):
-                TYPE = self.ts.BASETYPE
-                var2index[box] = llimpl.compile_start_ref_var(c, TYPE)
-            elif isinstance(box, history.BoxFloat):
-                var2index[box] = llimpl.compile_start_float_var(c)
-            else:
-                raise Exception("box is: %r" % (box,))
-        llimpl.compile_started_vars(clt)
-        self._compile_operations(c, operations, var2index, clt)
-        return c
-
-    def _compile_operations(self, c, operations, var2index, clt):
-        for op in operations:
-            if op.getopnum() == -124: # force_spill
-                continue
-            llimpl.compile_add(c, op.getopnum())
-            descr = op.getdescr()
-            if isinstance(descr, Descr):
-                llimpl.compile_add_descr(c, descr.ofs, descr.typeinfo,
-                                         descr.arg_types, descr.extrainfo,
-                                         descr.width)
-            if isinstance(descr, history.JitCellToken):
-                assert op.getopnum() != rop.JUMP
-                llimpl.compile_add_loop_token(c, descr)
-            if isinstance(descr, history.TargetToken) and op.getopnum() == rop.LABEL:
-                llimpl.compile_add_target_token(c, descr, clt)
-            if self.is_oo and isinstance(descr, (OODescr, MethDescr)):
-                # hack hack, not rpython
-                c._obj.externalobj.operations[-1].setdescr(descr)
-            for i in range(op.numargs()):
-                x = op.getarg(i)
-                if isinstance(x, history.Box):
-                    llimpl.compile_add_var(c, var2index[x])
-                elif isinstance(x, history.ConstInt):
-                    llimpl.compile_add_int_const(c, x.value)
-                elif isinstance(x, self.ts.ConstRef):
-                    llimpl.compile_add_ref_const(c, x.value, self.ts.BASETYPE)
-                elif isinstance(x, history.ConstFloat):
-                    llimpl.compile_add_float_const(c, x.value)
-                elif isinstance(x, Descr):
-                    llimpl.compile_add_descr_arg(c, x.ofs, x.typeinfo,
-                                                 x.arg_types)
-                else:
-                    raise Exception("'%s' args contain: %r" % (op.getopname(),
-                                                               x))
-            if op.is_guard():
-                faildescr = op.getdescr()
-                assert isinstance(faildescr, history.AbstractFailDescr)
-                faildescr._fail_args_types = []
-                for box in op.getfailargs():
-                    if box is None:
-                        type = history.HOLE
-                    else:
-                        type = box.type
-                    faildescr._fail_args_types.append(type)
-                fail_index = self.get_fail_descr_number(faildescr)
-                index = llimpl.compile_add_fail(c, fail_index)
-                faildescr._compiled_fail = c, index
-                for box in op.getfailargs():
-                    if box is not None:
-                        llimpl.compile_add_fail_arg(c, var2index[box])
-                    else:
-                        llimpl.compile_add_fail_arg(c, -1)
-
-            x = op.result
-            if x is not None:
-                if isinstance(x, history.BoxInt):
-                    var2index[x] = llimpl.compile_add_int_result(c)
-                elif isinstance(x, self.ts.BoxRef):
-                    var2index[x] = llimpl.compile_add_ref_result(c, self.ts.BASETYPE)
-                elif isinstance(x, history.BoxFloat):
-                    var2index[x] = llimpl.compile_add_float_result(c)
-                else:
-                    raise Exception("%s.result contain: %r" % (op.getopname(),
-                                                               x))
-        op = operations[-1]
-        assert op.is_final()
-        if op.getopnum() == rop.JUMP:
-            targettoken = op.getdescr()
-            llimpl.compile_add_jump_target(c, targettoken, clt)
-        elif op.getopnum() == rop.FINISH:
-            faildescr = op.getdescr()
-            index = self.get_fail_descr_number(faildescr)
-            llimpl.compile_add_fail(c, index)
-        else:
-            assert False, "unknown operation"
-
-    def _execute_token(self, loop_token):
-        compiled_version = loop_token.compiled_loop_token.compiled_version
-        frame = llimpl.new_frame(self.is_oo, self)
-        # setup the frame
-        llimpl.frame_clear(frame, compiled_version)
-        # run the loop
-        fail_index = llimpl.frame_execute(frame)
-        # we hit a FAIL operation.
-        self.latest_frame = frame
-        return fail_index
-
-    def make_execute_token(self, *argtypes):
-        nb_args = len(argtypes)
-        unroll_argtypes = unrolling_iterable(list(enumerate(argtypes)))
-        #
-        def execute_token(loop_token, *args):
-            assert len(args) == nb_args
-            for index, TYPE in unroll_argtypes:
-                x = args[index]
-                assert TYPE == lltype.typeOf(x)
-                if TYPE == lltype.Signed:
-                    llimpl.set_future_value_int(index, x)
-                elif TYPE == llmemory.GCREF:
-                    llimpl.set_future_value_ref(index, x)
-                elif TYPE == longlong.FLOATSTORAGE:
-                    llimpl.set_future_value_float(index, x)
-                else:
-                    assert 0
-            #
-            fail_index = self._execute_token(loop_token)
-            return self.get_fail_descr_from_number(fail_index)
-        #
-        return execute_token
-
-    def get_latest_value_int(self, index):
-        return llimpl.frame_int_getvalue(self.latest_frame, index)
-
-    def get_latest_value_ref(self, index):
-        return llimpl.frame_ptr_getvalue(self.latest_frame, index)
-
-    def get_latest_value_float(self, index):
-        return llimpl.frame_float_getvalue(self.latest_frame, index)
-
-    def get_latest_value_count(self):
-        return llimpl.frame_get_value_count(self.latest_frame)
-
-    def get_latest_force_token(self):
-        token = llimpl.get_frame_forced_token(self.latest_frame)
-        return heaptracker.adr2int(token)
-
-    def clear_latest_values(self, count):
-        llimpl.frame_clear_latest_values(self.latest_frame, count)
-
-    def redirect_call_assembler(self, oldlooptoken, newlooptoken):
-        if we_are_translated():
-            raise ValueError("CALL_ASSEMBLER not supported")
-        llimpl.redirect_call_assembler(self, oldlooptoken, newlooptoken)
-
-    def invalidate_loop(self, looptoken):
-        for loop in looptoken.compiled_loop_token.loop_and_bridges:
-            loop._obj.externalobj.invalid = True
-
-    # ----------
-
-    def sizeof(self, S):
-        assert not isinstance(S, lltype.Ptr)
-        count = heaptracker.count_fields_if_immutable(S)
-        return self.getdescr(symbolic.get_size(S), count_fields_if_immut=count)
-
-
-class LLtypeCPU(BaseCPU):
-    is_oo = False
-    ts = llhelper
-
-    def __init__(self, *args, **kwds):
-        BaseCPU.__init__(self, *args, **kwds)
-        self.fielddescrof_vtable = self.fielddescrof(rclass.OBJECT, 'typeptr')
-
-    def fielddescrof(self, S, fieldname):
-        ofs, size = symbolic.get_field_token(S, fieldname)
-        token = history.getkind(getattr(S, fieldname))
-        return self.getdescr(ofs, token[0], name=fieldname)
-
-    def interiorfielddescrof(self, A, fieldname):
-        S = A.OF
-        width = symbolic.get_size(A)
-        ofs, size = symbolic.get_field_token(S, fieldname)
-        token = history.getkind(getattr(S, fieldname))
-        return self.getdescr(ofs, token[0], name=fieldname, width=width)
-
-    def calldescrof(self, FUNC, ARGS, RESULT, extrainfo):
-        arg_types = []
-        for ARG in ARGS:
-            token = history.getkind(ARG)
-            if token != 'void':
-                if token == 'float' and longlong.is_longlong(ARG):
-                    token = 'L'
-                arg_types.append(token[0])
-        token = history.getkind(RESULT)
-        if token == 'float' and longlong.is_longlong(RESULT):
-            token = 'L'
-        return self.getdescr(0, token[0], extrainfo=extrainfo,
-                             arg_types=''.join(arg_types))
-
-    def calldescrof_dynamic(self, cif_description, extrainfo):
-        from pypy.jit.backend.llsupport.ffisupport import get_ffi_type_kind
-        from pypy.jit.backend.llsupport.ffisupport import UnsupportedKind
-        arg_types = []
-        try:
-            for itp in range(cif_description.nargs):
-                arg = cif_description.atypes[itp]
-                kind = get_ffi_type_kind(self, arg)
-                if kind != history.VOID:
-                    arg_types.append(kind)
-            reskind = get_ffi_type_kind(self, cif_description.rtype)
-        except UnsupportedKind:
-            return None
-        return self.getdescr(0, reskind, extrainfo=extrainfo,
-                             arg_types=''.join(arg_types),
-                             ffi_flags=cif_description.abi)
-
-    def _calldescr_dynamic_for_tests(self, atypes, rtype,
-                                     abiname='FFI_DEFAULT_ABI'):
-        from pypy.jit.backend.llsupport import ffisupport
-        return ffisupport.calldescr_dynamic_for_tests(self, atypes, rtype,
-                                                      abiname)
-
-    def grab_exc_value(self):
-        return llimpl.grab_exc_value()
-
-    def arraydescrof(self, A):
-        assert A.OF != lltype.Void
-        assert isinstance(A, lltype.GcArray) or A._hints.get('nolength', False)
-        size = symbolic.get_size(A)
-        if isinstance(A.OF, lltype.Ptr) or isinstance(A.OF, lltype.Primitive):
-            token = history.getkind(A.OF)[0]
-        elif isinstance(A.OF, lltype.Struct):
-            token = 's'
-        else:
-            token = '?'
-        return self.getdescr(size, token)
-
-    # ---------- the backend-dependent operations ----------
-
-    def bh_strlen(self, string):
-        return llimpl.do_strlen(string)
-
-    def bh_strgetitem(self, string, index):
-        return llimpl.do_strgetitem(string, index)
-
-    def bh_unicodelen(self, string):
-        return llimpl.do_unicodelen(string)
-
-    def bh_unicodegetitem(self, string, index):
-        return llimpl.do_unicodegetitem(string, index)
-
-    def bh_getarrayitem_gc_i(self, arraydescr, array, index):
-        assert isinstance(arraydescr, Descr)
-        return llimpl.do_getarrayitem_gc_int(array, index)
-    def bh_getarrayitem_raw_i(self, arraydescr, array, index):
-        assert isinstance(arraydescr, Descr)
-        return llimpl.do_getarrayitem_raw_int(array, index, arraydescr.ofs)
-    def bh_getarrayitem_gc_r(self, arraydescr, array, index):
-        assert isinstance(arraydescr, Descr)
-        return llimpl.do_getarrayitem_gc_ptr(array, index)
-    def bh_getarrayitem_gc_f(self, arraydescr, array, index):
-        assert isinstance(arraydescr, Descr)
-        return llimpl.do_getarrayitem_gc_float(array, index)
-    def bh_getarrayitem_raw_f(self, arraydescr, array, index):
-        assert isinstance(arraydescr, Descr)
-        return llimpl.do_getarrayitem_raw_float(array, index)
-
-    def bh_getfield_gc_i(self, struct, fielddescr):
-        assert isinstance(fielddescr, Descr)
-        return llimpl.do_getfield_gc_int(struct, fielddescr.ofs)
-    def bh_getfield_gc_r(self, struct, fielddescr):
-        assert isinstance(fielddescr, Descr)
-        return llimpl.do_getfield_gc_ptr(struct, fielddescr.ofs)
-    def bh_getfield_gc_f(self, struct, fielddescr):
-        assert isinstance(fielddescr, Descr)
-        return llimpl.do_getfield_gc_float(struct, fielddescr.ofs)
-
-    def bh_getfield_raw_i(self, struct, fielddescr):
-        assert isinstance(fielddescr, Descr)
-        return llimpl.do_getfield_raw_int(struct, fielddescr.ofs)
-    def bh_getfield_raw_r(self, struct, fielddescr):
-        assert isinstance(fielddescr, Descr)
-        return llimpl.do_getfield_raw_ptr(struct, fielddescr.ofs)
-    def bh_getfield_raw_f(self, struct, fielddescr):
-        assert isinstance(fielddescr, Descr)
-        return llimpl.do_getfield_raw_float(struct, fielddescr.ofs)
-
-    def bh_getinteriorfield_gc_i(self, array, index, descr):
-        assert isinstance(descr, Descr)
-        return llimpl.do_getinteriorfield_gc_int(array, index, descr.ofs)
-    def bh_getinteriorfield_gc_r(self, array, index, descr):
-        assert isinstance(descr, Descr)
-        return llimpl.do_getinteriorfield_gc_ptr(array, index, descr.ofs)
-    def bh_getinteriorfield_gc_f(self, array, index, descr):
-        assert isinstance(descr, Descr)
-        return llimpl.do_getinteriorfield_gc_float(array, index, descr.ofs)
-
-    def bh_setinteriorfield_gc_i(self, array, index, descr, value):
-        assert isinstance(descr, Descr)
-        return llimpl.do_setinteriorfield_gc_int(array, index, descr.ofs,
-                                                 value)
-    def bh_setinteriorfield_gc_r(self, array, index, descr, value):
-        assert isinstance(descr, Descr)
-        return llimpl.do_setinteriorfield_gc_ptr(array, index, descr.ofs,
-                                                 value)
-    def bh_setinteriorfield_gc_f(self, array, index, descr, value):
-        assert isinstance(descr, Descr)
-        return llimpl.do_setinteriorfield_gc_float(array, index, descr.ofs,
-                                                   value)
-
-    def bh_raw_store_i(self, struct, offset, descr, newvalue):
-        assert isinstance(descr, Descr)
-        return llimpl.do_raw_store_int(struct, offset, descr.ofs, newvalue)
-    def bh_raw_store_f(self, struct, offset, descr, newvalue):
-        assert isinstance(descr, Descr)
-        return llimpl.do_raw_store_float(struct, offset, newvalue)
-    def bh_raw_load_i(self, struct, offset, descr):
-        assert isinstance(descr, Descr)
-        return llimpl.do_raw_load_int(struct, offset, descr.ofs)
-    def bh_raw_load_f(self, struct, offset, descr):
-        assert isinstance(descr, Descr)
-        return llimpl.do_raw_load_float(struct, offset)
-
-    def bh_new(self, sizedescr):
-        assert isinstance(sizedescr, Descr)
-        return llimpl.do_new(sizedescr.ofs)
-
-    def bh_new_with_vtable(self, sizedescr, vtable):
-        assert isinstance(sizedescr, Descr)
-        result = llimpl.do_new(sizedescr.ofs)
-        llimpl.do_setfield_gc_int(result, self.fielddescrof_vtable.ofs, vtable)
-        return result
-
-    def bh_classof(self, struct):
-        struct = lltype.cast_opaque_ptr(rclass.OBJECTPTR, struct)
-        result_adr = llmemory.cast_ptr_to_adr(struct.typeptr)
-        return heaptracker.adr2int(result_adr)
-
-    def bh_new_array(self, arraydescr, length):
-        assert isinstance(arraydescr, Descr)
-        return llimpl.do_new_array(arraydescr.ofs, length)
-
-    def bh_arraylen_gc(self, arraydescr, array):
-        assert isinstance(arraydescr, Descr)
-        return llimpl.do_arraylen_gc(arraydescr, array)
-
-    def bh_setarrayitem_gc_i(self, arraydescr, array, index, newvalue):
-        assert isinstance(arraydescr, Descr)
-        llimpl.do_setarrayitem_gc_int(array, index, newvalue)
-
-    def bh_setarrayitem_raw_i(self, arraydescr, array, index, newvalue):
-        assert isinstance(arraydescr, Descr)
-        llimpl.do_setarrayitem_raw_int(array, index, newvalue, arraydescr.ofs)
-
-    def bh_setarrayitem_gc_r(self, arraydescr, array, index, newvalue):
-        assert isinstance(arraydescr, Descr)
-        llimpl.do_setarrayitem_gc_ptr(array, index, newvalue)
-
-    def bh_setarrayitem_gc_f(self, arraydescr, array, index, newvalue):
-        assert isinstance(arraydescr, Descr)
-        llimpl.do_setarrayitem_gc_float(array, index, newvalue)
-
-    def bh_setarrayitem_raw_f(self, arraydescr, array, index, newvalue):
-        assert isinstance(arraydescr, Descr)
-        llimpl.do_setarrayitem_raw_float(array, index, newvalue)
-
-    def bh_setfield_gc_i(self, struct, fielddescr, newvalue):
-        assert isinstance(fielddescr, Descr)
-        llimpl.do_setfield_gc_int(struct, fielddescr.ofs, newvalue)
-    def bh_setfield_gc_r(self, struct, fielddescr, newvalue):
-        assert isinstance(fielddescr, Descr)
-        llimpl.do_setfield_gc_ptr(struct, fielddescr.ofs, newvalue)
-    def bh_setfield_gc_f(self, struct, fielddescr, newvalue):
-        assert isinstance(fielddescr, Descr)
-        llimpl.do_setfield_gc_float(struct, fielddescr.ofs, newvalue)
-
-    def bh_setfield_raw_i(self, struct, fielddescr, newvalue):
-        assert isinstance(fielddescr, Descr)
-        llimpl.do_setfield_raw_int(struct, fielddescr.ofs, newvalue)
-    def bh_setfield_raw_r(self, struct, fielddescr, newvalue):
-        assert isinstance(fielddescr, Descr)
-        llimpl.do_setfield_raw_ptr(struct, fielddescr.ofs, newvalue)
-    def bh_setfield_raw_f(self, struct, fielddescr, newvalue):
-        assert isinstance(fielddescr, Descr)
-        llimpl.do_setfield_raw_float(struct, fielddescr.ofs, newvalue)
-
-    def bh_newstr(self, length):
-        return llimpl.do_newstr(length)
-
-    def bh_newunicode(self, length):
-        return llimpl.do_newunicode(length)
-
-    def bh_strsetitem(self, string, index, newvalue):
-        llimpl.do_strsetitem(string, index, newvalue)
-
-    def bh_unicodesetitem(self, string, index, newvalue):
-        llimpl.do_unicodesetitem(string, index, newvalue)
-
-    def bh_call_i(self, func, calldescr, args_i, args_r, args_f):
-        self._prepare_call(INT, calldescr, args_i, args_r, args_f)
-        return llimpl.do_call_int(func)
-    def bh_call_r(self, func, calldescr, args_i, args_r, args_f):
-        self._prepare_call(REF, calldescr, args_i, args_r, args_f)
-        return llimpl.do_call_ptr(func)
-    def bh_call_f(self, func, calldescr, args_i, args_r, args_f):
-        self._prepare_call(FLOAT + 'L', calldescr, args_i, args_r, args_f)
-        return llimpl.do_call_float(func)
-    def bh_call_v(self, func, calldescr, args_i, args_r, args_f):
-        self._prepare_call('v', calldescr, args_i, args_r, args_f)
-        llimpl.do_call_void(func)
-
-    def _prepare_call(self, resulttypeinfo, calldescr, args_i, args_r, args_f):
-        assert isinstance(calldescr, Descr)
-        assert calldescr.typeinfo in resulttypeinfo
-        if args_i is not None:
-            for x in args_i:
-                llimpl.do_call_pushint(x)
-        if args_r is not None:
-            for x in args_r:
-                llimpl.do_call_pushptr(x)
-        if args_f is not None:
-            for x in args_f:
-                llimpl.do_call_pushfloat(x)
-
-    def get_all_loop_runs(self):
-        return lltype.malloc(LOOP_RUN_CONTAINER, 0)
-
-    def force(self, force_token):
-        token = llmemory.cast_int_to_adr(force_token)
-        frame = llimpl.get_forced_token_frame(token)
-        fail_index = llimpl.force(frame)
-        self.latest_frame = frame
-        return self.get_fail_descr_from_number(fail_index)
-
-
-class OOtypeCPU_xxx_disabled(BaseCPU):
-    is_oo = True
-    ts = oohelper
-
-    @staticmethod
-    def fielddescrof(T, fieldname):
-        # use class where the field is really defined as a key
-        T1, _ = T._lookup_field(fieldname)
-        return FieldDescr.new(T1, fieldname)
-
-    @staticmethod
-    def calldescrof(FUNC, ARGS, RESULT, extrainfo):
-        return StaticMethDescr.new(FUNC, ARGS, RESULT, extrainfo)
-
-    @staticmethod
-    def methdescrof(SELFTYPE, methname):
-        return MethDescr.new(SELFTYPE, methname)
-
-    @staticmethod
-    def typedescrof(TYPE):
-        return TypeDescr.new(TYPE)
-
-    @staticmethod
-    def arraydescrof(A):
-        assert isinstance(A, ootype.Array)
-        TYPE = A.ITEM
-        return TypeDescr.new(TYPE)
-
-    def typedescr2classbox(self, descr):
-        assert isinstance(descr, TypeDescr)
-        return history.ConstObj(ootype.cast_to_object(
-                            ootype.runtimeClass(descr.TYPE)))
-
-    def get_exception(self):
-        if llimpl._last_exception:
-            e = llimpl._last_exception.args[0]
-            return ootype.cast_to_object(e)
-        else:
-            return ootype.NULL
-
-    def get_exc_value(self):
-        if llimpl._last_exception:
-            earg = llimpl._last_exception.args[1]
-            return ootype.cast_to_object(earg)
-        else:
-            return ootype.NULL
-
-    def get_overflow_error(self):
-        ll_err = llimpl._get_error(OverflowError)
-        return (ootype.cast_to_object(ll_err.args[0]),
-                ootype.cast_to_object(ll_err.args[1]))
-
-    def get_zero_division_error(self):
-        ll_err = llimpl._get_error(ZeroDivisionError)
-        return (ootype.cast_to_object(ll_err.args[0]),
-                ootype.cast_to_object(ll_err.args[1]))
-
-    def do_new_with_vtable(self, clsbox):
-        cls = clsbox.getref_base()
-        typedescr = self.class_sizes[cls]
-        return typedescr.create()
-
-    def do_new_array(self, lengthbox, typedescr):
-        assert isinstance(typedescr, TypeDescr)
-        return typedescr.create_array(lengthbox)
-
-    def do_new(self, typedescr):
-        assert isinstance(typedescr, TypeDescr)
-        return typedescr.create()
-
-    def do_runtimenew(self, classbox):
-        "NOT_RPYTHON"
-        classobj = classbox.getref(ootype.Class)
-        res = ootype.runtimenew(classobj)
-        return history.BoxObj(ootype.cast_to_object(res))
-
-    def do_instanceof(self, box1, typedescr):
-        assert isinstance(typedescr, TypeDescr)
-        return typedescr.instanceof(box1)
-
-    def do_getfield_gc(self, box1, fielddescr):
-        assert isinstance(fielddescr, FieldDescr)
-        return fielddescr.getfield(box1)
-
-    def do_setfield_gc(self, box1, box2, fielddescr):
-        assert isinstance(fielddescr, FieldDescr)
-        return fielddescr.setfield(box1, box2)
-
-    def do_getarrayitem_gc(self, box1, box2, typedescr):
-        assert isinstance(typedescr, TypeDescr)
-        return typedescr.getarrayitem(box1, box2)
-
-    def do_setarrayitem_gc(self, box1, box2, box3, typedescr):
-        assert isinstance(typedescr, TypeDescr)
-        return typedescr.setarrayitem(box1, box2, box3)
-
-    def do_arraylen_gc(self, box1, typedescr):
-        assert isinstance(typedescr, TypeDescr)
-        return typedescr.getarraylength(box1)
-
-    def do_call_XXX(self, args, descr):
-        assert isinstance(descr, StaticMethDescr)
-        funcbox = args[0]
-        argboxes = args[1:]
-        x = descr.callfunc(funcbox, argboxes)
-        # XXX: return None if RESULT is Void
-        return x
-
-    def do_oosend(self, args, descr):
-        assert isinstance(descr, MethDescr)
-        selfbox = args[0]
-        argboxes = args[1:]
-        x = descr.callmeth(selfbox, argboxes)
-        # XXX: return None if METH.RESULT is Void
-        return x
-
-
-def make_getargs(ARGS):
-    argsiter = unrolling_iterable(ARGS)
-    args_n = len([ARG for ARG in ARGS if ARG is not ootype.Void])
-    def getargs(argboxes):
-        funcargs = ()
-        assert len(argboxes) == args_n
-        i = 0
-        for ARG in argsiter:
-            if ARG is ootype.Void:
-                funcargs += (None,)
-            else:
-                box = argboxes[i]
-                i+=1
-                funcargs += (unwrap(ARG, box),)
-        return funcargs
-    return getargs
-
-def boxresult(RESULT, result):
-    if isinstance(RESULT, ootype.OOType):
-        return history.BoxObj(ootype.cast_to_object(result))
-    elif RESULT is lltype.Float:
-        return history.BoxFloat(result)
-    else:
-        return history.BoxInt(lltype.cast_primitive(ootype.Signed, result))
-boxresult._annspecialcase_ = 'specialize:arg(0)'
-
-
-class KeyManager(object):
-    """
-    Helper class to convert arbitrary dictionary keys to integers.
-    """
-
-    def __init__(self):
-        self.keys = {}
-
-    def getkey(self, key):
-        try:
-            return self.keys[key]
-        except KeyError:
-            n = len(self.keys)
-            self.keys[key] = n
-            return n
-
-    def _freeze_(self):
-        raise Exception("KeyManager is not supposed to be turned into a pbc")
-
-
-descr_cache = {}
-class OODescr(history.AbstractDescr):
-
-    @classmethod
-    def new(cls, *args):
-        'NOT_RPYTHON'
-        key = (cls, args)
-        try:
-            return descr_cache[key]
-        except KeyError:
-            res = cls(*args)
-            descr_cache[key] = res
-            return res
-
-class StaticMethDescr(OODescr):
-
-    def __init__(self, FUNC, ARGS, RESULT, extrainfo=None):
-        self.FUNC = FUNC
-        getargs = make_getargs(FUNC.ARGS)
-        def callfunc(funcbox, argboxes):
-            funcobj = funcbox.getref(FUNC)
-            funcargs = getargs(argboxes)
-            res = llimpl.call_maybe_on_top_of_llinterp(funcobj, funcargs)
-            if RESULT is not ootype.Void:
-                return boxresult(RESULT, res)
-        self.callfunc = callfunc
-        self.extrainfo = extrainfo
-
-    def get_extra_info(self):
-        return self.extrainfo
-
-class MethDescr(history.AbstractMethDescr):
-
-    callmeth = None
-
-    new = classmethod(OODescr.new.im_func)
-
-    def __init__(self, SELFTYPE, methname):
-        _, meth = SELFTYPE._lookup(methname)
-        METH = ootype.typeOf(meth)
-        self.SELFTYPE = SELFTYPE
-        self.METH = METH
-        self.methname = methname
-        RESULT = METH.RESULT
-        getargs = make_getargs(METH.ARGS)
-        def callmeth(selfbox, argboxes):
-            selfobj = selfbox.getref(SELFTYPE)
-            meth = getattr(selfobj, methname)
-            methargs = getargs(argboxes)
-            res = llimpl.call_maybe_on_top_of_llinterp(meth, methargs)
-            if RESULT is not ootype.Void:
-                return boxresult(RESULT, res)
-        self.callmeth = callmeth
-
-    def __repr__(self):
-        return '<MethDescr %r>' % self.methname
-
-class TypeDescr(OODescr):
-
-    create = None
-
-    def __init__(self, TYPE):
-        self.TYPE = TYPE
-        self.ARRAY = ARRAY = ootype.Array(TYPE)
-        def create():
-            return boxresult(TYPE, ootype.new(TYPE))
-
-        def create_array(lengthbox):
-            n = lengthbox.getint()
-            return boxresult(ARRAY, ootype.oonewarray(ARRAY, n))
-
-        def getarrayitem(arraybox, ibox):
-            array = arraybox.getref(ARRAY)
-            i = ibox.getint()
-            return boxresult(TYPE, array.ll_getitem_fast(i))
-
-        def setarrayitem(arraybox, ibox, valuebox):
-            array = arraybox.getref(ARRAY)
-            i = ibox.getint()
-            value = unwrap(TYPE, valuebox)
-            array.ll_setitem_fast(i, value)
-
-        def getarraylength(arraybox):
-            array = arraybox.getref(ARRAY)
-            return boxresult(ootype.Signed, array.ll_length())
-
-        def instanceof(box):
-            obj = box.getref(ootype.ROOT)
-            return history.BoxInt(ootype.instanceof(obj, TYPE))
-
-        self.create = create
-        self.create_array = create_array
-        self.getarrayitem = getarrayitem
-        self.setarrayitem = setarrayitem
-        self.getarraylength = getarraylength
-        self.instanceof = instanceof
-        self._is_array_of_pointers = (history.getkind(TYPE) == 'ref')
-        self._is_array_of_floats = (history.getkind(TYPE) == 'float')
-
-    def is_array_of_pointers(self):
-        # for arrays, TYPE is the type of the array item.
-        return self._is_array_of_pointers
-
-    def is_array_of_floats(self):
-        # for arrays, TYPE is the type of the array item.
-        return self._is_array_of_floats
-
-    def __repr__(self):
-        return '<TypeDescr %s>' % self.TYPE._short_name()
-
-class FieldDescr(OODescr):
-
-    getfield = None
-    _keys = KeyManager()
-
-    def __init__(self, TYPE, fieldname):
-        self.TYPE = TYPE
-        self.fieldname = fieldname
-
-        _, T = TYPE._lookup_field(fieldname)
-        def getfield(objbox):
-            obj = objbox.getref(TYPE)
-            value = getattr(obj, fieldname)
-            return boxresult(T, value)
-        def setfield(objbox, valuebox):
-            obj = objbox.getref(TYPE)
-            value = unwrap(T, valuebox)
-            setattr(obj, fieldname, value)
-
-        self.getfield = getfield
-        self.setfield = setfield
-        self._is_pointer_field = (history.getkind(T) == 'ref')
-        self._is_float_field = (history.getkind(T) == 'float')
-
-    def sort_key(self):
-        return self._keys.getkey((self.TYPE, self.fieldname))
-
-    def is_pointer_field(self):
-        return self._is_pointer_field
-
-    def is_float_field(self):
-        return self._is_float_field
-
-    def equals(self, other):
-        return self.TYPE == other.TYPE and \
-            self.fieldname == other.fieldname
-
-    def __repr__(self):
-        return '<FieldDescr %r>' % self.fieldname
diff --git a/pypy/jit/backend/llgraph/llimpl.py b/pypy/jit/backend/llgraph/llimpl.py
deleted file mode 100644
--- a/pypy/jit/backend/llgraph/llimpl.py
+++ /dev/null
@@ -1,1968 +0,0 @@
-"""
-The non-RPythonic part of the llgraph backend.
-This contains all the code that is directly run
-when executing on top of the llinterpreter.
-"""
-
-import weakref
-from pypy.objspace.flow.model import Variable, Constant
-from pypy.annotation import model as annmodel
-from pypy.jit.metainterp.history import REF, INT, FLOAT
-from pypy.jit.metainterp import history
-from pypy.jit.codewriter import heaptracker
-from pypy.rpython.lltypesystem import lltype, llmemory, rclass, rstr, rffi
-from pypy.rpython.ootypesystem import ootype
-from pypy.rpython.module.support import LLSupport, OOSupport
-from pypy.rpython.llinterp import LLException
-from pypy.rpython.extregistry import ExtRegistryEntry
-
-from pypy.jit.metainterp import resoperation
-from pypy.jit.metainterp.resoperation import rop
-from pypy.jit.backend.llgraph import symbolic
-from pypy.jit.codewriter import longlong
-from pypy.jit.codewriter.effectinfo import EffectInfo
-
-from pypy.rlib.objectmodel import ComputedIntSymbolic, we_are_translated
-from pypy.rlib.rarithmetic import ovfcheck
-from pypy.rlib.rarithmetic import r_longlong, r_ulonglong, r_uint
-from pypy.rlib.rtimer import read_timestamp
-
-import py
-from pypy.tool.ansi_print import ansi_log
-log = py.log.Producer('runner')
-py.log.setconsumer('runner', ansi_log)
-
-IS_32_BIT = r_ulonglong is not r_uint
-
-
-def _from_opaque(opq):
-    return opq._obj.externalobj
-
-_TO_OPAQUE = {}
-
-def _to_opaque(value):
-    try:
-        return value._the_opaque_pointer
-    except AttributeError:
-        op = lltype.opaqueptr(_TO_OPAQUE[value.__class__], 'opaque',
-                              externalobj=value)
-        value._the_opaque_pointer = op
-        return op
-
-def _normalize(value):
-    if isinstance(value, lltype._ptr):
-        value = lltype.top_container(value._obj)
-    return value
-
-def from_opaque_string(s):
-    if isinstance(s, str):
-        return s
-    elif isinstance(s, ootype._string):
-        return OOSupport.from_rstr(s)
-    else:
-        return LLSupport.from_rstr(s)
-
-FLOAT_ARRAY_TP = lltype.Ptr(lltype.Array(lltype.Float, hints={"nolength": True}))
-def maybe_uncast(TP, array):
-    if array._TYPE.TO.OF != lltype.Float:
-        # array._TYPE.TO._hints.get("uncast_on_llgraph"):
-        array = rffi.cast(TP, array)
-    return array
-
-# a list of argtypes of all operations - couldn't find any and it's
-# very useful.  Note however that the table is half-broken here and
-# there, in ways that are sometimes a bit hard to fix; that's why
-# it is not "official".
-TYPES = {
-    'int_add'         : (('int', 'int'), 'int'),
-    'int_sub'         : (('int', 'int'), 'int'),
-    'int_mul'         : (('int', 'int'), 'int'),
-    'int_floordiv'    : (('int', 'int'), 'int'),
-    'int_mod'         : (('int', 'int'), 'int'),
-    'int_and'         : (('int', 'int'), 'int'),
-    'int_or'          : (('int', 'int'), 'int'),
-    'int_xor'         : (('int', 'int'), 'int'),
-    'int_lshift'      : (('int', 'int'), 'int'),
-    'int_rshift'      : (('int', 'int'), 'int'),
-    'int_lt'          : (('int', 'int'), 'bool'),
-    'int_gt'          : (('int', 'int'), 'bool'),
-    'int_ge'          : (('int', 'int'), 'bool'),
-    'int_le'          : (('int', 'int'), 'bool'),
-    'int_eq'          : (('int', 'int'), 'bool'),
-    'int_ne'          : (('int', 'int'), 'bool'),
-    'int_is_true'     : (('int',), 'bool'),
-    'int_is_zero'     : (('int',), 'bool'),
-    'int_neg'         : (('int',), 'int'),
-    'int_invert'      : (('int',), 'int'),
-    'int_add_ovf'     : (('int', 'int'), 'int'),
-    'int_sub_ovf'     : (('int', 'int'), 'int'),
-    'int_mul_ovf'     : (('int', 'int'), 'int'),
-    'int_force_ge_zero':(('int',), 'int'),
-    'uint_add'        : (('int', 'int'), 'int'),
-    'uint_sub'        : (('int', 'int'), 'int'),
-    'uint_mul'        : (('int', 'int'), 'int'),
-    'uint_lt'         : (('int', 'int'), 'bool'),
-    'uint_le'         : (('int', 'int'), 'bool'),
-    'uint_eq'         : (('int', 'int'), 'bool'),
-    'uint_ne'         : (('int', 'int'), 'bool'),
-    'uint_gt'         : (('int', 'int'), 'bool'),
-    'uint_ge'         : (('int', 'int'), 'bool'),
-    'uint_xor'        : (('int', 'int'), 'int'),
-    'uint_rshift'     : (('int', 'int'), 'int'),
-    'uint_floordiv'   : (('int', 'int'), 'int'),
-    'float_add'       : (('float', 'float'), 'float'),
-    'float_sub'       : (('float', 'float'), 'float'),
-    'float_mul'       : (('float', 'float'), 'float'),
-    'float_truediv'   : (('float', 'float'), 'float'),
-    'float_lt'        : (('float', 'float'), 'bool'),
-    'float_le'        : (('float', 'float'), 'bool'),
-    'float_eq'        : (('float', 'float'), 'bool'),
-    'float_ne'        : (('float', 'float'), 'bool'),
-    'float_gt'        : (('float', 'float'), 'bool'),
-    'float_ge'        : (('float', 'float'), 'bool'),
-    'float_neg'       : (('float',), 'float'),
-    'float_abs'       : (('float',), 'float'),
-    'cast_float_to_int':(('float',), 'int'),
-    'cast_int_to_float':(('int',), 'float'),
-    'same_as'         : (('int',), 'int'),      # could also be ptr=>ptr
-    'new_with_vtable' : (('ref',), 'ref'),
-    'new'             : ((), 'ref'),
-    'new_array'       : (('int',), 'ref'),
-    'oois'            : (('ref', 'ref'), 'bool'),
-    'ooisnot'         : (('ref', 'ref'), 'bool'),
-    'instanceof'      : (('ref',), 'bool'),
-    'subclassof'      : (('ref', 'ref'), 'bool'),
-    'runtimenew'      : (('ref',), 'ref'),
-    'setfield_gc'     : (('ref', 'intorptr'), None),
-    'getfield_gc'     : (('ref',), 'intorptr'),
-    'getfield_gc_pure': (('ref',), 'intorptr'),
-    'setfield_raw'    : (('ref', 'intorptr'), None),
-    'getfield_raw'    : (('ref',), 'intorptr'),
-    'getfield_raw_pure': (('ref',), 'intorptr'),
-    'setarrayitem_gc' : (('ref', 'int', 'intorptr'), None),
-    'getarrayitem_gc' : (('ref', 'int'), 'intorptr'),
-    'getarrayitem_gc_pure' : (('ref', 'int'), 'intorptr'),
-    'setarrayitem_raw' : (('ref', 'int', 'intorptr'), None),
-    'getarrayitem_raw' : (('ref', 'int'), 'intorptr'),
-    'getarrayitem_raw_pure' : (('ref', 'int'), 'intorptr'),
-    'arraylen_gc'     : (('ref',), 'int'),
-    'call'            : (('ref', 'varargs'), 'intorptr'),
-    'call_assembler'  : (('varargs',), 'intorptr'),
-    'cond_call_gc_wb' : (('ptr', 'ptr'), None),
-    'cond_call_gc_wb_array': (('ptr', 'int', 'ptr'), None),
-    'oosend'          : (('varargs',), 'intorptr'),
-    'oosend_pure'     : (('varargs',), 'intorptr'),
-    'guard_true'      : (('bool',), None),
-    'guard_false'     : (('bool',), None),
-    'guard_value'     : (('int', 'int'), None),
-    'guard_class'     : (('ref', 'ref'), None),
-    'guard_no_exception'   : ((), None),
-    'guard_exception'      : (('ref',), 'ref'),
-    'guard_no_overflow'    : ((), None),
-    'guard_overflow'       : ((), None),
-    'guard_nonnull'        : (('ref',), None),
-    'guard_isnull'        : (('ref',), None),
-    'guard_nonnull_class' : (('ref', 'ref'), None),
-    'newstr'          : (('int',), 'ref'),
-    'strlen'          : (('ref',), 'int'),
-    'strgetitem'      : (('ref', 'int'), 'int'),
-    'strsetitem'      : (('ref', 'int', 'int'), None),
-    'newunicode'      : (('int',), 'ref'),
-    'unicodelen'      : (('ref',), 'int'),
-    'unicodegetitem'  : (('ref', 'int'), 'int'),
-    'unicodesetitem'  : (('ref', 'int', 'int'), 'int'),
-    'cast_ptr_to_int' : (('ref',), 'int'),
-    'cast_int_to_ptr' : (('int',), 'ref'),
-    'debug_merge_point': (('ref', 'int', 'int'), None),
-    'force_token'     : ((), 'int'),
-    'call_may_force'  : (('int', 'varargs'), 'intorptr'),
-    'guard_not_forced': ((), None),
-}
-
-# ____________________________________________________________
-
-class CompiledLoop(object):
-    has_been_freed = False
-    invalid = False
-
-    def __init__(self):
-        self.inputargs = []
-        self.operations = []
-
-    def getargtypes(self):
-        return [v.concretetype for v in self.inputargs]
-
-    def __repr__(self):
-        lines = []
-        self.as_text(lines, 1)
-        return 'CompiledLoop %s:\n%s' % (self.inputargs, '\n'.join(lines))
-
-    def as_text(self, lines, indent):
-        for op in self.operations:
-            lines.append('\t'*indent + repr(op))
-
-class Operation(object):
-    result = None
-    descr = None
-    jump_target = None
-    fail_args = None
-
-    def __init__(self, opnum):
-        self.opnum = opnum
-        self.args = []
-
-    def __repr__(self):
-        if self.result is not None:
-            sres = repr0(self.result) + ' = '
-        else:
-            sres = ''
-        return '{%s%s(%s)}' % (sres, self.getopname(),
-                               ', '.join(map(repr0, self.args)))
-
-    def getopname(self):
-        try:
-            return resoperation.opname[self.opnum]
-        except KeyError:
-            return '<%d>' % self.opnum
-
-    def is_guard(self):
-        return rop._GUARD_FIRST <= self.opnum <= rop._GUARD_LAST
-
-    def is_final(self):
-        return rop._FINAL_FIRST <= self.opnum <= rop._FINAL_LAST
-
-def repr0(x):
-    if isinstance(x, list):
-        return '[' + ', '.join(repr0(y) for y in x) + ']'
-    elif isinstance(x, Constant):
-        return '(' + repr0(x.value) + ')'
-    elif isinstance(x, lltype._ptr):
-        x = llmemory.cast_ptr_to_adr(x)
-        if x.ptr:
-            try:
-                container = x.ptr._obj._normalizedcontainer()
-                return '* %s' % (container._TYPE._short_name(),)
-            except AttributeError:
-                return repr(x)
-        else:
-            return 'NULL'
-    else:
-        return repr(x)
-
-def repr_list(lst, types):
-    res_l = []
-    if types and types[-1] == 'varargs':
-        types = types[:-1] + ('int',) * (len(lst) - len(types) + 1)
-    assert len(types) == len(lst)
-    for elem, tp in zip(lst, types):
-        if isinstance(elem, Constant):
-            res_l.append('(%s)' % repr1(elem, tp))
-        else:
-            res_l.append(repr1(elem, tp))
-    return '[%s]' % (', '.join(res_l))
-
-def repr1(x, tp):
-    if tp == "intorptr":
-        TYPE = lltype.typeOf(x)
-        if isinstance(TYPE, lltype.Ptr) and TYPE.TO._gckind == 'gc':
-            tp = "ref"
-        else:
-            tp = "int"
-    if tp == 'int':
-        return str(x)
-    elif tp == 'void':
-        return '---'
-    elif tp == 'ref':
-        if not x:
-            return '(* None)'
-        if isinstance(x, int):
-            # XXX normalize?
-            ptr = str(llmemory.cast_int_to_adr(x))
-        elif isinstance(ootype.typeOf(x), ootype.OOType):
-            return repr(x)
-        else:
-            if getattr(x, '_fake', None):
-                return repr(x)
-            if lltype.typeOf(x) == llmemory.GCREF:
-                TP = lltype.Ptr(lltype.typeOf(x._obj.container))
-                ptr = lltype.cast_opaque_ptr(TP, x)
-            else:
-                ptr = x
-        try:
-            container = ptr._obj._normalizedcontainer()
-            return '(* %s)' % (container._TYPE._short_name(),)
-        except AttributeError:
-            return '(%r)' % (ptr,)
-    elif tp == 'bool':
-        assert x == 0 or x == 1
-        return str(bool(x))
-    #elif tp == 'fieldname':
-    #    return str(symbolic.TokenToField[x...][1])
-    elif tp == 'float':
-        return str(x)
-    else:
-        raise NotImplementedError("tp = %s" % tp)
-
-_variables = []
-
-def compile_start():
-    del _variables[:]
-    return _to_opaque(CompiledLoop())
-
-def mark_as_free(loop):
-    loop = _from_opaque(loop)
-    assert not loop.has_been_freed
-    loop.has_been_freed = True
-
-def compile_start_int_var(loop):
-    return compile_start_ref_var(loop, lltype.Signed)
-
-def compile_start_float_var(loop):
-    return compile_start_ref_var(loop, longlong.FLOATSTORAGE)
-
-def compile_start_ref_var(loop, TYPE):
-    loop = _from_opaque(loop)
-    assert not loop.operations
-    v = Variable()
-    v.concretetype = TYPE
-    loop.inputargs.append(v)
-    r = len(_variables)
-    _variables.append(v)
-    return r
-
-def compile_started_vars(clt):
-    if not hasattr(clt, '_debug_argtypes'):    # only when compiling the loop
-        argtypes = [v.concretetype for v in _variables]
-        try:
-            clt._debug_argtypes = argtypes
-        except AttributeError:    # when 'clt' is actually a translated
-            pass                  # GcStruct
-
-def compile_add(loop, opnum):
-    loop = _from_opaque(loop)
-    loop.operations.append(Operation(opnum))
-
-def compile_add_descr(loop, ofs, type, arg_types, extrainfo, width):
-    from pypy.jit.backend.llgraph.runner import Descr
-    loop = _from_opaque(loop)
-    op = loop.operations[-1]
-    assert isinstance(type, str) and len(type) == 1
-    op.descr = Descr(ofs, type, arg_types=arg_types, extrainfo=extrainfo, width=width)
-
-def compile_add_descr_arg(loop, ofs, type, arg_types):
-    from pypy.jit.backend.llgraph.runner import Descr
-    loop = _from_opaque(loop)
-    op = loop.operations[-1]
-    assert isinstance(type, str) and len(type) == 1
-    op.args.append(Descr(ofs, type, arg_types=arg_types))
-
-def compile_add_loop_token(loop, descr):
-    if we_are_translated():
-        raise ValueError("CALL_ASSEMBLER not supported")
-    loop = _from_opaque(loop)
-    op = loop.operations[-1]
-    op.descr = weakref.ref(descr)
-
-TARGET_TOKENS = weakref.WeakKeyDictionary()
-
-def compile_add_target_token(loop, descr, clt):
-    # here, 'clt' is the compiled_loop_token of the original loop that
-    # we are compiling
-    loop = _from_opaque(loop)
-    op = loop.operations[-1]
-    descrobj = _normalize(descr)
-    TARGET_TOKENS[descrobj] = loop, len(loop.operations), op.args, clt
-
-def compile_add_var(loop, intvar):
-    loop = _from_opaque(loop)
-    op = loop.operations[-1]
-    op.args.append(_variables[intvar])
-
-def compile_add_int_const(loop, value):
-    compile_add_ref_const(loop, value, lltype.Signed)
-
-def compile_add_float_const(loop, value):
-    compile_add_ref_const(loop, value, longlong.FLOATSTORAGE)
-
-def compile_add_ref_const(loop, value, TYPE):
-    loop = _from_opaque(loop)
-    const = Constant(value)
-    const.concretetype = TYPE
-    op = loop.operations[-1]
-    op.args.append(const)
-
-def compile_add_int_result(loop):
-    return compile_add_ref_result(loop, lltype.Signed)
-
-def compile_add_float_result(loop):
-    return compile_add_ref_result(loop, longlong.FLOATSTORAGE)
-
-def compile_add_ref_result(loop, TYPE):
-    loop = _from_opaque(loop)
-    v = Variable()
-    v.concretetype = TYPE
-    op = loop.operations[-1]
-    op.result = v
-    r = len(_variables)
-    _variables.append(v)
-    return r
-
-def compile_add_jump_target(loop, targettoken, source_clt):
-    loop = _from_opaque(loop)
-    descrobj = _normalize(targettoken)
-    (loop_target, target_opindex, target_inputargs, target_clt
-        ) = TARGET_TOKENS[descrobj]
-    #
-    try:
-        assert source_clt._debug_argtypes == target_clt._debug_argtypes
-    except AttributeError:   # when translated
-        pass
-    #
-    op = loop.operations[-1]
-    op.jump_target = loop_target
-    op.jump_target_opindex = target_opindex
-    op.jump_target_inputargs = target_inputargs
-    assert op.opnum == rop.JUMP
-    assert [v.concretetype for v in op.args] == (
-           [v.concretetype for v in target_inputargs])
-    #
-    if loop_target == loop:
-        log.info("compiling new loop")
-    else:
-        log.info("compiling new bridge")
-
-def compile_add_guard_jump_target(loop, loop_target):
-    loop = _from_opaque(loop)
-    loop_target = _from_opaque(loop_target)
-    op = loop.operations[-1]
-    assert op.is_guard()
-    op.jump_target = loop_target
-
-def compile_add_fail(loop, fail_index):
-    loop = _from_opaque(loop)
-    index = len(loop.operations)-1
-    op = loop.operations[index]
-    op.fail_index = fail_index
-    return index
-
-def compile_add_fail_arg(loop, intvar):
-    loop = _from_opaque(loop)
-    op = loop.operations[-1]
-    if op.fail_args is None:
-        op.fail_args = []
-    if intvar == -1:
-        op.fail_args.append(None)
-    else:
-        op.fail_args.append(_variables[intvar])
-
-def compile_redirect_fail(old_loop, old_index, new_loop):
-    old_loop = _from_opaque(old_loop)
-    new_loop = _from_opaque(new_loop)
-    guard_op = old_loop.operations[old_index]
-    assert guard_op.is_guard()
-    guard_op.jump_target = new_loop
-    # check that the bridge's inputargs are of the correct number and
-    # kind for the guard
-    if guard_op.fail_args is not None:
-        argkinds = [v.concretetype for v in guard_op.fail_args if v]
-    else:
-        argkinds = []
-    assert argkinds == [v.concretetype for v in new_loop.inputargs]
-
-# ------------------------------
-
-class Frame(object):
-    OPHANDLERS = [None] * (rop._LAST+1)
-
-    def __init__(self, cpu):
-        self.verbose = False
-        self.cpu = cpu
-        self.opindex = 1
-        self._forced = False
-        self._may_force = -1
-
-    def getenv(self, v):
-        from pypy.jit.backend.llgraph.runner import Descr
-        if isinstance(v, Constant):
-            return v.value
-        elif isinstance(v, Descr):
-            return v
-        else:
-            return self.env[v]
-
-    def _populate_fail_args(self, op, skip=None):
-        fail_args = []
-        if op.fail_args:
-            for fail_arg in op.fail_args:
-                if fail_arg is None:
-                    fail_args.append(None)
-                elif fail_arg is skip:
-                    fail_args.append(fail_arg.concretetype._defl())
-                else:
-                    fail_args.append(self.getenv(fail_arg))
-        self.fail_args = fail_args
-        self.fail_index = op.fail_index
-
-    def execute(self):
-        """Execute all operations in a loop,
-        possibly following to other loops as well.
-        """
-        global _last_exception
-        assert _last_exception is None, "exception left behind"
-        verbose = True
-        self.opindex = 0
-        while True:
-            assert not self.loop.has_been_freed
-            op = self.loop.operations[self.opindex]
-            args = [self.getenv(v) for v in op.args]
-            if not op.is_final():
-                try:
-                    result = self.execute_operation(op.opnum, args, op.descr,
-                                                    verbose)
-                except GuardFailed:
-                    assert op.is_guard()
-                    _stats.exec_conditional_jumps += 1
-                    if op.jump_target is not None:
-                        # a patched guard, pointing to further code
-                        if op.fail_args:
-                            args = [self.getenv(v) for v in op.fail_args if v]
-                        else:
-                            args = []
-                        assert len(op.jump_target.inputargs) == len(args)
-                        self.env = dict(zip(op.jump_target.inputargs, args))
-                        self.loop = op.jump_target
-                        self.opindex = 0
-                        continue
-                    else:
-                        self._populate_fail_args(op)
-                        # a non-patched guard
-                        if self.verbose:
-                            log.trace('failed: %s' % (
-                                ', '.join(map(str, fail_args)),))
-                        return op.fail_index
-                #verbose = self.verbose
-                assert (result is None) == (op.result is None)
-                if op.result is not None:
-                    RESTYPE = op.result.concretetype
-                    if RESTYPE is lltype.Signed:
-                        x = self.as_int(result)
-                    elif RESTYPE is llmemory.GCREF:
-                        x = self.as_ptr(result)
-                    elif RESTYPE is ootype.Object:
-                        x = self.as_object(result)
-                    elif RESTYPE is longlong.FLOATSTORAGE:
-                        x = self.as_floatstorage(result)
-                    else:
-                        raise Exception("op.result.concretetype is %r"
-                                        % (RESTYPE,))
-                    self.env[op.result] = x
-                self.opindex += 1
-                continue
-            if op.opnum == rop.JUMP:
-                inputargs = op.jump_target_inputargs
-                assert len(inputargs) == len(args)
-                self.env = dict(zip(inputargs, args))
-                self.loop = op.jump_target
-                self.opindex = op.jump_target_opindex
-                _stats.exec_jumps += 1
-            elif op.opnum == rop.FINISH:
-                if self.verbose:
-                    log.trace('finished: %s' % (
-                        ', '.join(map(str, args)),))
-                self.fail_args = args
-                return op.fail_index
-
-            else:
-                assert 0, "unknown final operation %d" % (op.opnum,)
-
-    def execute_operation(self, opnum, values, descr, verbose):
-        """Execute a single operation.
-        """
-        ophandler = self.OPHANDLERS[opnum]
-        if ophandler is None:
-            self._define_impl(opnum)
-            ophandler = self.OPHANDLERS[opnum]
-            assert ophandler is not None, "missing impl for op %d" % opnum
-        opname = resoperation.opname[opnum].lower()
-        exec_counters = _stats.exec_counters
-        exec_counters[opname] = exec_counters.get(opname, 0) + 1
-        for i in range(len(values)):
-            if isinstance(values[i], ComputedIntSymbolic):
-                values[i] = values[i].compute_fn()
-        res = NotImplemented
-        try:
-            res = ophandler(self, descr, *values)
-        finally:
-            if 0:     # if verbose:
-                argtypes, restype = TYPES[opname]
-                if res is None:
-                    resdata = ''
-                elif res is NotImplemented:
-                    resdata = '*fail*'
-                else:
-                    resdata = '-> ' + repr1(res, restype)
-                # fish the types
-                log.cpu('\t%s %s %s' % (opname, repr_list(values, argtypes),
-                                        resdata))
-        return res
-
-    def as_int(self, x):
-        return cast_to_int(x)
-
-    def as_ptr(self, x):
-        return cast_to_ptr(x)
-
-    def as_object(self, x):
-        return ootype.cast_to_object(x)
-
-    def as_floatstorage(self, x):
-        return cast_to_floatstorage(x)
-
-    def log_progress(self):
-        count = sum(_stats.exec_counters.values())
-        count_jumps = _stats.exec_jumps
-        log.trace('ran %d operations, %d jumps' % (count, count_jumps))
-
-    # ----------
-
-    @classmethod
-    def _define_impl(cls, opnum):
-        opname = resoperation.opname[opnum]
-        try:
-            op = getattr(cls, 'op_' + opname.lower())   # op_guard_true etc.
-        except AttributeError:
-            try:
-                impl = globals()['do_' + opname.lower()]  # do_arraylen_gc etc.
-                def op(self, descr, *args):
-                    if descr is None:
-                        return impl(*args)
-                    else:
-                        return impl(descr, *args)
-            except KeyError:
-                op = cls._make_impl_from_blackhole_interp(opname)
-        cls.OPHANDLERS[opnum] = op
-
-    @classmethod
-    def _make_impl_from_blackhole_interp(cls, opname):
-        from pypy.jit.metainterp.blackhole import BlackholeInterpreter
-        name = 'bhimpl_' + opname.lower()
-        func = BlackholeInterpreter.__dict__[name]
-        for argtype in func.argtypes:
-            assert argtype in ('i', 'r', 'f')
-        #
-        def _op_default_implementation(self, descr, *args):
-            # for all operations implemented in the blackhole interpreter
-            return func(*args)
-        #
-        return _op_default_implementation
-
-    def op_label(self, _, *args):
-        op = self.loop.operations[self.opindex]
-        assert op.opnum == rop.LABEL
-        assert len(op.args) == len(args)
-        newenv = {}
-        for v, value in zip(op.args, args):
-            newenv[v] = value
-        self.env = newenv
-
-    def op_debug_merge_point(self, _, *args):
-        from pypy.jit.metainterp.warmspot import get_stats
-        try:
-            stats = get_stats()
-        except AttributeError:
-            pass
-        else:
-            stats.add_merge_point_location(args[1:])
-        pass
-
-    def op_guard_true(self, _, value):
-        if not value:
-            raise GuardFailed
-
-    def op_guard_false(self, _, value):
-        if value:
-            raise GuardFailed
-
-    op_guard_nonnull = op_guard_true
-    op_guard_isnull  = op_guard_false
-
-    def op_guard_class(self, _, value, expected_class):
-        value = lltype.cast_opaque_ptr(rclass.OBJECTPTR, value)
-        expected_class = llmemory.cast_adr_to_ptr(
-            llmemory.cast_int_to_adr(expected_class),
-            rclass.CLASSTYPE)
-        if value.typeptr != expected_class:
-            raise GuardFailed
-
-    def op_guard_nonnull_class(self, _, value, expected_class):
-        if not value:
-            raise GuardFailed
-        self.op_guard_class(_, value, expected_class)
-
-    def op_guard_value(self, _, value, expected_value):
-        if value != expected_value:
-            raise GuardFailed
-
-    def op_guard_no_exception(self, _):
-        if _last_exception:
-            raise GuardFailed
-
-    def _check_exception(self, expected_exception):
-        global _last_exception
-        expected_exception = self._cast_exception(expected_exception)
-        assert expected_exception
-        exc = _last_exception
-        if exc:
-            got = exc.args[0]
-            # exact match!
-            if got != expected_exception:
-                return False
-            return True
-        else:
-            return False
-
-    def _cast_exception(self, exception):
-        return llmemory.cast_adr_to_ptr(
-            llmemory.cast_int_to_adr(exception),
-            rclass.CLASSTYPE)
-
-    def _issubclass(self, cls1, cls2):
-        return rclass.ll_issubclass(cls1, cls2)
-
-    def op_guard_exception(self, _, expected_exception):
-        global _last_exception
-        if not self._check_exception(expected_exception):
-            raise GuardFailed
-        res = _last_exception[1]
-        _last_exception = None
-        return res
-
-    def op_guard_no_overflow(self, _):
-        flag = self.overflow_flag
-        del self.overflow_flag
-        if flag:
-            raise GuardFailed
-
-    def op_guard_overflow(self, _):
-        flag = self.overflow_flag
-        del self.overflow_flag
-        if not flag:
-            raise GuardFailed
-
-    def op_int_add_ovf(self, _, x, y):
-        try:
-            z = ovfcheck(x + y)
-        except OverflowError:
-            ovf = True
-            z = 0
-        else:
-            ovf = False
-        self.overflow_flag = ovf
-        return z
-
-    def op_int_sub_ovf(self, _, x, y):
-        try:
-            z = ovfcheck(x - y)
-        except OverflowError:
-            ovf = True
-            z = 0
-        else:
-            ovf = False
-        self.overflow_flag = ovf
-        return z
-
-    def op_int_mul_ovf(self, _, x, y):
-        try:
-            z = ovfcheck(x * y)
-        except OverflowError:
-            ovf = True
-            z = 0
-        else:
-            ovf = False
-        self.overflow_flag = ovf
-        return z
-
-    def op_keepalive(self, _, x):
-        pass
-
-    # ----------
-    # delegating to the builtins do_xxx() (done automatically for simple cases)
-
-    def op_getarrayitem_gc(self, arraydescr, array, index):
-        if arraydescr.typeinfo == REF:
-            return do_getarrayitem_gc_ptr(array, index)
-        elif arraydescr.typeinfo == INT:
-            return do_getarrayitem_gc_int(array, index)
-        elif arraydescr.typeinfo == FLOAT:
-            return do_getarrayitem_gc_float(array, index)
-        else:
-            raise NotImplementedError
-
-    op_getarrayitem_gc_pure = op_getarrayitem_gc
-
-    def op_getarrayitem_raw(self, arraydescr, array, index):
-        if arraydescr.typeinfo == REF:
-            raise NotImplementedError("getarrayitem_raw -> gcref")
-        elif arraydescr.typeinfo == INT:
-            return do_getarrayitem_raw_int(array, index, arraydescr.ofs)
-        elif arraydescr.typeinfo == FLOAT:
-            return do_getarrayitem_raw_float(array, index)
-        else:
-            raise NotImplementedError
-
-    op_getarrayitem_raw_pure = op_getarrayitem_raw
-
-    def op_getfield_gc(self, fielddescr, struct):
-        if fielddescr.typeinfo == REF:
-            return do_getfield_gc_ptr(struct, fielddescr.ofs)
-        elif fielddescr.typeinfo == INT:
-            return do_getfield_gc_int(struct, fielddescr.ofs)
-        elif fielddescr.typeinfo == FLOAT:
-            return do_getfield_gc_float(struct, fielddescr.ofs)
-        else:
-            raise NotImplementedError
-
-    op_getfield_gc_pure = op_getfield_gc
-
-    def op_getfield_raw(self, fielddescr, struct):
-        if fielddescr.typeinfo == REF:
-            return do_getfield_raw_ptr(struct, fielddescr.ofs)
-        elif fielddescr.typeinfo == INT:
-            return do_getfield_raw_int(struct, fielddescr.ofs)
-        elif fielddescr.typeinfo == FLOAT:
-            return do_getfield_raw_float(struct, fielddescr.ofs)
-        else:
-            raise NotImplementedError
-
-    op_getfield_raw_pure = op_getfield_raw
-
-    def op_raw_store(self, arraydescr, addr, offset, value):
-        if arraydescr.typeinfo == REF:
-            raise AssertionError("cannot store GC pointer in raw storage")
-        elif arraydescr.typeinfo == INT:
-            do_raw_store_int(addr, offset, arraydescr.ofs, value)
-        elif arraydescr.typeinfo == FLOAT:
-            do_raw_store_float(addr, offset, value)
-        else:
-            raise NotImplementedError
-
-    def op_raw_load(self, arraydescr, addr, offset):
-        if arraydescr.typeinfo == REF: 
-            raise AssertionError("cannot store GC pointer in raw storage")
-        elif arraydescr.typeinfo == INT:
-            return do_raw_load_int(addr, offset, arraydescr.ofs)
-        elif arraydescr.typeinfo == FLOAT:
-            return do_raw_load_float(addr, offset)
-        else:
-            raise NotImplementedError
-
-    def op_new(self, size):
-        return do_new(size.ofs)
-
-    def op_new_with_vtable(self, descr, vtable):
-        assert descr is None
-        descr = heaptracker.vtable2descr(self.cpu, vtable)
-        result = do_new(descr.ofs)
-        value = lltype.cast_opaque_ptr(rclass.OBJECTPTR, result)
-        value.typeptr = cast_from_int(rclass.CLASSTYPE, vtable)
-        return result
-
-    def op_setarrayitem_gc(self, arraydescr, array, index, newvalue):
-        if arraydescr.typeinfo == REF:
-            do_setarrayitem_gc_ptr(array, index, newvalue)
-        elif arraydescr.typeinfo == INT:
-            do_setarrayitem_gc_int(array, index, newvalue)
-        elif arraydescr.typeinfo == FLOAT:
-            do_setarrayitem_gc_float(array, index, newvalue)
-        else:
-            raise NotImplementedError
-
-    def op_setarrayitem_raw(self, arraydescr, array, index, newvalue):
-        if arraydescr.typeinfo == REF:
-            raise NotImplementedError("setarrayitem_raw <- gcref")
-        elif arraydescr.typeinfo == INT:
-            do_setarrayitem_raw_int(array, index, newvalue, arraydescr.ofs)
-        elif arraydescr.typeinfo == FLOAT:
-            do_setarrayitem_raw_float(array, index, newvalue)
-        else:
-            raise NotImplementedError
-
-    def op_getinteriorfield_gc(self, descr, array, index):
-        if descr.typeinfo == REF:
-            return do_getinteriorfield_gc_ptr(array, index, descr.ofs)
-        elif descr.typeinfo == INT:
-            return do_getinteriorfield_gc_int(array, index, descr.ofs)
-        elif descr.typeinfo == FLOAT:
-            return do_getinteriorfield_gc_float(array, index, descr.ofs)
-        else:
-            raise NotImplementedError
-
-    def op_getinteriorfield_raw(self, descr, array, index):
-        if descr.typeinfo == REF:
-            return do_getinteriorfield_raw_ptr(array, index, descr.width, descr.ofs)
-        elif descr.typeinfo == INT:
-            return do_getinteriorfield_raw_int(array, index, descr.width, descr.ofs)
-        elif descr.typeinfo == FLOAT:
-            return do_getinteriorfield_raw_float(array, index, descr.width, descr.ofs)
-        else:
-            raise NotImplementedError
-
-    def op_setinteriorfield_gc(self, descr, array, index, newvalue):
-        if descr.typeinfo == REF:
-            return do_setinteriorfield_gc_ptr(array, index, descr.ofs,
-                                              newvalue)
-        elif descr.typeinfo == INT:
-            return do_setinteriorfield_gc_int(array, index, descr.ofs,
-                                              newvalue)
-        elif descr.typeinfo == FLOAT:
-            return do_setinteriorfield_gc_float(array, index, descr.ofs,
-                                                newvalue)
-        else:
-            raise NotImplementedError
-
-    def op_setinteriorfield_raw(self, descr, array, index, newvalue):
-        if descr.typeinfo == REF:
-            return do_setinteriorfield_raw_ptr(array, index, newvalue, descr.width, descr.ofs)
-        elif descr.typeinfo == INT:
-            return do_setinteriorfield_raw_int(array, index, newvalue, descr.width, descr.ofs)
-        elif descr.typeinfo == FLOAT:
-            return do_setinteriorfield_raw_float(array, index, newvalue, descr.width, descr.ofs)
-        else:
-            raise NotImplementedError
-
-    def op_setfield_gc(self, fielddescr, struct, newvalue):
-        if fielddescr.typeinfo == REF:
-            do_setfield_gc_ptr(struct, fielddescr.ofs, newvalue)
-        elif fielddescr.typeinfo == INT:
-            do_setfield_gc_int(struct, fielddescr.ofs, newvalue)
-        elif fielddescr.typeinfo == FLOAT:
-            do_setfield_gc_float(struct, fielddescr.ofs, newvalue)
-        else:
-            raise NotImplementedError
-
-    def op_setfield_raw(self, fielddescr, struct, newvalue):
-        if fielddescr.typeinfo == REF:
-            do_setfield_raw_ptr(struct, fielddescr.ofs, newvalue)
-        elif fielddescr.typeinfo == INT:
-            do_setfield_raw_int(struct, fielddescr.ofs, newvalue)
-        elif fielddescr.typeinfo == FLOAT:
-            do_setfield_raw_float(struct, fielddescr.ofs, newvalue)
-        else:
-            raise NotImplementedError
-
-    def op_call(self, calldescr, func, *args):
-        effectinfo = calldescr.get_extra_info()
-        if effectinfo is not None and hasattr(effectinfo, 'oopspecindex'):
-            oopspecindex = effectinfo.oopspecindex
-            if oopspecindex == EffectInfo.OS_MATH_SQRT:
-                return do_math_sqrt(args[0])
-        return self._do_call(calldescr, func, args, call_with_llptr=False)
-
-    def op_call_release_gil(self, calldescr, func, *args):
-        return self._do_call(calldescr, func, args, call_with_llptr=True)
-
-    def _do_call(self, calldescr, func, args, call_with_llptr):
-        global _last_exception
-        assert _last_exception is None, "exception left behind"
-        assert _call_args_i == _call_args_r == _call_args_f == []
-        args_in_order = []
-        for x in args:
-            T = lltype.typeOf(x)
-            if T is lltype.Signed:
-                args_in_order.append('i')
-                _call_args_i.append(x)
-            elif T == llmemory.GCREF:
-                args_in_order.append('r')
-                _call_args_r.append(x)
-            elif T is longlong.FLOATSTORAGE:
-                args_in_order.append('f')
-                _call_args_f.append(x)
-            else:
-                raise TypeError(x)
-        try:
-            return _do_call_common(func, args_in_order, calldescr,
-                                   call_with_llptr)
-        except LLException, lle:
-            _last_exception = lle
-            d = {'v': None,
-                 REF: lltype.nullptr(llmemory.GCREF.TO),
-                 INT: 0,
-                 FLOAT: 0.0}
-            return d[calldescr.typeinfo]
-
-    def op_cond_call_gc_wb(self, descr, a, b):
-        py.test.skip("cond_call_gc_wb not supported")
-
-    def op_cond_call_gc_wb_array(self, descr, a, b, c):
-        py.test.skip("cond_call_gc_wb_array not supported")
-
-    def op_oosend(self, descr, obj, *args):
-        raise NotImplementedError("oosend for lltype backend??")
-
-    op_oosend_pure = op_oosend
-
-    def op_new_array(self, arraydescr, count):
-        return do_new_array(arraydescr.ofs, count)
-
-    def op_force_token(self, descr):
-        opaque_frame = _to_opaque(self)
-        return llmemory.cast_ptr_to_adr(opaque_frame)
-
-    def op_read_timestamp(self, descr):
-        return read_timestamp()
-
-    def op_call_may_force(self, calldescr, func, *args):
-        assert not self._forced
-        self._may_force = self.opindex
-        try:
-            return self.op_call(calldescr, func, *args)
-        finally:
-            self._may_force = -1
-
-    def op_call_assembler(self, wref_loop_token, *args):
-        if we_are_translated():
-            raise ValueError("CALL_ASSEMBLER not supported")
-        return self._do_call_assembler(wref_loop_token, *args)
-
-    def _do_call_assembler(self, wref_loop_token, *args):
-        global _last_exception
-        loop_token = wref_loop_token()
-        assert loop_token, "CALL_ASSEMBLER to a target that already died"
-        ctl = loop_token.compiled_loop_token
-        if hasattr(ctl, 'redirected'):
-            return self._do_call_assembler(ctl.redirected, *args)
-        assert not self._forced
-        self._may_force = self.opindex
-        try:
-            inpargs = _from_opaque(ctl.compiled_version).inputargs
-            assert len(inpargs) == len(args)
-            for i, inparg in enumerate(inpargs):
-                TYPE = inparg.concretetype
-                if TYPE is lltype.Signed:
-                    set_future_value_int(i, args[i])
-                elif isinstance(TYPE, lltype.Ptr):
-                    set_future_value_ref(i, args[i])
-                elif TYPE is longlong.FLOATSTORAGE:
-                    set_future_value_float(i, args[i])
-                else:
-                    raise Exception("Nonsense type %s" % TYPE)
-
-            failindex = self.cpu._execute_token(loop_token)
-            jd = loop_token.outermost_jitdriver_sd
-            assert jd is not None, ("call_assembler(): the loop_token needs "
-                                    "to have 'outermost_jitdriver_sd'")
-            if jd.index_of_virtualizable != -1:
-                vable = args[jd.index_of_virtualizable]
-            else:
-                vable = lltype.nullptr(llmemory.GCREF.TO)
-            #
-            # Emulate the fast path
-            if failindex == self.cpu.done_with_this_frame_int_v:
-                reset_vable(jd, vable)
-                return self.cpu.get_latest_value_int(0)
-            if failindex == self.cpu.done_with_this_frame_ref_v:
-                reset_vable(jd, vable)
-                return self.cpu.get_latest_value_ref(0)
-            if failindex == self.cpu.done_with_this_frame_float_v:
-                reset_vable(jd, vable)
-                return self.cpu.get_latest_value_float(0)
-            if failindex == self.cpu.done_with_this_frame_void_v:
-                reset_vable(jd, vable)
-                return None
-            #
-            assembler_helper_ptr = jd.assembler_helper_adr.ptr  # fish
-            try:
-                return assembler_helper_ptr(failindex, vable)
-            except LLException, lle:
-                assert _last_exception is None, "exception left behind"
-                _last_exception = lle


More information about the pypy-commit mailing list