summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c45
1 files changed, 29 insertions, 16 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index a9d7c2f..b08427d 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -718,7 +718,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
return tstate->interp->eval_frame(f, throwflag);
}
-PyObject *
+PyObject* _Py_HOT_FUNCTION
_PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
{
#ifdef DXPAIRS
@@ -1424,6 +1424,12 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
PyObject *right = POP();
PyObject *left = TOP();
PyObject *sum;
+ /* NOTE(haypo): Please don't try to micro-optimize int+int on
+ CPython using bytecode, it is simply worthless.
+ See http://bugs.python.org/issue21955 and
+ http://bugs.python.org/issue10044 for the discussion. In short,
+ no patch shown any impact on a realistic benchmark, only a minor
+ speedup on microbenchmarks. */
if (PyUnicode_CheckExact(left) &&
PyUnicode_CheckExact(right)) {
sum = unicode_concatenate(left, right, f, next_instr);
@@ -1538,7 +1544,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
TARGET(SET_ADD) {
PyObject *v = POP();
- PyObject *set = stack_pointer[-oparg];
+ PyObject *set = PEEK(oparg);
int err;
err = PySet_Add(set, v);
Py_DECREF(v);
@@ -2399,8 +2405,10 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
TARGET(DELETE_DEREF) {
PyObject *cell = freevars[oparg];
- if (PyCell_GET(cell) != NULL) {
- PyCell_Set(cell, NULL);
+ PyObject *oldobj = PyCell_GET(cell);
+ if (oldobj != NULL) {
+ PyCell_SET(cell, NULL);
+ Py_DECREF(oldobj);
DISPATCH();
}
format_exc_unbound(co, oparg);
@@ -2797,7 +2805,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
PyObject *map;
int err;
STACKADJ(-2);
- map = stack_pointer[-oparg]; /* dict */
+ map = PEEK(oparg); /* dict */
assert(PyDict_CheckExact(map));
err = PyDict_SetItem(map, key, value); /* map[key] = value */
Py_DECREF(value);
@@ -4267,6 +4275,9 @@ do_raise(PyObject *exc, PyObject *cause)
goto raise_error;
}
+ assert(type != NULL);
+ assert(value != NULL);
+
if (cause) {
PyObject *fixed_cause;
if (PyExceptionClass_Check(cause)) {
@@ -4293,8 +4304,8 @@ do_raise(PyObject *exc, PyObject *cause)
PyErr_SetObject(type, value);
/* PyErr_SetObject incref's its arguments */
- Py_XDECREF(value);
- Py_XDECREF(type);
+ Py_DECREF(value);
+ Py_DECREF(type);
return 0;
raise_error:
@@ -4763,7 +4774,7 @@ if (tstate->use_tracing && tstate->c_profilefunc) { \
x = call; \
}
-static PyObject *
+static PyObject* _Py_HOT_FUNCTION
call_function(PyObject ***pp_stack, Py_ssize_t oparg, PyObject *kwnames)
{
PyObject **pfunc = (*pp_stack) - oparg - 1;
@@ -4836,7 +4847,7 @@ call_function(PyObject ***pp_stack, Py_ssize_t oparg, PyObject *kwnames)
done before evaluating the frame.
*/
-static PyObject*
+static PyObject* _Py_HOT_FUNCTION
_PyFunction_FastCall(PyCodeObject *co, PyObject **args, Py_ssize_t nargs,
PyObject *globals)
{
@@ -5342,8 +5353,10 @@ unicode_concatenate(PyObject *v, PyObject *w,
PyObject **freevars = (f->f_localsplus +
f->f_code->co_nlocals);
PyObject *c = freevars[oparg];
- if (PyCell_GET(c) == v)
- PyCell_Set(c, NULL);
+ if (PyCell_GET(c) == v) {
+ PyCell_SET(c, NULL);
+ Py_DECREF(v);
+ }
break;
}
case STORE_NAME:
@@ -5427,8 +5440,8 @@ _PyEval_RequestCodeExtraIndex(freefunc free)
static void
dtrace_function_entry(PyFrameObject *f)
{
- char* filename;
- char* funcname;
+ const char *filename;
+ const char *funcname;
int lineno;
filename = PyUnicode_AsUTF8(f->f_code->co_filename);
@@ -5441,8 +5454,8 @@ dtrace_function_entry(PyFrameObject *f)
static void
dtrace_function_return(PyFrameObject *f)
{
- char* filename;
- char* funcname;
+ const char *filename;
+ const char *funcname;
int lineno;
filename = PyUnicode_AsUTF8(f->f_code->co_filename);
@@ -5458,7 +5471,7 @@ maybe_dtrace_line(PyFrameObject *frame,
int *instr_lb, int *instr_ub, int *instr_prev)
{
int line = frame->f_lineno;
- char *co_filename, *co_name;
+ const char *co_filename, *co_name;
/* If the last instruction executed isn't in the current
instruction window, reset the window.