mirror of
https://github.com/python/cpython.git
synced 2025-07-19 01:05:26 +00:00
GH-95113: Don't use EXTENDED_ARG_QUICK in unquickened code (GH-95121)
This commit is contained in:
parent
79d2f549ad
commit
e402b26b7f
8 changed files with 20 additions and 200 deletions
|
@ -5631,8 +5631,16 @@ handle_eval_breaker:
|
|||
assert(oparg);
|
||||
oparg <<= 8;
|
||||
oparg |= _Py_OPARG(*next_instr);
|
||||
// We might be tracing. To avoid breaking tracing guarantees in
|
||||
// quickened instructions, always deoptimize the next opcode:
|
||||
opcode = _PyOpcode_Deopt[_Py_OPCODE(*next_instr)];
|
||||
PRE_DISPATCH_GOTO();
|
||||
// CPython hasn't traced the following instruction historically
|
||||
// (DO_TRACING would clobber our extended oparg anyways), so just
|
||||
// skip our usual cframe.use_tracing check before dispatch. Also,
|
||||
// make sure the next instruction isn't a RESUME, since that needs
|
||||
// to trace properly (and shouldn't have an extended arg anyways):
|
||||
assert(opcode != RESUME);
|
||||
DISPATCH_GOTO();
|
||||
}
|
||||
|
||||
|
|
|
@ -211,13 +211,13 @@ write_instr(_Py_CODEUNIT *codestr, struct instr *instruction, int ilen)
|
|||
int caches = _PyOpcode_Caches[opcode];
|
||||
switch (ilen - caches) {
|
||||
case 4:
|
||||
*codestr++ = _Py_MAKECODEUNIT(EXTENDED_ARG_QUICK, (oparg >> 24) & 0xFF);
|
||||
*codestr++ = _Py_MAKECODEUNIT(EXTENDED_ARG, (oparg >> 24) & 0xFF);
|
||||
/* fall through */
|
||||
case 3:
|
||||
*codestr++ = _Py_MAKECODEUNIT(EXTENDED_ARG_QUICK, (oparg >> 16) & 0xFF);
|
||||
*codestr++ = _Py_MAKECODEUNIT(EXTENDED_ARG, (oparg >> 16) & 0xFF);
|
||||
/* fall through */
|
||||
case 2:
|
||||
*codestr++ = _Py_MAKECODEUNIT(EXTENDED_ARG_QUICK, (oparg >> 8) & 0xFF);
|
||||
*codestr++ = _Py_MAKECODEUNIT(EXTENDED_ARG, (oparg >> 8) & 0xFF);
|
||||
/* fall through */
|
||||
case 1:
|
||||
*codestr++ = _Py_MAKECODEUNIT(opcode, oparg & 0xFF);
|
||||
|
|
|
@ -295,6 +295,9 @@ _PyCode_Quicken(PyCodeObject *code)
|
|||
else {
|
||||
assert(!_PyOpcode_Caches[opcode]);
|
||||
switch (opcode) {
|
||||
case EXTENDED_ARG:
|
||||
_Py_SET_OPCODE(instructions[i], EXTENDED_ARG_QUICK);
|
||||
break;
|
||||
case JUMP_BACKWARD:
|
||||
_Py_SET_OPCODE(instructions[i], JUMP_BACKWARD_QUICK);
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue