jit/backend/aarch64/test/test_zrpy_vmprof.py::TestZVMprof::()::test_vmprof
self = <rpython.jit.backend.aarch64.test.test_zrpy_vmprof.TestZVMprof object at 0x000000014014d4b0>
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 0x000000013dbbfa60>
gc = <rpython.memory.gc.incminimark.IncrementalMiniMarkGC object at 0x000000013dbcd718>
rtyper = <rpython.rtyper.rtyper.RPythonTyper object at 0x000000015026d0f8>
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 0x000000013abbe188> for <GcStruct GCREFTRACER { array_base_addr, array_length }> can cause the GC to be called!
memory/gctransform/framework.py:630: Exception
(somefailed=True in jit/backend/aarch64/test/test_zrpy_vmprof.py)
builder: rpython-macos-arm64 build #265+
test: jit/backend/aarch64/test/test_zrpy_vmprof.py::TestZVMprof::()::test_vmprof