[Python-checkins] python/dist/src/Python ceval.c,2.404,2.405
mondragon at users.sourceforge.net
mondragon at users.sourceforge.net
Fri Jun 25 19:31:09 EDT 2004
Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23805/Python
Modified Files:
ceval.c
Log Message:
Massive performance improvement for C extension and builtin tracing code
Index: ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.404
retrieving revision 2.405
diff -C2 -d -r2.404 -r2.405
*** ceval.c 22 Jun 2004 15:37:51 -0000 2.404
--- ceval.c 25 Jun 2004 23:31:06 -0000 2.405
***************
*** 3439,3482 ****
}
! #ifdef WITH_C_PROF
! #define BEGIN_C_TRACE \
! if (tstate->use_tracing) { \
if (tstate->c_profilefunc != NULL) { \
! PyObject *func_name = \
! PyString_FromString (((PyCFunctionObject *) \
! func)->m_ml->ml_name); \
! are_tracing = 1; \
! if (call_trace(tstate->c_profilefunc, \
! tstate->c_profileobj, \
! tstate->frame, PyTrace_C_CALL, \
! func_name)) \
! { return NULL; } \
! Py_DECREF (func_name); \
! } \
! }
!
! #define END_C_TRACE \
! if (tstate->use_tracing && are_tracing) { \
! if (tstate->c_profilefunc != NULL) { \
! if (x == NULL) { \
! if (call_trace (tstate->c_profilefunc, \
! tstate->c_profileobj, \
! tstate->frame, PyTrace_C_EXCEPTION, \
! NULL)) \
! { return NULL; } \
! } else { \
! if (call_trace(tstate->c_profilefunc, \
! tstate->c_profileobj, \
! tstate->frame, PyTrace_C_RETURN, \
! NULL)) \
! { return NULL; } \
! } \
} \
}
- #else
- #define BEGIN_C_TRACE
- #define END_C_TRACE
- #endif
-
static PyObject *
--- 3439,3468 ----
}
! #define C_TRACE(call) \
! if (tstate->use_tracing && tstate->c_profilefunc) { \
! if (call_trace(tstate->c_profilefunc, \
! tstate->c_profileobj, \
! tstate->frame, PyTrace_C_CALL, \
! func)) \
! { return NULL; } \
! call; \
if (tstate->c_profilefunc != NULL) { \
! if (x == NULL) { \
! if (call_trace (tstate->c_profilefunc, \
! tstate->c_profileobj, \
! tstate->frame, PyTrace_C_EXCEPTION, \
! func)) \
! { return NULL; } \
! } else { \
! if (call_trace(tstate->c_profilefunc, \
! tstate->c_profileobj, \
! tstate->frame, PyTrace_C_RETURN, \
! func)) \
! { return NULL; } \
} \
+ } \
+ } else { \
+ call; \
}
static PyObject *
***************
*** 3494,3502 ****
PyObject *x, *w;
- #ifdef WITH_C_PROF
- int are_tracing = 0;
- PyThreadState *tstate = PyThreadState_GET();
- #endif
-
/* Always dispatch PyCFunction first, because these are
presumed to be the most frequent callable object.
--- 3480,3483 ----
***************
*** 3505,3521 ****
int flags = PyCFunction_GET_FLAGS(func);
PCALL(PCALL_CFUNCTION);
if (flags & (METH_NOARGS | METH_O)) {
PyCFunction meth = PyCFunction_GET_FUNCTION(func);
PyObject *self = PyCFunction_GET_SELF(func);
if (flags & METH_NOARGS && na == 0) {
! BEGIN_C_TRACE
! x = (*meth)(self, NULL);
! END_C_TRACE
}
else if (flags & METH_O && na == 1) {
PyObject *arg = EXT_POP(*pp_stack);
! BEGIN_C_TRACE
! x = (*meth)(self, arg);
! END_C_TRACE
Py_DECREF(arg);
}
--- 3486,3499 ----
int flags = PyCFunction_GET_FLAGS(func);
PCALL(PCALL_CFUNCTION);
+ PyThreadState *tstate = PyThreadState_GET();
if (flags & (METH_NOARGS | METH_O)) {
PyCFunction meth = PyCFunction_GET_FUNCTION(func);
PyObject *self = PyCFunction_GET_SELF(func);
if (flags & METH_NOARGS && na == 0) {
! C_TRACE(x=(*meth)(self,NULL));
}
else if (flags & METH_O && na == 1) {
PyObject *arg = EXT_POP(*pp_stack);
! C_TRACE(x=(*meth)(self,arg));
Py_DECREF(arg);
}
***************
*** 3528,3540 ****
PyObject *callargs;
callargs = load_args(pp_stack, na);
- BEGIN_C_TRACE
#ifdef WITH_TSC
rdtscll(*pintr0);
#endif
! x = PyCFunction_Call(func, callargs, NULL);
#ifdef WITH_TSC
rdtscll(*pintr1);
#endif
- END_C_TRACE
Py_XDECREF(callargs);
}
--- 3506,3516 ----
PyObject *callargs;
callargs = load_args(pp_stack, na);
#ifdef WITH_TSC
rdtscll(*pintr0);
#endif
! C_TRACE(x=PyCFunction_Call(func,callargs,NULL));
#ifdef WITH_TSC
rdtscll(*pintr1);
#endif
Py_XDECREF(callargs);
}
More information about the Python-checkins
mailing list