Kaydet (Commit) e2176020 authored tarafından Thomas Wouters's avatar Thomas Wouters

Try harder to stay within the 79-column limit. There's still two places that go…

Try harder to stay within the 79-column limit. There's still two places that go (way) over, but those are harder to fix without suffering in readability.
üst efa7d51e
...@@ -28,8 +28,9 @@ ...@@ -28,8 +28,9 @@
typedef unsigned long long uint64; typedef unsigned long long uint64;
#if defined(__ppc__) /* <- Don't know if this is the correct symbol; this #if defined(__ppc__) /* <- Don't know if this is the correct symbol; this
section should work for GCC on any PowerPC platform, section should work for GCC on any PowerPC
irrespective of OS. POWER? Who knows :-) */ platform, irrespective of OS.
POWER? Who knows :-) */
#define READ_TIMESTAMP(var) ppc_getcounter(&var) #define READ_TIMESTAMP(var) ppc_getcounter(&var)
...@@ -93,7 +94,8 @@ static PyObject * call_function(PyObject ***, int); ...@@ -93,7 +94,8 @@ static PyObject * call_function(PyObject ***, int);
static PyObject * fast_function(PyObject *, PyObject ***, int, int, int); static PyObject * fast_function(PyObject *, PyObject ***, int, int, int);
static PyObject * do_call(PyObject *, PyObject ***, int, int); static PyObject * do_call(PyObject *, PyObject ***, int, int);
static PyObject * ext_do_call(PyObject *, PyObject ***, int, int, int); static PyObject * ext_do_call(PyObject *, PyObject ***, int, int, int);
static PyObject * update_keyword_args(PyObject *, int, PyObject ***,PyObject *); static PyObject * update_keyword_args(PyObject *, int, PyObject ***,
PyObject *);
static PyObject * update_star_args(int, int, PyObject *, PyObject ***); static PyObject * update_star_args(int, int, PyObject *, PyObject ***);
static PyObject * load_args(PyObject ***, int); static PyObject * load_args(PyObject ***, int);
#define CALL_FLAG_VAR 1 #define CALL_FLAG_VAR 1
...@@ -504,7 +506,8 @@ PyEval_EvalCode(PyCodeObject *co, PyObject *globals, PyObject *locals) ...@@ -504,7 +506,8 @@ PyEval_EvalCode(PyCodeObject *co, PyObject *globals, PyObject *locals)
PyObject * PyObject *
PyEval_EvalFrame(PyFrameObject *f) { PyEval_EvalFrame(PyFrameObject *f) {
/* This is for backward compatibility with extension modules that /* This is for backward compatibility with extension modules that
used this API; core interpreter code should call PyEval_EvalFrameEx() */ used this API; core interpreter code should call
PyEval_EvalFrameEx() */
return PyEval_EvalFrameEx(f, 0); return PyEval_EvalFrameEx(f, 0);
} }
...@@ -514,7 +517,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) ...@@ -514,7 +517,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
#ifdef DXPAIRS #ifdef DXPAIRS
int lastopcode = 0; int lastopcode = 0;
#endif #endif
register PyObject **stack_pointer; /* Next free slot in value stack */ register PyObject **stack_pointer; /* Next free slot in value stack */
register unsigned char *next_instr; register unsigned char *next_instr;
register int opcode; /* Current opcode */ register int opcode; /* Current opcode */
register int oparg; /* Current opcode argument, if any */ register int oparg; /* Current opcode argument, if any */
...@@ -607,10 +610,10 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) ...@@ -607,10 +610,10 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
#define JUMPBY(x) (next_instr += (x)) #define JUMPBY(x) (next_instr += (x))
/* OpCode prediction macros /* OpCode prediction macros
Some opcodes tend to come in pairs thus making it possible to predict Some opcodes tend to come in pairs thus making it possible to
the second code when the first is run. For example, COMPARE_OP is often predict the second code when the first is run. For example,
followed by JUMP_IF_FALSE or JUMP_IF_TRUE. And, those opcodes are often COMPARE_OP is often followed by JUMP_IF_FALSE or JUMP_IF_TRUE. And,
followed by a POP_TOP. those opcodes are often followed by a POP_TOP.
Verifying the prediction costs a single high-speed test of register Verifying the prediction costs a single high-speed test of register
variable against a constant. If the pairing was good, then the variable against a constant. If the pairing was good, then the
...@@ -657,11 +660,13 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) ...@@ -657,11 +660,13 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
#define PUSH(v) { (void)(BASIC_PUSH(v), \ #define PUSH(v) { (void)(BASIC_PUSH(v), \
lltrace && prtrace(TOP(), "push")); \ lltrace && prtrace(TOP(), "push")); \
assert(STACK_LEVEL() <= co->co_stacksize); } assert(STACK_LEVEL() <= co->co_stacksize); }
#define POP() ((void)(lltrace && prtrace(TOP(), "pop")), BASIC_POP()) #define POP() ((void)(lltrace && prtrace(TOP(), "pop")), \
BASIC_POP())
#define STACKADJ(n) { (void)(BASIC_STACKADJ(n), \ #define STACKADJ(n) { (void)(BASIC_STACKADJ(n), \
lltrace && prtrace(TOP(), "stackadj")); \ lltrace && prtrace(TOP(), "stackadj")); \
assert(STACK_LEVEL() <= co->co_stacksize); } assert(STACK_LEVEL() <= co->co_stacksize); }
#define EXT_POP(STACK_POINTER) (lltrace && prtrace((STACK_POINTER)[-1], "ext_pop"), *--(STACK_POINTER)) #define EXT_POP(STACK_POINTER) (lltrace && prtrace((STACK_POINTER)[-1], \
"ext_pop"), *--(STACK_POINTER))
#else #else
#define PUSH(v) BASIC_PUSH(v) #define PUSH(v) BASIC_PUSH(v)
#define POP() BASIC_POP() #define POP() BASIC_POP()
...@@ -1696,7 +1701,8 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) ...@@ -1696,7 +1701,8 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
why == WHY_CONTINUE) why == WHY_CONTINUE)
retval = POP(); retval = POP();
} }
else if (PyExceptionClass_Check(v) || PyString_Check(v)) { else if (PyExceptionClass_Check(v) ||
PyString_Check(v)) {
w = POP(); w = POP();
u = POP(); u = POP();
PyErr_Restore(v, w, u); PyErr_Restore(v, w, u);
...@@ -1745,7 +1751,8 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) ...@@ -1745,7 +1751,8 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
if ((x = f->f_locals) != NULL) { if ((x = f->f_locals) != NULL) {
if ((err = PyObject_DelItem(x, w)) != 0) if ((err = PyObject_DelItem(x, w)) != 0)
format_exc_check_arg(PyExc_NameError, format_exc_check_arg(PyExc_NameError,
NAME_ERROR_MSG ,w); NAME_ERROR_MSG,
w);
break; break;
} }
PyErr_Format(PyExc_SystemError, PyErr_Format(PyExc_SystemError,
...@@ -1756,8 +1763,10 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) ...@@ -1756,8 +1763,10 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
PREDICTED_WITH_ARG(UNPACK_SEQUENCE); PREDICTED_WITH_ARG(UNPACK_SEQUENCE);
case UNPACK_SEQUENCE: case UNPACK_SEQUENCE:
v = POP(); v = POP();
if (PyTuple_CheckExact(v) && PyTuple_GET_SIZE(v) == oparg) { if (PyTuple_CheckExact(v) &&
PyObject **items = ((PyTupleObject *)v)->ob_item; PyTuple_GET_SIZE(v) == oparg) {
PyObject **items = \
((PyTupleObject *)v)->ob_item;
while (oparg--) { while (oparg--) {
w = items[oparg]; w = items[oparg];
Py_INCREF(w); Py_INCREF(w);
...@@ -1765,15 +1774,17 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) ...@@ -1765,15 +1774,17 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
} }
Py_DECREF(v); Py_DECREF(v);
continue; continue;
} else if (PyList_CheckExact(v) && PyList_GET_SIZE(v) == oparg) { } else if (PyList_CheckExact(v) &&
PyObject **items = ((PyListObject *)v)->ob_item; PyList_GET_SIZE(v) == oparg) {
PyObject **items = \
((PyListObject *)v)->ob_item;
while (oparg--) { while (oparg--) {
w = items[oparg]; w = items[oparg];
Py_INCREF(w); Py_INCREF(w);
PUSH(w); PUSH(w);
} }
} else if (unpack_iterable(v, oparg, } else if (unpack_iterable(v, oparg,
stack_pointer + oparg)) { stack_pointer + oparg)) {
stack_pointer += oparg; stack_pointer += oparg;
} else { } else {
/* unpack_iterable() raised an exception */ /* unpack_iterable() raised an exception */
...@@ -1831,7 +1842,8 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) ...@@ -1831,7 +1842,8 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
else { else {
x = PyObject_GetItem(v, w); x = PyObject_GetItem(v, w);
if (x == NULL && PyErr_Occurred()) { if (x == NULL && PyErr_Occurred()) {
if (!PyErr_ExceptionMatches(PyExc_KeyError)) if (!PyErr_ExceptionMatches(
PyExc_KeyError))
break; break;
PyErr_Clear(); PyErr_Clear();
} }
...@@ -1843,7 +1855,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) ...@@ -1843,7 +1855,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
if (x == NULL) { if (x == NULL) {
format_exc_check_arg( format_exc_check_arg(
PyExc_NameError, PyExc_NameError,
NAME_ERROR_MSG ,w); NAME_ERROR_MSG, w);
break; break;
} }
} }
...@@ -1944,13 +1956,10 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) ...@@ -1944,13 +1956,10 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
UNBOUNDLOCAL_ERROR_MSG, UNBOUNDLOCAL_ERROR_MSG,
v); v);
} else { } else {
v = PyTuple_GET_ITEM( v = PyTuple_GET_ITEM(co->co_freevars, oparg -
co->co_freevars, PyTuple_GET_SIZE(co->co_cellvars));
oparg - PyTuple_GET_SIZE(co->co_cellvars)); format_exc_check_arg(PyExc_NameError,
format_exc_check_arg( UNBOUNDFREE_ERROR_MSG, v);
PyExc_NameError,
UNBOUNDFREE_ERROR_MSG,
v);
} }
break; break;
...@@ -2177,7 +2186,8 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) ...@@ -2177,7 +2186,8 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
continue; continue;
} }
if (PyErr_Occurred()) { if (PyErr_Occurred()) {
if (!PyErr_ExceptionMatches(PyExc_StopIteration)) if (!PyErr_ExceptionMatches(
PyExc_StopIteration))
break; break;
PyErr_Clear(); PyErr_Clear();
} }
...@@ -2203,9 +2213,10 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) ...@@ -2203,9 +2213,10 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
case SETUP_LOOP: case SETUP_LOOP:
case SETUP_EXCEPT: case SETUP_EXCEPT:
case SETUP_FINALLY: case SETUP_FINALLY:
/* NOTE: If you add any new block-setup opcodes that are /* NOTE: If you add any new block-setup opcodes that
not try/except/finally handlers, you may need to are not try/except/finally handlers, you may need
update the PyGen_NeedsFinalizing() function. */ to update the PyGen_NeedsFinalizing() function.
*/
PyFrame_BlockSetup(f, opcode, INSTR_OFFSET() + oparg, PyFrame_BlockSetup(f, opcode, INSTR_OFFSET() + oparg,
STACK_LEVEL()); STACK_LEVEL());
...@@ -4001,10 +4012,9 @@ cmp_outcome(int op, register PyObject *v, register PyObject *w) ...@@ -4001,10 +4012,9 @@ cmp_outcome(int op, register PyObject *v, register PyObject *w)
if (PyString_Check(exc)) { if (PyString_Check(exc)) {
int ret_val; int ret_val;
ret_val = PyErr_WarnEx( ret_val = PyErr_WarnEx(
PyExc_DeprecationWarning, PyExc_DeprecationWarning,
"catching of string " "catching of string "
"exceptions is " "exceptions is deprecated", 1);
"deprecated", 1);
if (ret_val == -1) if (ret_val == -1)
return NULL; return NULL;
} }
...@@ -4016,8 +4026,7 @@ cmp_outcome(int op, register PyObject *v, register PyObject *w) ...@@ -4016,8 +4026,7 @@ cmp_outcome(int op, register PyObject *v, register PyObject *w)
ret_val = PyErr_WarnEx( ret_val = PyErr_WarnEx(
PyExc_DeprecationWarning, PyExc_DeprecationWarning,
"catching of string " "catching of string "
"exceptions is deprecated", "exceptions is deprecated", 1);
1);
if (ret_val == -1) if (ret_val == -1)
return NULL; return NULL;
} }
...@@ -4295,8 +4304,9 @@ string_concatenate(PyObject *v, PyObject *w, ...@@ -4295,8 +4304,9 @@ string_concatenate(PyObject *v, PyObject *w,
if (v->ob_refcnt == 2) { if (v->ob_refcnt == 2) {
/* In the common case, there are 2 references to the value /* In the common case, there are 2 references to the value
* stored in 'variable' when the += is performed: one on the * stored in 'variable' when the += is performed: one on the
* value stack (in 'v') and one still stored in the 'variable'. * value stack (in 'v') and one still stored in the
* We try to delete the variable now to reduce the refcnt to 1. * 'variable'. We try to delete the variable now to reduce
* the refcnt to 1.
*/ */
switch (*next_instr) { switch (*next_instr) {
case STORE_FAST: case STORE_FAST:
...@@ -4309,7 +4319,8 @@ string_concatenate(PyObject *v, PyObject *w, ...@@ -4309,7 +4319,8 @@ string_concatenate(PyObject *v, PyObject *w,
} }
case STORE_DEREF: case STORE_DEREF:
{ {
PyObject **freevars = f->f_localsplus + f->f_code->co_nlocals; PyObject **freevars = (f->f_localsplus +
f->f_code->co_nlocals);
PyObject *c = freevars[PEEKARG()]; PyObject *c = freevars[PEEKARG()];
if (PyCell_GET(c) == v) if (PyCell_GET(c) == v)
PyCell_Set(c, NULL); PyCell_Set(c, NULL);
...@@ -4337,10 +4348,10 @@ string_concatenate(PyObject *v, PyObject *w, ...@@ -4337,10 +4348,10 @@ string_concatenate(PyObject *v, PyObject *w,
*/ */
if (_PyString_Resize(&v, new_len) != 0) { if (_PyString_Resize(&v, new_len) != 0) {
/* XXX if _PyString_Resize() fails, 'v' has been /* XXX if _PyString_Resize() fails, 'v' has been
* deallocated so it cannot be put back into 'variable'. * deallocated so it cannot be put back into
* The MemoryError is raised when there is no value in * 'variable'. The MemoryError is raised when there
* 'variable', which might (very remotely) be a cause * is no value in 'variable', which might (very
* of incompatibilities. * remotely) be a cause of incompatibilities.
*/ */
return NULL; return NULL;
} }
......
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