summaryrefslogtreecommitdiffstats
path: root/Python/bytecodes.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/bytecodes.c')
-rw-r--r--Python/bytecodes.c46
1 files changed, 14 insertions, 32 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index b38d37a..e92c5d8 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -270,7 +270,6 @@ dummy_func(
else {
res = Py_False;
}
- Py_INCREF(res);
}
inst(UNARY_INVERT, (value -- res)) {
@@ -967,7 +966,7 @@ dummy_func(
if (PyErr_GivenExceptionMatches(exc_value, PyExc_StopIteration)) {
value = Py_NewRef(((PyStopIterationObject *)exc_value)->value);
DECREF_INPUTS();
- none = Py_NewRef(Py_None);
+ none = Py_None;
}
else {
_PyErr_SetRaisedException(tstate, Py_NewRef(exc_value));
@@ -1452,7 +1451,7 @@ dummy_func(
DECREF_INPUTS();
ERROR_IF(true, error);
}
- Py_DECREF(none_val);
+ assert(Py_IsNone(none_val));
DECREF_INPUTS();
}
@@ -1993,7 +1992,6 @@ dummy_func(
_Py_DECREF_SPECIALIZED(left, _PyFloat_ExactDealloc);
_Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc);
res = (sign_ish & oparg) ? Py_True : Py_False;
- Py_INCREF(res);
}
// Similar to COMPARE_OP_FLOAT
@@ -2012,7 +2010,6 @@ dummy_func(
_Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free);
_Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free);
res = (sign_ish & oparg) ? Py_True : Py_False;
- Py_INCREF(res);
}
// Similar to COMPARE_OP_FLOAT, but for ==, != only
@@ -2028,20 +2025,19 @@ dummy_func(
assert((oparg & 0xf) == COMPARISON_NOT_EQUALS || (oparg & 0xf) == COMPARISON_EQUALS);
assert(COMPARISON_NOT_EQUALS + 1 == COMPARISON_EQUALS);
res = ((COMPARISON_NOT_EQUALS + eq) & oparg) ? Py_True : Py_False;
- Py_INCREF(res);
}
inst(IS_OP, (left, right -- b)) {
int res = Py_Is(left, right) ^ oparg;
DECREF_INPUTS();
- b = Py_NewRef(res ? Py_True : Py_False);
+ b = res ? Py_True : Py_False;
}
inst(CONTAINS_OP, (left, right -- b)) {
int res = PySequence_Contains(right, left);
DECREF_INPUTS();
ERROR_IF(res < 0, error);
- b = Py_NewRef((res^oparg) ? Py_True : Py_False);
+ b = (res ^ oparg) ? Py_True : Py_False;
}
inst(CHECK_EG_MATCH, (exc_value, match_type -- rest, match)) {
@@ -2074,7 +2070,7 @@ dummy_func(
int res = PyErr_GivenExceptionMatches(left, right);
DECREF_INPUTS();
- b = Py_NewRef(res ? Py_True : Py_False);
+ b = res ? Py_True : Py_False;
}
inst(IMPORT_NAME, (level, fromlist -- res)) {
@@ -2101,14 +2097,10 @@ dummy_func(
}
inst(POP_JUMP_IF_FALSE, (cond -- )) {
- if (Py_IsTrue(cond)) {
- _Py_DECREF_NO_DEALLOC(cond);
- }
- else if (Py_IsFalse(cond)) {
- _Py_DECREF_NO_DEALLOC(cond);
+ if (Py_IsFalse(cond)) {
JUMPBY(oparg);
}
- else {
+ else if (!Py_IsTrue(cond)) {
int err = PyObject_IsTrue(cond);
DECREF_INPUTS();
if (err == 0) {
@@ -2121,14 +2113,10 @@ dummy_func(
}
inst(POP_JUMP_IF_TRUE, (cond -- )) {
- if (Py_IsFalse(cond)) {
- _Py_DECREF_NO_DEALLOC(cond);
- }
- else if (Py_IsTrue(cond)) {
- _Py_DECREF_NO_DEALLOC(cond);
+ if (Py_IsTrue(cond)) {
JUMPBY(oparg);
}
- else {
+ else if (!Py_IsFalse(cond)) {
int err = PyObject_IsTrue(cond);
DECREF_INPUTS();
if (err > 0) {
@@ -2145,14 +2133,10 @@ dummy_func(
DECREF_INPUTS();
JUMPBY(oparg);
}
- else {
- _Py_DECREF_NO_DEALLOC(value);
- }
}
inst(POP_JUMP_IF_NONE, (value -- )) {
if (Py_IsNone(value)) {
- _Py_DECREF_NO_DEALLOC(value);
JUMPBY(oparg);
}
else {
@@ -2188,19 +2172,19 @@ dummy_func(
}
else {
ERROR_IF(_PyErr_Occurred(tstate), error); // Error!
- attrs = Py_NewRef(Py_None); // Failure!
+ attrs = Py_None; // Failure!
}
}
inst(MATCH_MAPPING, (subject -- subject, res)) {
int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_MAPPING;
- res = Py_NewRef(match ? Py_True : Py_False);
+ res = match ? Py_True : Py_False;
PREDICT(POP_JUMP_IF_FALSE);
}
inst(MATCH_SEQUENCE, (subject -- subject, res)) {
int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_SEQUENCE;
- res = Py_NewRef(match ? Py_True : Py_False);
+ res = match ? Py_True : Py_False;
PREDICT(POP_JUMP_IF_FALSE);
}
@@ -2392,7 +2376,7 @@ dummy_func(
STAT_INC(FOR_ITER, hit);
_PyInterpreterFrame *gen_frame = (_PyInterpreterFrame *)gen->gi_iframe;
frame->return_offset = oparg;
- _PyFrame_StackPush(gen_frame, Py_NewRef(Py_None));
+ _PyFrame_StackPush(gen_frame, Py_None);
gen->gi_frame_state = FRAME_EXECUTING;
gen->gi_exc_state.previous_item = tstate->exc_info;
tstate->exc_info = &gen->gi_exc_state;
@@ -2499,7 +2483,7 @@ dummy_func(
prev_exc = exc_info->exc_value;
}
else {
- prev_exc = Py_NewRef(Py_None);
+ prev_exc = Py_None;
}
assert(PyExceptionInstance_Check(new_exc));
exc_info->exc_value = Py_NewRef(new_exc);
@@ -3393,7 +3377,6 @@ dummy_func(
_Py_CODEUNIT *here = next_instr-1;
int offset;
if (Py_IsNone(value)) {
- _Py_DECREF_NO_DEALLOC(value);
offset = oparg;
}
else {
@@ -3408,7 +3391,6 @@ dummy_func(
_Py_CODEUNIT *here = next_instr-1;
int offset;
if (Py_IsNone(value)) {
- _Py_DECREF_NO_DEALLOC(value);
offset = 0;
}
else {