jit/backend/x86/test/test_ztranslation_basic.py::TestTranslationX86::()::test_stuff_translates
self = <rpython.jit.backend.x86.test.test_ztranslation_basic.TestTranslationX86 object at 0x00000197dc0984f0>
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:130: in _compile_and_run
cbuilder.generate_source()
translator\c\genc.py:214: in generate_source
self.eci, defines=defines, split=self.split)
translator\c\genc.py:879: in gen_source
sg.gen_readable_parts_of_source(f)
translator\c\genc.py:697: in gen_readable_parts_of_source
for node, impl in nodeiter:
translator\c\genc.py:621: in subiter
impl = '\n'.join(list(node.implementation())).split('\n')
translator\c\node.py:524: in implementation
lines = list(self.initializationexpr())
translator\c\node.py:615: in initializationexpr
padding_drop = T._hints['get_padding_drop'](d)
rtyper\tool\rffi_platform.py:586: in __call__
self.compute_now(types)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <rpython.rtyper.tool.rffi_platform.PaddingDrop object at 0x00000197dab8a9c0>
types = {'c__pad0': 'unsigned char', 'c__pad1': 'unsigned char', 'c__pad2': 'unsigned char', 'c__pad3': 'unsigned char', ...}
def compute_now(self, types):
# Some simplifying assumptions there. We assume that all fields
# are either integers or pointers, so can be written in C as '0'.
# We also assume that the C backend gives us in 'types' a dictionary
# mapping non-padding field names to their C type (without '@').
drops = []
staticfields = []
consecutive_pads = []
for fieldname in self.allfields:
if fieldname in self.padfields:
consecutive_pads.append(fieldname)
continue
staticfields.append(types[fieldname])
if consecutive_pads:
# In that case we have to ask: how many of these pads are
# really needed? The correct answer might be between none
# and all of the pads listed in 'consecutive_pads'.
for i in range(len(consecutive_pads)+1):
class CConfig:
_compilation_info_ = self.eci
FIELDLOOKUP = _PaddingDropFieldLookup(self.name,
staticfields,
fieldname)
try:
got = configure(CConfig)['FIELDLOOKUP']
if got == 1:
break # found
except CompilationError:
pass
staticfields.insert(-1, None)
else:
raise Exception("could not determine the detailed field"
> " layout of %r" % (self.name,))
E Exception: could not determine the detailed field layout of 'ffi_type'
rtyper\tool\rffi_platform.py:621: Exception
---------- Captured stderr call ----------
[platform:msg] Updated environment with vsver 160, using x64 True
[rtyper] specializing: 100 / 577 blocks (17%)
[rtyper] specializing: 200 / 577 blocks (34%)
[rtyper] specializing: 300 / 588 blocks (51%)
[rtyper] specializing: 400 / 663 blocks (60%)
[rtyper] specializing: 500 / 724 blocks (69%)
[rtyper] specializing: 600 / 726 blocks (82%)
[rtyper] specializing: 700 / 730 blocks (95%)
[rtyper] -=- specialized 730 blocks -=-
[rtyper] -=- specialized 4 more blocks -=-
[rtyper] specializing: 800 / 1036 blocks (77%)
[rtyper] specializing: 900 / 1041 blocks (86%)
[rtyper] specializing: 1000 / 1041 blocks (96%)
[rtyper] -=- specialized 307 more blocks -=-
[rtyper] -=- specialized 6 more blocks -=-
[rtyper] -=- specialized 2 more blocks -=-
[rtyper] -=- specialized 7 more blocks -=-
[rtyper] -=- specialized 2 more blocks -=-
[rtyper] -=- specialized 17 more blocks -=-
[rtyper] -=- specialized 12 more blocks -=-
[backendopt:inlining] phase with threshold factor: 32.4
[backendopt:inlining] heuristic: rpython.translator.backendopt.inline.inlining_heuristic
[backendopt:inlining] inlined 21 callsites.
[backendopt:malloc] starting malloc removal
[backendopt:malloc] removed 22 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 / 54004 blocks (5%)
[rtyper] specializing: 5700 / 56245 blocks (10%)
[rtyper] specializing: 8700 / 57994 blocks (15%)
[rtyper] specializing: 12600 / 62878 blocks (20%)
[rtyper] specializing: 16000 / 63889 blocks (25%)
[rtyper] specializing: 19200 / 63889 blocks (30%)
[rtyper] specializing: 22400 / 63923 blocks (35%)
[rtyper] specializing: 27200 / 67910 blocks (40%)
[rtyper] specializing: 30600 / 67940 blocks (45%)
[rtyper] specializing: 34000 / 67947 blocks (50%)
[rtyper] specializing: 37500 / 68056 blocks (55%)
[rtyper] specializing: 41000 / 68199 blocks (60%)
[rtyper] specializing: 44400 / 68211 blocks (65%)
[rtyper] specializing: 47800 / 68211 blocks (70%)
[rtyper] specializing: 51200 / 68211 blocks (75%)
[rtyper] specializing: 52600 / 68211 blocks (77%)
[rtyper] specializing: 56000 / 68213 blocks (82%)
[rtyper] specializing: 59400 / 68257 blocks (87%)
[rtyper] specializing: 62800 / 68257 blocks (92%)
[rtyper] specializing: 66300 / 68257 blocks (97%)
[rtyper] -=- specialized 67164 more blocks -=-
[rtyper] -=- specialized 34 more blocks -=-
[rtyper] -=- specialized 0 more blocks -=-
[rtyper] specializing: 68300 / 68316 blocks (99%)
[rtyper] -=- specialized 25 more blocks -=-
[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 14 more blocks -=-
[rtyper] -=- specialized 0 more blocks -=-
[c] 1000 nodes [ array: 211 boehm rtti: 45 func: 580 struct: 2641 ]
[c] 2000 nodes [ array: 2211 boehm rtti: 45 func: 580 struct: 2641 ]
[c] 3000 nodes [ array: 4211 boehm rtti: 45 func: 580 struct: 2641 ]
[c] 4000 nodes [ array: 4351 boehm rtti: 52 func: 741 struct: 4390 ]
[c] 5000 nodes [ array: 4351 boehm rtti: 52 func: 741 struct: 4390 ]
[c] 6000 nodes [ array: 4351 boehm rtti: 52 func: 741 struct: 4390 ]
[c] 7000 nodes [ array: 4351 boehm rtti: 52 func: 741 struct: 4390 ]
[c] 8000 nodes [ array: 4371 boehm rtti: 81 func: 925 struct: 4461 ]
[c] 9000 nodes [ array: 4371 boehm rtti: 219 func: 1159 struct: 4599 ]
[c] 10000 nodes [ array: 4482 boehm rtti: 288 func: 1428 struct: 4786 ]
[c] 11000 nodes [ array: 4686 boehm rtti: 303 func: 1871 struct: 4958 ]
[c] 12000 nodes [ array: 4845 boehm rtti: 321 func: 2407 struct: 5594 ]
[c] 13000 nodes [ array: 4919 boehm rtti: 333 func: 2839 struct: 6120 ]
[c] 14000 nodes [ array: 5210 boehm rtti: 338 func: 3184 struct: 6339 ]
[c] 15000 nodes [ array: 5282 boehm rtti: 345 func: 3480 struct: 6574 ]
[c] 16000 nodes [ array: 5351 boehm rtti: 355 func: 4294 struct: 6885 ]
[c] 17000 nodes [ array: 5438 boehm rtti: 358 func: 7362 struct: 7452 ]
[c] 18000 nodes [ array: 5478 boehm rtti: 363 func: 7822 struct: 7692 ]
[c] 19000 nodes [ array: 5506 boehm rtti: 364 func: 8148 struct: 7781 ]
[c] 20000 nodes [ array: 5527 boehm rtti: 364 func: 8305 struct: 7860 ]
[c] 21000 nodes [ array: 5589 boehm rtti: 364 func: 8589 struct: 7973 ]
[c] 22000 nodes [ array: 5776 boehm rtti: 368 func: 8944 struct: 8110 ]
[c] 23000 nodes [ array: 5913 boehm rtti: 379 func: 9220 struct: 8210 ]
[c] 24000 nodes [ array: 5963 boehm rtti: 387 func: 9921 struct: 8312 ]
[c] 25000 nodes [ array: 5988 boehm rtti: 419 func: 10771 struct: 9329 ]
[c] 26000 nodes [ array: 6035 boehm rtti: 427 func: 12436 struct: 9364 ]
[c] 27000 nodes [ array: 6066 boehm rtti: 432 func: 13357 struct: 9440 ]
[c] 28000 nodes [ array: 6066 boehm rtti: 432 func: 13398 struct: 9441 ]
[c] 29000 nodes [ array: 6066 boehm rtti: 432 func: 13425 struct: 9441 ]
[c] 30000 nodes [ array: 6141 boehm rtti: 465 func: 13902 struct: 9655 ]
[rtyper] specializing: 68400 / 68442 blocks (99%)
[rtyper] -=- specialized 48 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] 30659 nodes [ array: 6159 boehm rtti: 467 func: 14320 struct: 9713 ]
[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
[platform:Error] platcheck_63.c
[platform:Error] d:\systemtemp\pytest\usession-main-2940\platcheck_63.c(113): error C2078: too many initializers
[platform:Error] d:\systemtemp\pytest\usession-main-2940\platcheck_63.c(112): error C2078: too many initializers
[platform:Error] platcheck_64.c
[platform:Error] d:\systemtemp\pytest\usession-main-2940\platcheck_64.c(114): error C2078: too many initializers
[platform:Error] d:\systemtemp\pytest\usession-main-2940\platcheck_64.c(112): error C2078: too many initializers
[platform:Error] platcheck_65.c
[platform:Error] d:\systemtemp\pytest\usession-main-2940\platcheck_65.c(115): error C2078: too many initializers
[platform:Error] d:\systemtemp\pytest\usession-main-2940\platcheck_65.c(112): error C2078: too many initializers
[platform:Error] platcheck_66.c
[platform:Error] d:\systemtemp\pytest\usession-main-2940\platcheck_66.c(116): error C2078: too many initializers
[platform:Error] d:\systemtemp\pytest\usession-main-2940\platcheck_66.c(112): error C2078: too many initializers
(somefailed=True in jit/backend/x86/test/test_ztranslation_basic.py)
builder: rpython-win-x86-64 build #403
test: jit/backend/x86/test/test_ztranslation_basic/py/TestTranslationX86/()/test_stuff_translates