gh-101907: Stop using _Py_OPCODE and _Py_OPARG macros (GH-101912)

* gh-101907: Removes use of non-standard C++ extension from Include/cpython/code.h

* Make cases_generator correct on Windows
This commit is contained in:
Steve Dower 2023-02-20 14:56:48 +00:00 committed by GitHub
parent c00faf7943
commit a99eb5cd99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 200 additions and 184 deletions

View file

@ -339,9 +339,9 @@
DEOPT_IF(!PyUnicode_CheckExact(left), BINARY_OP);
DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP);
_Py_CODEUNIT true_next = next_instr[INLINE_CACHE_ENTRIES_BINARY_OP];
assert(_Py_OPCODE(true_next) == STORE_FAST ||
_Py_OPCODE(true_next) == STORE_FAST__LOAD_FAST);
PyObject **target_local = &GETLOCAL(_Py_OPARG(true_next));
assert(true_next.op.code == STORE_FAST ||
true_next.op.code == STORE_FAST__LOAD_FAST);
PyObject **target_local = &GETLOCAL(true_next.op.arg);
DEOPT_IF(*target_local != left, BINARY_OP);
STAT_INC(BINARY_OP, hit);
/* Handle `left = left + right` or `left += right` for str.
@ -2199,10 +2199,10 @@
Py_DECREF(left);
Py_DECREF(right);
if (cond == NULL) goto pop_2_error;
assert(_Py_OPCODE(next_instr[1]) == POP_JUMP_IF_FALSE ||
_Py_OPCODE(next_instr[1]) == POP_JUMP_IF_TRUE);
bool jump_on_true = _Py_OPCODE(next_instr[1]) == POP_JUMP_IF_TRUE;
int offset = _Py_OPARG(next_instr[1]);
assert(next_instr[1].op.code == POP_JUMP_IF_FALSE ||
next_instr[1].op.code == POP_JUMP_IF_TRUE);
bool jump_on_true = next_instr[1].op.code == POP_JUMP_IF_TRUE;
int offset = next_instr[1].op.arg;
int err = PyObject_IsTrue(cond);
Py_DECREF(cond);
if (err < 0) {
@ -2230,7 +2230,7 @@
_Py_DECREF_SPECIALIZED(left, _PyFloat_ExactDealloc);
_Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc);
if (sign_ish & oparg) {
int offset = _Py_OPARG(next_instr[1]);
int offset = next_instr[1].op.arg;
JUMPBY(offset);
}
STACK_SHRINK(2);
@ -2255,7 +2255,7 @@
_Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free);
_Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free);
if (sign_ish & oparg) {
int offset = _Py_OPARG(next_instr[1]);
int offset = next_instr[1].op.arg;
JUMPBY(offset);
}
STACK_SHRINK(2);
@ -2278,7 +2278,7 @@
assert((oparg & 0xf) == COMPARISON_NOT_EQUALS || (oparg & 0xf) == COMPARISON_EQUALS);
assert(COMPARISON_NOT_EQUALS + 1 == COMPARISON_EQUALS);
if ((res + COMPARISON_NOT_EQUALS) & oparg) {
int offset = _Py_OPARG(next_instr[1]);
int offset = next_instr[1].op.arg;
JUMPBY(offset);
}
STACK_SHRINK(2);
@ -2682,7 +2682,7 @@
_PyErr_Clear(tstate);
}
/* iterator ended normally */
assert(_Py_OPCODE(next_instr[INLINE_CACHE_ENTRIES_FOR_ITER + oparg]) == END_FOR);
assert(next_instr[INLINE_CACHE_ENTRIES_FOR_ITER + oparg].op.code == END_FOR);
Py_DECREF(iter);
STACK_SHRINK(1);
/* Jump forward oparg, then skip following END_FOR instruction */
@ -2761,7 +2761,7 @@
DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER);
STAT_INC(FOR_ITER, hit);
_Py_CODEUNIT next = next_instr[INLINE_CACHE_ENTRIES_FOR_ITER];
assert(_PyOpcode_Deopt[_Py_OPCODE(next)] == STORE_FAST);
assert(_PyOpcode_Deopt[next.op.code] == STORE_FAST);
if (r->len <= 0) {
STACK_SHRINK(1);
Py_DECREF(r);
@ -2772,7 +2772,7 @@
long value = r->start;
r->start = value + r->step;
r->len--;
if (_PyLong_AssignValue(&GETLOCAL(_Py_OPARG(next)), value) < 0) {
if (_PyLong_AssignValue(&GETLOCAL(next.op.arg), value) < 0) {
goto error;
}
// The STORE_FAST is already done.
@ -2795,7 +2795,7 @@
gen->gi_exc_state.previous_item = tstate->exc_info;
tstate->exc_info = &gen->gi_exc_state;
JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER + oparg);
assert(_Py_OPCODE(*next_instr) == END_FOR);
assert(next_instr->op.code == END_FOR);
DISPATCH_INLINED(gen_frame);
}
@ -3516,7 +3516,7 @@
STACK_SHRINK(3);
// CALL + POP_TOP
JUMPBY(INLINE_CACHE_ENTRIES_CALL + 1);
assert(_Py_OPCODE(next_instr[-1]) == POP_TOP);
assert(next_instr[-1].op.code == POP_TOP);
DISPATCH();
}
@ -3903,8 +3903,8 @@
TARGET(EXTENDED_ARG) {
assert(oparg);
assert(cframe.use_tracing == 0);
opcode = _Py_OPCODE(*next_instr);
oparg = oparg << 8 | _Py_OPARG(*next_instr);
opcode = next_instr->op.code;
oparg = oparg << 8 | next_instr->op.arg;
PRE_DISPATCH_GOTO();
DISPATCH_GOTO();
}