GH-94893: Ignore caches when adding LOAD_FAST_CHECKs (GH-94894)

This commit is contained in:
Brandt Bucher 2022-07-18 09:00:41 -07:00 committed by GitHub
parent 067f0da335
commit b407312a24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View file

@ -603,7 +603,8 @@ add_load_fast_null_checks(PyCodeObject *co)
int changed = 0;
_Py_CODEUNIT *instructions = _PyCode_CODE(co);
for (Py_ssize_t i = 0; i < Py_SIZE(co); i++) {
switch (_Py_OPCODE(instructions[i])) {
int opcode = _Py_OPCODE(instructions[i]);
switch (opcode) {
case LOAD_FAST:
case LOAD_FAST__LOAD_FAST:
case LOAD_FAST__LOAD_CONST:
@ -619,6 +620,7 @@ add_load_fast_null_checks(PyCodeObject *co)
_Py_SET_OPCODE(instructions[i], STORE_FAST);
break;
}
i += _PyOpcode_Caches[_PyOpcode_Deopt[opcode]];
}
if (changed) {
// invalidate cached co_code object