@@ -3438,47 +3438,33 @@ err_args(PyObject *func, int flags, int nargs)
34383438 nargs );
34393439}
34403440
3441- #ifdef WITH_C_PROF
3442- #define BEGIN_C_TRACE \
3443- if (tstate->use_tracing) { \
3441+ #define C_TRACE (call ) \
3442+ if (tstate->use_tracing && tstate->c_profilefunc) { \
3443+ if (call_trace(tstate->c_profilefunc, \
3444+ tstate->c_profileobj, \
3445+ tstate->frame, PyTrace_C_CALL, \
3446+ func)) \
3447+ { return NULL; } \
3448+ call; \
34443449 if (tstate->c_profilefunc != NULL) { \
3445- PyObject *func_name = \
3446- PyString_FromString (((PyCFunctionObject *) \
3447- func)->m_ml->ml_name); \
3448- are_tracing = 1; \
3449- if (call_trace(tstate->c_profilefunc, \
3450- tstate->c_profileobj, \
3451- tstate->frame, PyTrace_C_CALL, \
3452- func_name)) \
3453- { return NULL; } \
3454- Py_DECREF (func_name); \
3450+ if (x == NULL) { \
3451+ if (call_trace (tstate->c_profilefunc, \
3452+ tstate->c_profileobj, \
3453+ tstate->frame, PyTrace_C_EXCEPTION, \
3454+ func)) \
3455+ { return NULL; } \
3456+ } else { \
3457+ if (call_trace(tstate->c_profilefunc, \
3458+ tstate->c_profileobj, \
3459+ tstate->frame, PyTrace_C_RETURN, \
3460+ func)) \
3461+ { return NULL; } \
34553462 } \
3463+ } \
3464+ } else { \
3465+ call; \
34563466 }
34573467
3458- #define END_C_TRACE \
3459- if (tstate->use_tracing && are_tracing) { \
3460- if (tstate->c_profilefunc != NULL) { \
3461- if (x == NULL) { \
3462- if (call_trace (tstate->c_profilefunc, \
3463- tstate->c_profileobj, \
3464- tstate->frame, PyTrace_C_EXCEPTION, \
3465- NULL)) \
3466- { return NULL; } \
3467- } else { \
3468- if (call_trace(tstate->c_profilefunc, \
3469- tstate->c_profileobj, \
3470- tstate->frame, PyTrace_C_RETURN, \
3471- NULL)) \
3472- { return NULL; } \
3473- } \
3474- } \
3475- }
3476- #else
3477- #define BEGIN_C_TRACE
3478- #define END_C_TRACE
3479- #endif
3480-
3481-
34823468static PyObject *
34833469call_function (PyObject * * * pp_stack , int oparg
34843470#ifdef WITH_TSC
@@ -3493,30 +3479,22 @@ call_function(PyObject ***pp_stack, int oparg
34933479 PyObject * func = * pfunc ;
34943480 PyObject * x , * w ;
34953481
3496- #ifdef WITH_C_PROF
3497- int are_tracing = 0 ;
3498- PyThreadState * tstate = PyThreadState_GET ();
3499- #endif
3500-
35013482 /* Always dispatch PyCFunction first, because these are
35023483 presumed to be the most frequent callable object.
35033484 */
35043485 if (PyCFunction_Check (func ) && nk == 0 ) {
35053486 int flags = PyCFunction_GET_FLAGS (func );
35063487 PCALL (PCALL_CFUNCTION );
3488+ PyThreadState * tstate = PyThreadState_GET ();
35073489 if (flags & (METH_NOARGS | METH_O )) {
35083490 PyCFunction meth = PyCFunction_GET_FUNCTION (func );
35093491 PyObject * self = PyCFunction_GET_SELF (func );
35103492 if (flags & METH_NOARGS && na == 0 ) {
3511- BEGIN_C_TRACE
3512- x = (* meth )(self , NULL );
3513- END_C_TRACE
3493+ C_TRACE (x = (* meth )(self ,NULL ));
35143494 }
35153495 else if (flags & METH_O && na == 1 ) {
35163496 PyObject * arg = EXT_POP (* pp_stack );
3517- BEGIN_C_TRACE
3518- x = (* meth )(self , arg );
3519- END_C_TRACE
3497+ C_TRACE (x = (* meth )(self ,arg ));
35203498 Py_DECREF (arg );
35213499 }
35223500 else {
@@ -3527,15 +3505,13 @@ call_function(PyObject ***pp_stack, int oparg
35273505 else {
35283506 PyObject * callargs ;
35293507 callargs = load_args (pp_stack , na );
3530- BEGIN_C_TRACE
35313508#ifdef WITH_TSC
35323509 rdtscll (* pintr0 );
35333510#endif
3534- x = PyCFunction_Call (func , callargs , NULL );
3511+ C_TRACE ( x = PyCFunction_Call (func ,callargs ,NULL ) );
35353512#ifdef WITH_TSC
35363513 rdtscll (* pintr1 );
35373514#endif
3538- END_C_TRACE
35393515 Py_XDECREF (callargs );
35403516 }
35413517 } else {
0 commit comments