Home - Summaries: (main) : (py3.11) : (py3.12) : Everything - Nightly builds - Benchmarks - RPython - Builders - About

jit/backend/x86/test/test_ztranslation_basic.py::TestTranslationX86::()::test_stuff_translates

self = <rpython.jit.backend.x86.test.test_ztranslation_basic.TestTranslationX86 object at 0x0c5e7e90>

    def test_stuff_translates(self):
        # this is a basic test that tries to hit a number of features and their
        # translation:
        # - jitting of loops and bridges
        # - two virtualizable types
        # - set_param interface
        # - profiler
        # - full optimizer
        # - floats neg and abs
        # - cast_int_to_float
        # - llexternal with macro=True
        # - extra place for the zero after STR instances
    
        class BasicFrame(object):
            _virtualizable_ = ['i']
    
            def __init__(self, i):
                self.i = i
    
        class Frame(BasicFrame):
            pass
    
        eci = ExternalCompilationInfo(post_include_bits=['''
    #define pypy_my_fabs(x)  fabs(x)
    '''], includes=['math.h'])
        myabs1 = rffi.llexternal('pypy_my_fabs', [lltype.Float],
                                 lltype.Float, macro=True, releasegil=False,
                                 compilation_info=eci)
        myabs2 = rffi.llexternal('pypy_my_fabs', [lltype.Float],
                                 lltype.Float, macro=True, releasegil=True,
                                 compilation_info=eci)
    
        @jl.returns(jl.MP_FILENAME,
                    jl.MP_LINENO,
                    jl.MP_INDEX)
        def get_location():
            return ("/home.py",0,0)
    
        jitdriver = JitDriver(greens = [],
                              reds = ['total', 'frame', 'prev_s', 'j'],
                              virtualizables = ['frame'],
                              get_location = get_location)
        def f(i, j):
            for param, _ in unroll_parameters:
                defl = PARAMETERS[param]
                set_param(jitdriver, param, defl)
            set_param(jitdriver, "threshold", 3)
            set_param(jitdriver, "trace_eagerness", 2)
            total = 0
            frame = Frame(i)
            j = float(j)
            prev_s = rstr.mallocstr(16)
            while frame.i > 3:
                jitdriver.can_enter_jit(frame=frame, total=total, j=j,
                                        prev_s=prev_s)
                jitdriver.jit_merge_point(frame=frame, total=total, j=j,
                                          prev_s=prev_s)
                _get_virtualizable_token(frame)
                total += frame.i
                if frame.i >= 20:
                    frame.i -= 2
                frame.i -= 1
                j *= -0.712
                if j + (-j):    raise ValueError
                j += frame.i
                k = myabs1(myabs2(j))
                if k - abs(j):  raise ValueError
                if k - abs(-j): raise ValueError
                s = rstr.mallocstr(16)
                rgc.ll_write_final_null_char(s)
                rgc.ll_write_final_null_char(prev_s)
                if (frame.i & 3) == 0:
                    prev_s = s
            return chr(total % 253)
        #
        class Virt2(object):
            _virtualizable_ = ['i']
            def __init__(self, i):
                self.i = i
        from rpython.rlib.libffi import types, CDLL, ArgChain
        from rpython.rlib.test.test_clibffi import get_libm_name
        libm_name = get_libm_name(sys.platform)
        jitdriver2 = JitDriver(greens=[], reds = ['v2', 'func', 'res', 'x'],
                               virtualizables = ['v2'])
        def libffi_stuff(i, j):
            lib = CDLL(libm_name)
            func = lib.getpointer('fabs', [types.double], types.double)
            res = 0.0
            x = float(j)
            v2 = Virt2(i)
            while v2.i > 0:
                jitdriver2.jit_merge_point(v2=v2, res=res, func=func, x=x)
                promote(func)
                argchain = ArgChain()
                argchain.arg(x)
                res = func.call(argchain, rffi.DOUBLE)
                v2.i -= 1
            return res
        #
        def main(i, j):
            a_char = f(i, j)
            a_float = libffi_stuff(i, j)
            return ord(a_char) * 10 + int(a_float)
        expected = main(40, -49)
>       res = self.meta_interp(main, [40, -49])

jit/backend/llsupport/test/ztranslation_test.py:127: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
jit/backend/test/support.py:73: in meta_interp
    warmrunnerdesc.finish()
jit/metainterp/warmspot.py:298: in finish
    self.annhelper.finish()
rtyper/annlowlevel.py:219: in finish
    self.finish_rtype()
rtyper/annlowlevel.py:254: in finish_rtype
    perform_normalizations(rtyper.annotator)
rtyper/normalizecalls.py:408: in perform_normalizations
    normalize_call_familes(annotator)
rtyper/normalizecalls.py:19: in normalize_call_familes
    normalize_calltable(annotator, callfamily)
rtyper/normalizecalls.py:33: in normalize_calltable
    raise_call_table_too_complex_error(callfamily, annotator)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

callfamily = <rpython.annotator.description.CallFamily object at 0x1f3f3190>
annotator = <rpython.annotator.annrpython.RPythonAnnotator object at 0x0ac54530>

    def raise_call_table_too_complex_error(callfamily, annotator):
        msg = []
        items = callfamily.calltables.items()
        for i, (shape1, table1) in enumerate(items):
            for shape2, table2 in items[i + 1:]:
                if shape1 == shape2:
                    continue
                row1 = table1[0]
                row2 = table2[0]
                problematic_function_graphs = set(row1.values()).union(set(row2.values()))
                pfg = [str(graph) for graph in problematic_function_graphs]
                pfg.sort()
                msg.append("the following functions:")
                msg.append("    %s" % ("\n    ".join(pfg), ))
                msg.append("are called with inconsistent numbers of arguments")
                msg.append("(and/or the argument names are different, which is"
                           " not supported in this case)")
                if shape1[0] != shape2[0]:
                    msg.append("sometimes with %s arguments, sometimes with %s" % (shape1[0], shape2[0]))
                else:
                    pass # XXX better message in this case
                callers = []
                msg.append("the callers of these functions are:")
                for tag, (caller, callee) in annotator.translator.callgraph.iteritems():
                    if callee not in problematic_function_graphs:
                        continue
                    if str(caller) in callers:
                        continue
                    callers.append(str(caller))
                callers.sort()
                for caller in callers:
                    msg.append("    %s" % (caller, ))
>       raise TyperError("\n".join(msg))
E       TyperError: the following functions:
E           (rpython.jit.metainterp.optimizeopt.info:120)NonNullPtrInfo.make_guards
E           (rpython.jit.metainterp.optimizeopt.info:336)InstancePtrInfo.make_guards
E           (rpython.jit.metainterp.optimizeopt.info:360)StructPtrInfo.make_guards
E           (rpython.jit.metainterp.optimizeopt.info:379)AbstractRawPtrInfo.make_guards
E           (rpython.jit.metainterp.optimizeopt.info:632)ArrayPtrInfo.make_guards
E           (rpython.jit.metainterp.optimizeopt.info:716)ConstPtrInfo.make_guards
E           (rpython.jit.metainterp.optimizeopt.info:83)PtrInfo.make_guards
E           (rpython.jit.metainterp.optimizeopt.info:862)FloatConstInfo.make_guards
E           (rpython.jit.metainterp.optimizeopt.intutils:1264)IntBound.make_guards
E           (rpython.jit.metainterp.optimizeopt.vstring:121)StrPtrInfo.make_guards
E       are called with inconsistent numbers of arguments
E       (and/or the argument names are different, which is not supported in this case)
E       the callers of these functions are:
E           (rpython.jit.metainterp.optimizeopt.info:336)InstancePtrInfo.make_guards
E           (rpython.jit.metainterp.optimizeopt.info:632)ArrayPtrInfo.make_guards
E           (rpython.jit.metainterp.optimizeopt.shortpreamble:382)AbstractShortPreambleBuilder.use_box
E           (rpython.jit.metainterp.optimizeopt.virtualstate:483)NotVirtualStateInfoInt._generate_guards_unkown
E           (rpython.jit.metainterp.optimizeopt.vstring:121)StrPtrInfo.make_guards

rtyper/normalizecalls.py:76: TyperError
---------- Captured stderr call ----------
[rtyper] specializing: 100 / 623 blocks   (16%)
[rtyper] specializing: 200 / 643 blocks   (31%)
[rtyper] specializing: 400 / 984 blocks   (40%)
[rtyper] specializing: 500 / 989 blocks   (50%)
[rtyper] specializing: 600 / 1013 blocks   (59%)
[rtyper] specializing: 700 / 1025 blocks   (68%)
[rtyper] specializing: 800 / 1032 blocks   (77%)
[rtyper] specializing: 900 / 1062 blocks   (84%)
[rtyper] specializing: 1000 / 1066 blocks   (93%)
[rtyper] -=- specialized 1066 blocks -=-
[rtyper] -=- specialized 4 more blocks -=-
[rtyper] specializing: 1100 / 1343 blocks   (81%)
[rtyper] specializing: 1200 / 1343 blocks   (89%)
[rtyper] specializing: 1300 / 1343 blocks   (96%)
[rtyper] -=- specialized 273 more blocks -=-
[rtyper] -=- specialized 6 more blocks -=-
[rtyper] -=- specialized 2 more blocks -=-
[rtyper] -=- specialized 7 more blocks -=-
[rtyper] -=- specialized 2 more blocks -=-
[rtyper] -=- specialized 15 more blocks -=-
[rtyper] -=- specialized 2 more blocks -=-
[backendopt:inlining] phase with threshold factor: 32.4
[backendopt:inlining] heuristic: rpython.translator.backendopt.inline.inlining_heuristic
[backendopt:inlining] inlined 20 callsites.
[backendopt:malloc] starting malloc removal
[backendopt:malloc] removed 13 simple mallocs in total
[backendopt:mergeifblocks] starting to merge if blocks
[rtyper] -=- specialized 6 more blocks -=-
[jitcodewriter:info] making JitCodes...
[jitcodewriter:info] There are 5 JitCode instances.
[jitcodewriter:info] There are 34 -live- ops. Size of liveness is 110 bytes
[rtyper] replaced 0 'jit_force_virtualizable' with <* delayed!force_virtualizable_if_necessary>
[rtyper] replaced 5 'jit_force_virtualizable' with <* delayed!force_virtualizable_if_necessary>
[jitcodewriter] compute_bitstrings:
[jitcodewriter]   9 effectinfos:
[jitcodewriter]     2 descrs for arrays
[jitcodewriter]     1 descrs for fields
[jitcodewriter]     0 descrs for interiorfields
[jitcodewriter] -> 3 bitstrings, mean length 0.7, max length 1
 (somefailed=True in jit/backend/x86/test/test_ztranslation_basic.py)
builder: rpython-linux-x86-32 build #814*
test: jit/backend/x86/test/test_ztranslation_basic.py::TestTranslationX86::()::test_stuff_translates