jit/backend/x86/test/test_ztranslation_basic.py::TestTranslationX86::()::test_stuff_translates
self = <rpython.jit.backend.x86.test.test_ztranslation_basic.TestTranslationX86 object at 0x00007fd5a98c3830>
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:75: in meta_interp
return self._compile_and_run(t, entry_point, entry_point_graph, args)
jit/backend/test/support.py:132: in _compile_and_run
exe_name = cbuilder.compile()
translator/c/genc.py:341: in compile
extra_opts)
translator/platform/posix.py:277: in execute_makefile
self._handle_error(returncode, stdout, stderr, path.join('make'))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Darwin_x86_64 cc=clang>, returncode = 2
stdout = 'clang -O3 -fomit-frame-pointer -Wno-duplicate-decl-specifier -mmacosx-version-min=10.13 -arch x86_64 -mdynamic-no-pic.../rpython"/rlib/rjitlog/src -I"/Users/matti/build-worker-x86_64/rpython-macos-x86-64/build/rpython"/rlib/rvmprof/src \n'
stderr = "testing_1.c:56:2: warning: 'GC_all_interior_pointers' is deprecated [-Wdeprecated-declarations]\n 56 | GC_a...memcpy;\n | ^ ~~~~~~\n1 error generated.\nmake: *** [rpython_jit_backend_llsupport.o] Error 1\n"
outname = local('/tmp/buildbot-x86_64/usession-main-5839/testing_1/make')
def _handle_error(self, returncode, stdout, stderr, outname):
if returncode != 0:
errorfile = outname.new(ext='errors')
errorfile.write(stderr, 'wb')
if self.log_errors:
stderrlines = stderr.splitlines()
for line in stderrlines:
log.Error(line)
# ^^^ don't use ERROR, because it might actually be fine.
# Also, ERROR confuses lib-python/conftest.py.
> raise CompilationError(stdout, stderr)
E CompilationError: CompilationError(err="""
E testing_1.c:56:2: warning: 'GC_all_interior_pointers' is deprecated [-Wdeprecated-declarations]
E 56 | GC_all_interior_pointers = 0;
E | ^
E /opt/homebrew_x86_64/Cellar/bdw-gc/8.2.12/include/gc/gc.h:193:8: note: 'GC_all_interior_pointers' has been explicitly marked deprecated here
E 193 | GC_API GC_ATTR_DEPRECATED int GC_all_interior_pointers;
E | ^
E /opt/homebrew_x86_64/Cellar/bdw-gc/8.2.12/include/gc/gc_config_macros.h:309:46: note: expanded from macro 'GC_ATTR_DEPRECATED'
E 309 | # define GC_ATTR_DEPRECATED __attribute__((__deprecated__))
E | ^
E 1 warning generated.
E rpython_jit_backend_llsupport.c:12414:11: error: incompatible function pointer types assigning to 'void (*)(void *, void *, size_t)' (aka 'void (*)(void *, void *, unsigned long)') from 'void *(void *, const void *, unsigned long)' [-Wincompatible-function-pointer-types]
E 12414 | l_v15230 = memcpy;
E | ^ ~~~~~~
E 1 error generated.
E make: *** [rpython_jit_backend_llsupport.o] Error 1
E """)
translator/platform/__init__.py:155: CompilationError
---------- Captured stdout call ----------
in get_rpath_flags, rel_libdirs is not fixed up [u'/opt/homebrew_x86_64/Cellar/bdw-gc/8.2.12/lib']
---------- Captured stderr call ----------
[rtyper] specializing: 100 / 626 blocks (15%)
[rtyper] specializing: 200 / 646 blocks (30%)
[rtyper] specializing: 300 / 780 blocks (38%)
[rtyper] specializing: 400 / 849 blocks (47%)
[rtyper] specializing: 500 / 854 blocks (58%)
[rtyper] specializing: 600 / 878 blocks (68%)
[rtyper] specializing: 700 / 895 blocks (78%)
[rtyper] specializing: 800 / 899 blocks (88%)
[rtyper] -=- specialized 899 blocks -=-
[rtyper] specializing: 900 / 903 blocks (99%)
[rtyper] -=- specialized 4 more blocks -=-
[rtyper] specializing: 1000 / 1178 blocks (84%)
[rtyper] specializing: 1100 / 1178 blocks (93%)
[rtyper] -=- specialized 275 more blocks -=-
[rtyper] -=- specialized 6 more blocks -=-
[rtyper] -=- specialized 2 more blocks -=-
[rtyper] -=- specialized 7 more blocks -=-
[rtyper] -=- specialized 2 more blocks -=-
[rtyper] specializing: 1200 / 1210 blocks (99%)
[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
[rtyper] specializing: 2800 / 54141 blocks (5%)
[rtyper] specializing: 5700 / 56377 blocks (10%)
[rtyper] specializing: 8800 / 58131 blocks (15%)
[rtyper] specializing: 12600 / 62800 blocks (20%)
[rtyper] specializing: 16100 / 64007 blocks (25%)
[rtyper] specializing: 19300 / 64007 blocks (30%)
[rtyper] specializing: 22500 / 64041 blocks (35%)
[rtyper] specializing: 27300 / 68031 blocks (40%)
[rtyper] specializing: 30700 / 68051 blocks (45%)
[rtyper] specializing: 34100 / 68068 blocks (50%)
[rtyper] specializing: 37500 / 68177 blocks (55%)
[rtyper] specializing: 41000 / 68285 blocks (60%)
[rtyper] specializing: 44500 / 68335 blocks (65%)
[rtyper] specializing: 47900 / 68335 blocks (70%)
[rtyper] specializing: 51300 / 68335 blocks (75%)
[rtyper] specializing: 52900 / 68335 blocks (77%)
[rtyper] specializing: 56100 / 68335 blocks (82%)
[rtyper] specializing: 59600 / 68434 blocks (87%)
[rtyper] specializing: 63000 / 68434 blocks (92%)
[rtyper] specializing: 66400 / 68434 blocks (97%)
[rtyper] specializing: 68400 / 68436 blocks (99%)
[rtyper] -=- specialized 67218 more blocks -=-
[rtyper] -=- specialized 24 more blocks -=-
[rtyper] -=- specialized 0 more blocks -=-
[rtyper] -=- specialized 25 more blocks -=-
[rtyper] specializing: 68500 / 68549 blocks (99%)
[rtyper] -=- specialized 64 more blocks -=-
[backendopt:inlining] phase with threshold factor: 32.4
[backendopt:inlining] heuristic: rpython.translator.backendopt.inline.inlining_heuristic
[backendopt:inlining] inlined 8 callsites.
[backendopt:malloc] starting malloc removal
[backendopt:malloc] removed 0 simple mallocs in total
[backendopt:mergeifblocks] starting to merge if blocks
[rtyper] -=- specialized 5 more blocks -=-
[rtyper] -=- specialized 0 more blocks -=-
[c] 1000 nodes [ array: 193 boehm rtti: 45 func: 584 struct: 2653 ]
[c] 2000 nodes [ array: 2193 boehm rtti: 45 func: 584 struct: 2653 ]
[c] 3000 nodes [ array: 4193 boehm rtti: 45 func: 584 struct: 2653 ]
[c] 4000 nodes [ array: 4359 boehm rtti: 53 func: 751 struct: 4403 ]
[c] 5000 nodes [ array: 4359 boehm rtti: 53 func: 751 struct: 4403 ]
[c] 6000 nodes [ array: 4359 boehm rtti: 53 func: 751 struct: 4403 ]
[c] 7000 nodes [ array: 4359 boehm rtti: 53 func: 751 struct: 4403 ]
[c] 8000 nodes [ array: 4380 boehm rtti: 78 func: 939 struct: 4473 ]
[c] 9000 nodes [ array: 4380 boehm rtti: 216 func: 1173 struct: 4611 ]
[c] 10000 nodes [ array: 4479 boehm rtti: 289 func: 1436 struct: 4805 ]
[c] 11000 nodes [ array: 4694 boehm rtti: 304 func: 1883 struct: 4989 ]
[c] 12000 nodes [ array: 4848 boehm rtti: 325 func: 2418 struct: 5629 ]
[c] 13000 nodes [ array: 4932 boehm rtti: 337 func: 2851 struct: 6145 ]
[c] 14000 nodes [ array: 5227 boehm rtti: 342 func: 3170 struct: 6359 ]
[c] 15000 nodes [ array: 5290 boehm rtti: 348 func: 3556 struct: 6579 ]
[c] 16000 nodes [ array: 5367 boehm rtti: 360 func: 4327 struct: 6912 ]
[c] 17000 nodes [ array: 5456 boehm rtti: 362 func: 5270 struct: 7153 ]
[c] 18000 nodes [ array: 5510 boehm rtti: 367 func: 7749 struct: 7734 ]
[c] 19000 nodes [ array: 5535 boehm rtti: 369 func: 8164 struct: 7813 ]
[c] 20000 nodes [ array: 5558 boehm rtti: 369 func: 8320 struct: 7891 ]
[c] 21000 nodes [ array: 5599 boehm rtti: 369 func: 8602 struct: 7987 ]
[c] 22000 nodes [ array: 5760 boehm rtti: 373 func: 8982 struct: 8151 ]
[c] 23000 nodes [ array: 5908 boehm rtti: 384 func: 9223 struct: 8241 ]
[c] 24000 nodes [ array: 5982 boehm rtti: 392 func: 9758 struct: 8339 ]
[c] 25000 nodes [ array: 6005 boehm rtti: 417 func: 10496 struct: 8587 ]
[c] 26000 nodes [ array: 6054 boehm rtti: 432 func: 12019 struct: 9406 ]
[c] 27000 nodes [ array: 6085 boehm rtti: 437 func: 13401 struct: 9482 ]
[c] 28000 nodes [ array: 6085 boehm rtti: 437 func: 13437 struct: 9483 ]
[c] 29000 nodes [ array: 6085 boehm rtti: 437 func: 13469 struct: 9483 ]
[c] 30000 nodes [ array: 6152 boehm rtti: 464 func: 13891 struct: 9685 ]
[rtyper] specializing: 68600 / 68601 blocks (99%)
[rtyper] -=- specialized 47 more blocks -=-
[backendopt:inlining] phase with threshold factor: 32.4
[backendopt:inlining] heuristic: rpython.translator.backendopt.inline.inlining_heuristic
[backendopt:inlining] inlined 1 callsites.
[backendopt:malloc] starting malloc removal
[backendopt:malloc] removed 16 simple mallocs in total
[backendopt:mergeifblocks] starting to merge if blocks
[c:database] GC transformer: finished helpers
[c:database] GC transformer: finished tables
[c:database] Inlining GC helpers and postprocessing
[c] 30769 nodes [ array: 6178 boehm rtti: 472 func: 14364 struct: 9755 ]
[c:database] Completed
[c:writing] structdef.h
[c:writing] forwarddecl.h
[c:writing] preimpl.h
[c:writing] data_rpython_flowspace.c
[c:writing] data_rpython_jit_backend.c
[c:writing] data_rpython_jit_backend_llsupport.c
[c:writing] data_rpython_jit_backend_llsupport_test.c
[c:writing] data_rpython_jit_backend_x86.c
[c:writing] data_rpython_jit_codewriter.c
[c:writing] data_rpython_jit_metainterp.c
[c:writing] data_rpython_jit_metainterp_optimizeopt.c
[c:writing] data_rpython_memory_gctransform.c
[c:writing] data_rpython_rlib.c
[c:writing] data_rpython_rlib_rjitlog.c
[c:writing] data_rpython_rtyper.c
[c:writing] data_rpython_rtyper_lltypesystem.c
[c:writing] data_rpython_translator_c.c
[c:writing] nonfuncnodes.c
[c:writing] data_rpython_jit_backend_llsupport_1.c
[c:writing] data_rpython_jit_backend_x86_1.c
[c:writing] data_rpython_jit_codewriter_1.c
[c:writing] data_rpython_jit_metainterp_1.c
[c:writing] data_rpython_rlib_1.c
[c:writing] data_rpython_rlib_rvmprof.c
[c:writing] data_rpython_rtyper_lltypesystem_1.c
[c:writing] implement.c
[c:writing] rpython_flowspace.c
[c:writing] rpython_jit_backend.c
[c:writing] rpython_jit_backend_llsupport.c
[c:writing] rpython_jit_backend_llsupport_test.c
[c:writing] rpython_jit_backend_x86.c
[c:writing] rpython_jit_codewriter.c
[c:writing] rpython_jit_metainterp.c
[c:writing] rpython_jit_metainterp_optimizeopt.c
[c:writing] rpython_memory_gctransform.c
[c:writing] rpython_rlib.c
[c:writing] rpython_rlib_rjitlog.c
[c:writing] rpython_rlib_rvmprof.c
[c:writing] rpython_rtyper.c
[c:writing] rpython_rtyper_lltypesystem.c
[c:writing] rpython_rtyper_lltypesystem_module.c
[c:writing] rpython_tool_algo.c
[c:writing] rpython_translator.c
[c:writing] rpython_translator_c.c
[platform:execute] make in /tmp/buildbot-x86_64/usession-main-5839/testing_1
[platform:Error] testing_1.c:56:2: warning: 'GC_all_interior_pointers' is deprecated [-Wdeprecated-declarations]
[platform:Error] 56 | GC_all_interior_pointers = 0;
[platform:Error] | ^
[platform:Error] /opt/homebrew_x86_64/Cellar/bdw-gc/8.2.12/include/gc/gc.h:193:8: note: 'GC_all_interior_pointers' has been explicitly marked deprecated here
[platform:Error] 193 | GC_API GC_ATTR_DEPRECATED int GC_all_interior_pointers;
[platform:Error] | ^
[platform:Error] /opt/homebrew_x86_64/Cellar/bdw-gc/8.2.12/include/gc/gc_config_macros.h:309:46: note: expanded from macro 'GC_ATTR_DEPRECATED'
[platform:Error] 309 | # define GC_ATTR_DEPRECATED __attribute__((__deprecated__))
[platform:Error] | ^
[platform:Error] 1 warning generated.
[platform:Error] rpython_jit_backend_llsupport.c:12414:11: error: incompatible function pointer types assigning to 'void (*)(void *, void *, size_t)' (aka 'void (*)(void *, void *, unsigned long)') from 'void *(void *, const void *, unsigned long)' [-Wincompatible-function-pointer-types]
[platform:Error] 12414 | l_v15230 = memcpy;
[platform:Error] | ^ ~~~~~~
[platform:Error] 1 error generated.
[platform:Error] make: *** [rpython_jit_backend_llsupport.o] Error 1
(somefailed=True in jit/backend/x86/test/test_ztranslation_basic.py)
builder: rpython-macos-x86-64 build #273
test: jit/backend/x86/test/test_ztranslation_basic/py/TestTranslationX86/()/test_stuff_translates