Commit e62a1430 authored by Stefan Behnel's avatar Stefan Behnel

enable profiling/tracing for module init code

parent f6f110e1
......@@ -2049,7 +2049,15 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln("{")
tempdecl_code = code.insertion_point()
profile = code.globalstate.directives['profile']
linetrace = code.globalstate.directives['linetrace']
if profile or linetrace:
code.globalstate.use_utility_code(UtilityCode.load_cached("Profile", "Profile.c"))
code.put_declare_refcount_context()
if profile or linetrace:
tempdecl_code.put_trace_declarations(None)
code.putln("#if CYTHON_REFNANNY")
code.putln("__Pyx_RefNanny = __Pyx_RefNannyImportAPI(\"refnanny\");")
code.putln("if (!__Pyx_RefNanny) {")
......@@ -2149,8 +2157,16 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln("/*--- Execution code ---*/")
code.mark_pos(None)
if profile or linetrace:
code.put_trace_call(header3, self.pos, nogil=not code.funcstate.gil_owned)
code.funcstate.can_trace = True
self.body.generate_execution_code(code)
if profile or linetrace:
code.funcstate.can_trace = False
code.put_trace_return("Py_None", nogil=not code.funcstate.gil_owned)
code.putln()
code.putln("/*--- Wrapped vars code ---*/")
self.generate_wrapped_entries_code(env, code)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment