jit/backend/aarch64/test/test_zrpy_vmprof.py::TestZVMprof::()::test_vmprof
self = <rpython.jit.backend.aarch64.test.test_zrpy_vmprof.TestZVMprof object at 0x0000000148987558>
def test_vmprof(self):
from rpython.rlib import rvmprof
class MyCode:
_vmprof_unique_id = 0
_vmprof_weak_list = RWeakListMixin() ; _vmprof_weak_list.initialize()
def __init__(self, name):
self.name = name
def get_name(code):
return code.name
code2 = MyCode("py:y:foo:4")
rvmprof.register_code(code2, get_name)
try:
rvmprof.register_code_object_class(MyCode, get_name)
except rvmprof.VMProfPlatformUnsupported as e:
py.test.skip(str(e))
def get_unique_id(code):
return rvmprof.get_unique_id(code)
driver = JitDriver(greens = ['code'], reds = ['i', 's', 'num'],
is_recursive=True, get_unique_id=get_unique_id)
@rvmprof.vmprof_execute_code("xcode13", lambda code, num: code)
def main(code, num):
return main_jitted(code, num)
def main_jitted(code, num):
s = 0
i = 0
while i < num:
driver.jit_merge_point(code=code, i=i, s=s, num=num)
s += (i << 1)
if i % 3 == 0 and code is not code2:
main(code2, 100)
i += 1
return s
tmpfilename = str(udir.join('test_rvmprof'))
def f(num):
rthread.get_ident() # register TLOFS_thread_ident
code = MyCode("py:x:foo:3")
rvmprof.register_code(code, get_name)
fd = os.open(tmpfilename, os.O_WRONLY | os.O_CREAT, 0666)
period = 0.0001
rvmprof.enable(fd, period)
res = main(code, num)
#assert res == 499999500000
rvmprof.disable()
os.close(fd)
return 0
def check_vmprof_output():
from vmprof import read_profile
tmpfile = str(udir.join('test_rvmprof'))
stats = read_profile(tmpfile)
t = stats.get_tree()
assert t.name == 'py:x:foo:3'
assert len(t.children) == 1 # jit
> self.meta_interp(f, [1000000], inline=True)
jit/backend/llsupport/test/zrpy_vmprof_test.py:84:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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:178: in generate_source
db = self.build_database()
translator/c/genc.py:102: in build_database
self.config.translation.reverse_debugger)
translator/c/database.py:64: in __init__
self.gctransformer = self.gcpolicy.gettransformer(translator, gchooks)
translator/c/gc.py:452: in gettransformer
return shadowstack.ShadowStackFrameworkGCTransformer(translator, gchooks)
memory/gctransform/framework.py:247: in __init__
self.check_custom_trace_funcs(gcdata.gc, translator.rtyper)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <rpython.memory.gctransform.shadowstack.ShadowStackFrameworkGCTransformer object at 0x0000000149a17638>
gc = <rpython.memory.gc.incminimark.IncrementalMiniMarkGC object at 0x0000000121926fa8>
rtyper = <rpython.rtyper.rtyper.RPythonTyper object at 0x0000000120469018>
def check_custom_trace_funcs(self, gc, rtyper):
# detect if one of the custom trace functions uses the GC
# (it must not!)
for TP, func in rtyper.custom_trace_funcs:
if getattr(func, '_skip_collect_analyzer_', False):
continue
def no_op_callback(obj, arg1, arg2):
pass
def ll_check_no_collect(obj):
func(gc, obj, no_op_callback, None, None)
annhelper = annlowlevel.MixLevelHelperAnnotator(rtyper)
graph1 = annhelper.getgraph(ll_check_no_collect, [SomeAddress()],
annmodel.s_None)
annhelper.finish()
collect_analyzer = CollectAnalyzer(self.translator)
if collect_analyzer.analyze_direct_call(graph1):
raise Exception(
"the custom trace hook %r for %r can cause "
> "the GC to be called!" % (func, TP))
E Exception: the custom trace hook <function gcrefs_trace at 0x000000013afccae8> for <GcStruct GCREFTRACER { array_base_addr, array_length }> can cause the GC to be called!
memory/gctransform/framework.py:630: Exception
---------- Captured stderr call ----------
[rtyper] specializing: 100 / 658 blocks (15%)
[rtyper] specializing: 200 / 747 blocks (26%)
[rtyper] specializing: 300 / 749 blocks (40%)
[rtyper] specializing: 400 / 749 blocks (53%)
[rtyper] specializing: 500 / 749 blocks (66%)
[rtyper] specializing: 600 / 754 blocks (79%)
[rtyper] specializing: 700 / 754 blocks (92%)
[rtyper] -=- specialized 758 blocks -=-
[rtyper] -=- specialized 4 more blocks -=-
[rtyper] specializing: 800 / 1057 blocks (75%)
[rtyper] specializing: 900 / 1057 blocks (85%)
[rtyper] specializing: 1000 / 1057 blocks (94%)
[rtyper] -=- specialized 295 more blocks -=-
[rtyper] -=- specialized 6 more blocks -=-
[rtyper] -=- specialized 2 more blocks -=-
[rtyper] -=- specialized 2 more blocks -=-
[rtyper] -=- specialized 6 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 5 callsites.
[backendopt:malloc] starting malloc removal
[backendopt:malloc] removed 1 simple mallocs in total
[backendopt:mergeifblocks] starting to merge if blocks
[rtyper] -=- specialized 8 more blocks -=-
[jitcodewriter:info] making JitCodes...
[rtyper] specializing: 1100 / 1100 blocks (100%)
[rtyper] -=- specialized 2 more blocks -=-
[rtyper] -=- specialized 2 more blocks -=-
[jitcodewriter:info] There are 4 JitCode instances.
[jitcodewriter:info] There are 12 -live- ops. Size of liveness is 22 bytes
[jitcodewriter] compute_bitstrings:
[jitcodewriter] 7 effectinfos:
[jitcodewriter] 0 descrs for arrays
[jitcodewriter] 0 descrs for fields
[jitcodewriter] 0 descrs for interiorfields
[jitcodewriter] -> 1 bitstrings, mean length 0.0, max length 0
[rtyper] specializing: 1700 / 33424 blocks (5%)
[rtyper] specializing: 3600 / 35683 blocks (10%)
[rtyper] specializing: 6000 / 39405 blocks (15%)
[rtyper] specializing: 8400 / 41967 blocks (20%)
[rtyper] specializing: 10600 / 42313 blocks (25%)
[rtyper] specializing: 12700 / 42313 blocks (30%)
[rtyper] specializing: 14900 / 42323 blocks (35%)
[rtyper] specializing: 17000 / 42323 blocks (40%)
[rtyper] specializing: 19200 / 42662 blocks (45%)
[rtyper] specializing: 23600 / 47149 blocks (50%)
[rtyper] specializing: 26100 / 47333 blocks (55%)
[rtyper] specializing: 28500 / 47354 blocks (60%)
[rtyper] specializing: 30800 / 47354 blocks (65%)
[rtyper] specializing: 32400 / 47354 blocks (68%)
[rtyper] specializing: 34600 / 47354 blocks (73%)
[rtyper] specializing: 37100 / 47453 blocks (78%)
[rtyper] specializing: 39400 / 47453 blocks (83%)
[rtyper] specializing: 41800 / 47453 blocks (88%)
[rtyper] specializing: 44200 / 47453 blocks (93%)
[rtyper] specializing: 46600 / 47453 blocks (98%)
[rtyper] specializing: 47400 / 47455 blocks (99%)
[rtyper] -=- specialized 46353 more blocks -=-
[rtyper] -=- specialized 26 more blocks -=-
[rtyper] -=- specialized 0 more blocks -=-
[rtyper] specializing: 47500 / 47506 blocks (99%)
[rtyper] -=- specialized 25 more blocks -=-
[rtyper] specializing: 47600 / 49966 blocks (95%)
[rtyper] specializing: 50000 / 50029 blocks (99%)
[rtyper] -=- specialized 2523 more blocks -=-
[rtyper] specializing: 50100 / 50105 blocks (99%)
[rtyper] -=- specialized 76 more blocks -=-
[backendopt:inlining] phase with threshold factor: 32.4
[backendopt:inlining] heuristic: rpython.translator.backendopt.inline.inlining_heuristic
[backendopt:inlining] inlined 1638 callsites.
[backendopt:malloc] starting malloc removal
[backendopt:malloc] removed 35 simple mallocs in total
[backendopt:mergeifblocks] starting to merge if blocks
[rtyper] -=- specialized 17 more blocks -=-
[rtyper] -=- specialized 12 more blocks -=-
(somefailed=True in jit/backend/aarch64/test/test_zrpy_vmprof.py)
builder: rpython-macos-arm64 build #260
test: jit/backend/aarch64/test/test_zrpy_vmprof/py/TestZVMprof/()/test_vmprof