aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/bytecodes.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/bytecodes.c')
-rw-r--r--Python/bytecodes.c79
1 files changed, 37 insertions, 42 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index effc8e0b6f6..908eb0c2a69 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -2130,8 +2130,7 @@ dummy_func(
PyStackRef_CLOSE(self_st);
self_or_null = PyStackRef_NULL;
}
- PyStackRef_CLOSE(class_st);
- PyStackRef_CLOSE(global_super_st);
+ DECREF_INPUTS();
attr = PyStackRef_FromPyObjectSteal(attr_o);
}
@@ -2245,7 +2244,7 @@ dummy_func(
attr = PyStackRef_FromPyObjectNew(attr_o);
#endif
STAT_INC(LOAD_ATTR, hit);
- DECREF_INPUTS();
+ PyStackRef_CLOSE(owner);
}
macro(LOAD_ATTR_INSTANCE_VALUE) =
@@ -3671,15 +3670,14 @@ dummy_func(
EXIT_IF(!PyStackRef_IsNull(null[0]));
}
- op(_EXPAND_METHOD, (callable[1], null[1], unused[oparg] -- method[1], self[1], unused[oparg])) {
+ op(_EXPAND_METHOD, (callable[1], self_or_null[1], unused[oparg] -- callable[1], self_or_null[1], unused[oparg])) {
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable[0]);
- assert(PyStackRef_IsNull(null[0]));
- DEAD(null);
+ assert(PyStackRef_IsNull(self_or_null[0]));
assert(Py_TYPE(callable_o) == &PyMethod_Type);
- self[0] = PyStackRef_FromPyObjectNew(((PyMethodObject *)callable_o)->im_self);
+ self_or_null[0] = PyStackRef_FromPyObjectNew(((PyMethodObject *)callable_o)->im_self);
_PyStackRef temp = callable[0];
- method[0] = PyStackRef_FromPyObjectNew(((PyMethodObject *)callable_o)->im_func);
- assert(PyStackRef_FunctionCheck(method[0]));
+ callable[0] = PyStackRef_FromPyObjectNew(((PyMethodObject *)callable_o)->im_func);
+ assert(PyStackRef_FunctionCheck(callable[0]));
PyStackRef_CLOSE(temp);
}
@@ -3740,13 +3738,13 @@ dummy_func(
EXIT_IF(Py_TYPE(PyStackRef_AsPyObjectBorrow(callable[0])) != &PyMethod_Type);
}
- op(_INIT_CALL_BOUND_METHOD_EXACT_ARGS, (callable[1], null[1], unused[oparg] -- func[1], self[1], unused[oparg])) {
- DEAD(null);
+ op(_INIT_CALL_BOUND_METHOD_EXACT_ARGS, (callable[1], self_or_null[1], unused[oparg] -- callable[1], self_or_null[1], unused[oparg])) {
+ assert(PyStackRef_IsNull(self_or_null[0]));
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable[0]);
STAT_INC(CALL, hit);
- self[0] = PyStackRef_FromPyObjectNew(((PyMethodObject *)callable_o)->im_self);
+ self_or_null[0] = PyStackRef_FromPyObjectNew(((PyMethodObject *)callable_o)->im_self);
_PyStackRef temp = callable[0];
- func[0] = PyStackRef_FromPyObjectNew(((PyMethodObject *)callable_o)->im_func);
+ callable[0] = PyStackRef_FromPyObjectNew(((PyMethodObject *)callable_o)->im_func);
PyStackRef_CLOSE(temp);
}
@@ -4171,8 +4169,9 @@ dummy_func(
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable[0]);
int total_args = oparg;
+ _PyStackRef *arguments = args;
if (!PyStackRef_IsNull(self_or_null[0])) {
- args--;
+ arguments--;
total_args++;
}
@@ -4183,8 +4182,8 @@ dummy_func(
EXIT_IF(meth->ml_flags != METH_O);
// CPython promises to check all non-vectorcall function calls.
EXIT_IF(tstate->c_recursion_remaining <= 0);
- _PyStackRef arg_stackref = args[1];
- _PyStackRef self_stackref = args[0];
+ _PyStackRef arg_stackref = arguments[1];
+ _PyStackRef self_stackref = arguments[0];
EXIT_IF(!Py_IS_TYPE(PyStackRef_AsPyObjectBorrow(self_stackref),
method->d_common.d_type));
STAT_INC(CALL, hit);
@@ -4195,11 +4194,7 @@ dummy_func(
PyStackRef_AsPyObjectBorrow(arg_stackref));
_Py_LeaveRecursiveCallTstate(tstate);
assert((res_o != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
- PyStackRef_CLOSE(self_stackref);
- PyStackRef_CLOSE(arg_stackref);
- DEAD(args);
- DEAD(self_or_null);
- PyStackRef_CLOSE(callable[0]);
+ DECREF_INPUTS();
ERROR_IF(res_o == NULL, error);
res = PyStackRef_FromPyObjectSteal(res_o);
}
@@ -4486,15 +4481,14 @@ dummy_func(
EXIT_IF(!PyStackRef_IsNull(null[0]));
}
- op(_EXPAND_METHOD_KW, (callable[1], null[1], unused[oparg], unused -- method[1], self[1], unused[oparg], unused)) {
+ op(_EXPAND_METHOD_KW, (callable[1], self_or_null[1], unused[oparg], unused -- callable[1], self_or_null[1], unused[oparg], unused)) {
+ assert(PyStackRef_IsNull(self_or_null[0]));
_PyStackRef callable_s = callable[0];
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable_s);
-
- assert(PyStackRef_IsNull(null[0]));
assert(Py_TYPE(callable_o) == &PyMethod_Type);
- self[0] = PyStackRef_FromPyObjectNew(((PyMethodObject *)callable_o)->im_self);
- method[0] = PyStackRef_FromPyObjectNew(((PyMethodObject *)callable_o)->im_func);
- assert(PyStackRef_FunctionCheck(method[0]));
+ self_or_null[0] = PyStackRef_FromPyObjectNew(((PyMethodObject *)callable_o)->im_self);
+ callable[0] = PyStackRef_FromPyObjectNew(((PyMethodObject *)callable_o)->im_func);
+ assert(PyStackRef_FunctionCheck(callable[0]));
PyStackRef_CLOSE(callable_s);
}
@@ -4600,7 +4594,8 @@ dummy_func(
}
}
- op(_DO_CALL_FUNCTION_EX, (func_st, unused, callargs_st, kwargs_st -- result)) {
+ op(_DO_CALL_FUNCTION_EX, (func_st, null, callargs_st, kwargs_st -- result)) {
+ (void)null;
PyObject *func = PyStackRef_AsPyObjectBorrow(func_st);
// DICT_MERGE is called before this opcode if there are kwargs.
@@ -4671,8 +4666,8 @@ dummy_func(
result_o = PyObject_Call(func, callargs, kwargs);
}
PyStackRef_XCLOSE(kwargs_st);
- DEAD(kwargs_st);
PyStackRef_CLOSE(callargs_st);
+ DEAD(null);
PyStackRef_CLOSE(func_st);
ERROR_IF(result_o == NULL, error);
result = PyStackRef_FromPyObjectSteal(result_o);
@@ -4809,12 +4804,11 @@ dummy_func(
macro(BINARY_OP) = _SPECIALIZE_BINARY_OP + unused/4 + _BINARY_OP;
- pure inst(SWAP, (bottom_in, unused[oparg-2], top_in --
- top_out, unused[oparg-2], bottom_out)) {
- bottom_out = bottom_in;
- DEAD(bottom_in);
- top_out = top_in;
- DEAD(top_in);
+ pure inst(SWAP, (bottom[1], unused[oparg-2], top[1] --
+ bottom[1], unused[oparg-2], top[1])) {
+ _PyStackRef temp = bottom[0];
+ bottom[0] = top[0];
+ top[0] = temp;
assert(oparg >= 2);
}
@@ -5174,7 +5168,8 @@ dummy_func(
EXIT_TO_TIER1();
}
- tier2 op(_ERROR_POP_N, (target/2, unused[oparg] --)) {
+ tier2 op(_ERROR_POP_N, (target/2 --)) {
+ assert(oparg == 0);
frame->instr_ptr = _PyFrame_GetBytecode(frame) + target;
SYNC_SP();
GOTO_UNWIND();
@@ -5193,18 +5188,18 @@ dummy_func(
}
label(pop_4_error) {
- STACK_SHRINK(1);
- goto pop_3_error;
+ STACK_SHRINK(4);
+ goto error;
}
label(pop_3_error) {
- STACK_SHRINK(1);
- goto pop_2_error;
+ STACK_SHRINK(3);
+ goto error;
}
label(pop_2_error) {
- STACK_SHRINK(1);
- goto pop_1_error;
+ STACK_SHRINK(2);
+ goto error;
}
label(pop_1_error) {