[Python-checkins] python/dist/src/Python ceval.c,2.389,2.390
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Tue Apr 6 05:37:37 EDT 2004
Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5777
Modified Files:
ceval.c
Log Message:
Coded WHY flags as bitfields (taking inspiration from tp_flags).
This allows multiple flags to be tested in a single compare
which eliminates unnecessary compares and saves a few bytes.
Index: ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.389
retrieving revision 2.390
diff -C2 -d -r2.389 -r2.390
*** ceval.c 5 Apr 2004 19:36:21 -0000 2.389
--- ceval.c 6 Apr 2004 09:37:35 -0000 2.390
***************
*** 538,552 ****
/* Status code for main loop (reason for stack unwind) */
! enum why_code {
! WHY_NOT, /* No error */
! WHY_EXCEPTION, /* Exception occurred */
! WHY_RERAISE, /* Exception re-raised by 'finally' */
! WHY_RETURN, /* 'return' statement */
! WHY_BREAK, /* 'break' statement */
! WHY_CONTINUE, /* 'continue' statement */
! WHY_YIELD /* 'yield' operator */
! };
! static enum why_code do_raise(PyObject *, PyObject *, PyObject *);
static int unpack_iterable(PyObject *, int, PyObject **);
--- 538,550 ----
/* Status code for main loop (reason for stack unwind) */
! #define WHY_NOT 0x0001
! #define WHY_EXCEPTION 0x0002
! #define WHY_RERAISE 0x0004
! #define WHY_RETURN 0x0008
! #define WHY_BREAK 0x0010
! #define WHY_CONTINUE 0x0020
! #define WHY_YIELD 0x0040
! static int do_raise(PyObject *, PyObject *, PyObject *);
static int unpack_iterable(PyObject *, int, PyObject **);
***************
*** 581,585 ****
register int opcode=0; /* Current opcode */
register int oparg=0; /* Current opcode argument, if any */
! register enum why_code why; /* Reason for block stack unwind */
register int err; /* Error status -- nonzero if error */
register PyObject *x; /* Result object -- NULL if error */
--- 579,583 ----
register int opcode=0; /* Current opcode */
register int oparg=0; /* Current opcode argument, if any */
! register int why; /* Reason for block stack unwind */
register int err; /* Error status -- nonzero if error */
register PyObject *x; /* Result object -- NULL if error */
***************
*** 1653,1660 ****
v = POP();
if (PyInt_Check(v)) {
! why = (enum why_code) PyInt_AS_LONG(v);
assert(why != WHY_YIELD);
! if (why == WHY_RETURN ||
! why == WHY_CONTINUE)
retval = POP();
}
--- 1651,1657 ----
v = POP();
if (PyInt_Check(v)) {
! why = (int) PyInt_AS_LONG(v);
assert(why != WHY_YIELD);
! if (why & (WHY_RETURN | WHY_CONTINUE))
retval = POP();
}
***************
*** 2289,2293 ****
/* Double-check exception status */
! if (why == WHY_EXCEPTION || why == WHY_RERAISE) {
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_SystemError,
--- 2286,2290 ----
/* Double-check exception status */
! if (why & (WHY_EXCEPTION | WHY_RERAISE)) {
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_SystemError,
***************
*** 2380,2385 ****
}
else {
! if (why == WHY_RETURN ||
! why == WHY_CONTINUE)
PUSH(retval);
v = PyInt_FromLong((long)why);
--- 2377,2381 ----
}
else {
! if (why & (WHY_RETURN | WHY_CONTINUE))
PUSH(retval);
v = PyInt_FromLong((long)why);
***************
*** 2412,2416 ****
if (tstate->use_tracing) {
if (tstate->c_tracefunc
! && (why == WHY_RETURN || why == WHY_YIELD)) {
if (call_trace(tstate->c_tracefunc,
tstate->c_traceobj, f,
--- 2408,2412 ----
if (tstate->use_tracing) {
if (tstate->c_tracefunc
! && (why & (WHY_RETURN | WHY_YIELD))) {
if (call_trace(tstate->c_tracefunc,
tstate->c_traceobj, f,
***************
*** 2839,2843 ****
/* Logic for the raise statement (too complicated for inlining).
This *consumes* a reference count to each of its arguments. */
! static enum why_code
do_raise(PyObject *type, PyObject *value, PyObject *tb)
{
--- 2835,2839 ----
/* Logic for the raise statement (too complicated for inlining).
This *consumes* a reference count to each of its arguments. */
! static int
do_raise(PyObject *type, PyObject *value, PyObject *tb)
{
More information about the Python-checkins
mailing list