gh-128045: Mark unknown opcodes as deopting to themselves (#128044)

* Mark unknown opcodes as deopting to themselves
This commit is contained in:
Dino Viehland 2025-05-19 10:15:16 -04:00 committed by GitHub
parent 71ea6a6798
commit cc9add695d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 39 additions and 0 deletions

View file

@ -1787,6 +1787,38 @@ const uint8_t _PyOpcode_Caches[256] = {
extern const uint8_t _PyOpcode_Deopt[256];
#ifdef NEED_OPCODE_METADATA
const uint8_t _PyOpcode_Deopt[256] = {
[119] = 119,
[120] = 120,
[121] = 121,
[122] = 122,
[123] = 123,
[124] = 124,
[125] = 125,
[126] = 126,
[127] = 127,
[211] = 211,
[212] = 212,
[213] = 213,
[214] = 214,
[215] = 215,
[216] = 216,
[217] = 217,
[218] = 218,
[219] = 219,
[220] = 220,
[221] = 221,
[222] = 222,
[223] = 223,
[224] = 224,
[225] = 225,
[226] = 226,
[227] = 227,
[228] = 228,
[229] = 229,
[230] = 230,
[231] = 231,
[232] = 232,
[233] = 233,
[BINARY_OP] = BINARY_OP,
[BINARY_OP_ADD_FLOAT] = BINARY_OP,
[BINARY_OP_ADD_INT] = BINARY_OP,

View file

@ -157,6 +157,13 @@ def generate_deopt_table(analysis: Analysis, out: CWriter) -> None:
if inst.family is not None:
deopt = inst.family.name
deopts.append((inst.name, deopt))
defined = set(analysis.opmap.values())
for i in range(256):
if i not in defined:
deopts.append((f'{i}', f'{i}'))
assert len(deopts) == 256
assert len(set(x[0] for x in deopts)) == 256
for name, deopt in sorted(deopts):
out.emit(f"[{name}] = {deopt},\n")
out.emit("};\n\n")