Lines Matching refs:pObj
120 static long long CallExternalTimer(ProfilerObject *pObj) in CallExternalTimer() argument
123 PyObject *o = PyObject_Call(pObj->externalTimer, empty_tuple, NULL); in CallExternalTimer()
125 PyErr_WriteUnraisable(pObj->externalTimer); in CallExternalTimer()
128 if (pObj->externalTimerUnit > 0.0) { in CallExternalTimer()
143 PyErr_WriteUnraisable(pObj->externalTimer); in CallExternalTimer()
149 #define CALL_TIMER(pObj) ((pObj)->externalTimer ? \ argument
150 CallExternalTimer(pObj) : \
226 newProfilerEntry(ProfilerObject *pObj, void *key, PyObject *userObj) in newProfilerEntry() argument
231 pObj->flags |= POF_NOMEMORY; in newProfilerEntry()
238 pObj->flags |= POF_NOMEMORY; in newProfilerEntry()
249 RotatingTree_Add(&pObj->profilerEntries, &self->header); in newProfilerEntry()
254 getEntry(ProfilerObject *pObj, void *key) in getEntry() argument
256 return (ProfilerEntry*) RotatingTree_Get(&pObj->profilerEntries, key); in getEntry()
260 getSubEntry(ProfilerObject *pObj, ProfilerEntry *caller, ProfilerEntry* entry) in getSubEntry() argument
267 newSubEntry(ProfilerObject *pObj, ProfilerEntry *caller, ProfilerEntry* entry) in newSubEntry() argument
272 pObj->flags |= POF_NOMEMORY; in newSubEntry()
301 static void clearEntries(ProfilerObject *pObj) in clearEntries() argument
303 RotatingTree_Enum(pObj->profilerEntries, freeEntry, NULL); in clearEntries()
304 pObj->profilerEntries = EMPTY_ROTATING_TREE; in clearEntries()
306 if (pObj->currentProfilerContext) { in clearEntries()
307 PyMem_Free(pObj->currentProfilerContext); in clearEntries()
308 pObj->currentProfilerContext = NULL; in clearEntries()
310 while (pObj->freelistProfilerContext) { in clearEntries()
311 ProfilerContext *c = pObj->freelistProfilerContext; in clearEntries()
312 pObj->freelistProfilerContext = c->previous; in clearEntries()
315 pObj->freelistProfilerContext = NULL; in clearEntries()
319 initContext(ProfilerObject *pObj, ProfilerContext *self, ProfilerEntry *entry) in initContext() argument
323 self->previous = pObj->currentProfilerContext; in initContext()
324 pObj->currentProfilerContext = self; in initContext()
326 if ((pObj->flags & POF_SUBCALLS) && self->previous) { in initContext()
329 ProfilerSubEntry *subentry = getSubEntry(pObj, caller, entry); in initContext()
331 subentry = newSubEntry(pObj, caller, entry); in initContext()
335 self->t0 = CALL_TIMER(pObj); in initContext()
339 Stop(ProfilerObject *pObj, ProfilerContext *self, ProfilerEntry *entry) in Stop() argument
341 long long tt = CALL_TIMER(pObj) - self->t0; in Stop()
345 pObj->currentProfilerContext = self->previous; in Stop()
352 if ((pObj->flags & POF_SUBCALLS) && self->previous) { in Stop()
355 ProfilerSubEntry *subentry = getSubEntry(pObj, caller, entry); in Stop()
372 ProfilerObject *pObj = (ProfilerObject*)self; in ptrace_enter_call() local
385 profEntry = getEntry(pObj, key); in ptrace_enter_call()
387 profEntry = newProfilerEntry(pObj, key, userObj); in ptrace_enter_call()
392 pContext = pObj->freelistProfilerContext; in ptrace_enter_call()
394 pObj->freelistProfilerContext = pContext->previous; in ptrace_enter_call()
401 pObj->flags |= POF_NOMEMORY; in ptrace_enter_call()
405 initContext(pObj, pContext, profEntry); in ptrace_enter_call()
415 ProfilerObject *pObj = (ProfilerObject*)self; in ptrace_leave_call() local
419 pContext = pObj->currentProfilerContext; in ptrace_leave_call()
422 profEntry = getEntry(pObj, key); in ptrace_leave_call()
424 Stop(pObj, pContext, profEntry); in ptrace_leave_call()
427 pObj->currentProfilerContext = pContext->previous; in ptrace_leave_call()
430 pContext->previous = pObj->freelistProfilerContext; in ptrace_leave_call()
431 pObj->freelistProfilerContext = pContext; in ptrace_leave_call()
486 pending_exception(ProfilerObject *pObj) in pending_exception() argument
488 if (pObj->flags & POF_NOMEMORY) { in pending_exception()
489 pObj->flags -= POF_NOMEMORY; in pending_exception()
629 profiler_getstats(ProfilerObject *pObj, PyObject* noarg) in profiler_getstats() argument
632 if (pending_exception(pObj)) in profiler_getstats()
634 if (!pObj->externalTimer) in profiler_getstats()
636 else if (pObj->externalTimerUnit > 0.0) in profiler_getstats()
637 collect.factor = pObj->externalTimerUnit; in profiler_getstats()
643 if (RotatingTree_Enum(pObj->profilerEntries, statsForEntry, &collect) in profiler_getstats()
652 setSubcalls(ProfilerObject *pObj, int nvalue) in setSubcalls() argument
655 pObj->flags &= ~POF_SUBCALLS; in setSubcalls()
657 pObj->flags |= POF_SUBCALLS; in setSubcalls()
662 setBuiltins(ProfilerObject *pObj, int nvalue) in setBuiltins() argument
665 pObj->flags &= ~POF_BUILTINS; in setBuiltins()
667 pObj->flags |= POF_BUILTINS; in setBuiltins()
699 flush_unmatched(ProfilerObject *pObj) in flush_unmatched() argument
701 while (pObj->currentProfilerContext) { in flush_unmatched()
702 ProfilerContext *pContext = pObj->currentProfilerContext; in flush_unmatched()
705 Stop(pObj, pContext, profEntry); in flush_unmatched()
707 pObj->currentProfilerContext = pContext->previous; in flush_unmatched()
738 profiler_clear(ProfilerObject *pObj, PyObject* noarg) in profiler_clear() argument
740 clearEntries(pObj); in profiler_clear()
756 profiler_init(ProfilerObject *pObj, PyObject *args, PyObject *kw) in profiler_init() argument
770 if (setSubcalls(pObj, subcalls) < 0 || setBuiltins(pObj, builtins) < 0) in profiler_init()
772 pObj->externalTimerUnit = timeunit; in profiler_init()
774 Py_XSETREF(pObj->externalTimer, timer); in profiler_init()