diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 1f7014e9cd426f..f304a9644e25a2 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -1752,6 +1752,14 @@ iterations of the loop. .. versionadded:: 3.13 +.. opcode:: MATCH_CLASS_ISINSTANCE + + Read match subject ``Stack[-2]`` and the type object ``Stack[-1]`` from stack. + Pop ``Stack[-1]`` and push ``True`` or ``False`` for the result of :func:`isinstance`. + + .. versionadded:: 3.15 + + .. opcode:: MATCH_CLASS (count) ``STACK[-1]`` is a tuple of keyword attribute names, ``STACK[-2]`` is the class diff --git a/Include/internal/pycore_magic_number.h b/Include/internal/pycore_magic_number.h index 3fcf650426d36d..95f97fb8430a74 100644 --- a/Include/internal/pycore_magic_number.h +++ b/Include/internal/pycore_magic_number.h @@ -292,6 +292,7 @@ Known values: Python 3.15a4 3659 (Add CALL_FUNCTION_EX specialization) Python 3.15a4 3660 (Change generator preamble code) Python 3.15a4 3661 (Lazy imports IMPORT_NAME opcode changes) + Python 3.15a7 3662 (Add MATCH_CLASS_ISINSTANCE opcode) Python 3.16 will start with 3700 @@ -305,7 +306,7 @@ PC/launcher.c must also be updated. */ -#define PYC_MAGIC_NUMBER 3661 +#define PYC_MAGIC_NUMBER 3662 /* This is equivalent to converting PYC_MAGIC_NUMBER to 2 bytes (little-endian) and then appending b'\r\n'. */ #define PYC_MAGIC_NUMBER_TOKEN \ diff --git a/Include/internal/pycore_opcode_metadata.h b/Include/internal/pycore_opcode_metadata.h index c64d4e8ba85b3d..aa356d7845316a 100644 --- a/Include/internal/pycore_opcode_metadata.h +++ b/Include/internal/pycore_opcode_metadata.h @@ -386,6 +386,8 @@ int _PyOpcode_num_popped(int opcode, int oparg) { return 3 + (oparg - 1); case MATCH_CLASS: return 3; + case MATCH_CLASS_ISINSTANCE: + return 2; case MATCH_KEYS: return 2; case MATCH_MAPPING: @@ -877,6 +879,8 @@ int _PyOpcode_num_pushed(int opcode, int oparg) { return 1 + (oparg - 1); case MATCH_CLASS: return 1; + case MATCH_CLASS_ISINSTANCE: + return 2; case MATCH_KEYS: return 3; case MATCH_MAPPING: @@ -1261,6 +1265,7 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[267] = { [MAKE_FUNCTION] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, [MAP_ADD] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, [MATCH_CLASS] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [MATCH_CLASS_ISINSTANCE] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, [MATCH_KEYS] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, [MATCH_MAPPING] = { true, INSTR_FMT_IX, 0 }, [MATCH_SEQUENCE] = { true, INSTR_FMT_IX, 0 }, @@ -1479,6 +1484,7 @@ _PyOpcode_macro_expansion[256] = { [MAKE_FUNCTION] = { .nuops = 1, .uops = { { _MAKE_FUNCTION, OPARG_SIMPLE, 0 } } }, [MAP_ADD] = { .nuops = 1, .uops = { { _MAP_ADD, OPARG_SIMPLE, 0 } } }, [MATCH_CLASS] = { .nuops = 4, .uops = { { _MATCH_CLASS, OPARG_SIMPLE, 0 }, { _POP_TOP, OPARG_SIMPLE, 0 }, { _POP_TOP, OPARG_SIMPLE, 0 }, { _POP_TOP, OPARG_SIMPLE, 0 } } }, + [MATCH_CLASS_ISINSTANCE] = { .nuops = 1, .uops = { { _MATCH_CLASS_ISINSTANCE, OPARG_SIMPLE, 0 } } }, [MATCH_KEYS] = { .nuops = 1, .uops = { { _MATCH_KEYS, OPARG_SIMPLE, 0 } } }, [MATCH_MAPPING] = { .nuops = 1, .uops = { { _MATCH_MAPPING, OPARG_SIMPLE, 0 } } }, [MATCH_SEQUENCE] = { .nuops = 1, .uops = { { _MATCH_SEQUENCE, OPARG_SIMPLE, 0 } } }, @@ -1714,6 +1720,7 @@ const char *_PyOpcode_OpName[267] = { [MAKE_FUNCTION] = "MAKE_FUNCTION", [MAP_ADD] = "MAP_ADD", [MATCH_CLASS] = "MATCH_CLASS", + [MATCH_CLASS_ISINSTANCE] = "MATCH_CLASS_ISINSTANCE", [MATCH_KEYS] = "MATCH_KEYS", [MATCH_MAPPING] = "MATCH_MAPPING", [MATCH_SEQUENCE] = "MATCH_SEQUENCE", @@ -1811,7 +1818,6 @@ const uint8_t _PyOpcode_Caches[256] = { PyAPI_DATA(const uint8_t) _PyOpcode_Deopt[256]; #ifdef NEED_OPCODE_METADATA const uint8_t _PyOpcode_Deopt[256] = { - [121] = 121, [122] = 122, [123] = 123, [124] = 124, @@ -2007,6 +2013,7 @@ const uint8_t _PyOpcode_Deopt[256] = { [MAKE_FUNCTION] = MAKE_FUNCTION, [MAP_ADD] = MAP_ADD, [MATCH_CLASS] = MATCH_CLASS, + [MATCH_CLASS_ISINSTANCE] = MATCH_CLASS_ISINSTANCE, [MATCH_KEYS] = MATCH_KEYS, [MATCH_MAPPING] = MATCH_MAPPING, [MATCH_SEQUENCE] = MATCH_SEQUENCE, @@ -2072,7 +2079,6 @@ const uint8_t _PyOpcode_Deopt[256] = { #endif // NEED_OPCODE_METADATA #define EXTRA_CASES \ - case 121: \ case 122: \ case 123: \ case 124: \ diff --git a/Include/internal/pycore_uop_ids.h b/Include/internal/pycore_uop_ids.h index 0fdeb56122ecc7..16d9047b601fd8 100644 --- a/Include/internal/pycore_uop_ids.h +++ b/Include/internal/pycore_uop_ids.h @@ -294,6 +294,7 @@ extern "C" { #define _MAKE_WARM 520 #define _MAP_ADD MAP_ADD #define _MATCH_CLASS 521 +#define _MATCH_CLASS_ISINSTANCE MATCH_CLASS_ISINSTANCE #define _MATCH_KEYS MATCH_KEYS #define _MATCH_MAPPING MATCH_MAPPING #define _MATCH_SEQUENCE MATCH_SEQUENCE @@ -1073,220 +1074,221 @@ extern "C" { #define _MAKE_WARM_r33 1273 #define _MAP_ADD_r20 1274 #define _MATCH_CLASS_r33 1275 -#define _MATCH_KEYS_r23 1276 -#define _MATCH_MAPPING_r02 1277 -#define _MATCH_MAPPING_r12 1278 -#define _MATCH_MAPPING_r23 1279 -#define _MATCH_SEQUENCE_r02 1280 -#define _MATCH_SEQUENCE_r12 1281 -#define _MATCH_SEQUENCE_r23 1282 -#define _MAYBE_EXPAND_METHOD_r00 1283 -#define _MAYBE_EXPAND_METHOD_KW_r11 1284 -#define _MONITOR_CALL_r00 1285 -#define _MONITOR_CALL_KW_r11 1286 -#define _MONITOR_JUMP_BACKWARD_r00 1287 -#define _MONITOR_JUMP_BACKWARD_r11 1288 -#define _MONITOR_JUMP_BACKWARD_r22 1289 -#define _MONITOR_JUMP_BACKWARD_r33 1290 -#define _MONITOR_RESUME_r00 1291 -#define _NOP_r00 1292 -#define _NOP_r11 1293 -#define _NOP_r22 1294 -#define _NOP_r33 1295 -#define _POP_CALL_r20 1296 -#define _POP_CALL_LOAD_CONST_INLINE_BORROW_r21 1297 -#define _POP_CALL_ONE_r30 1298 -#define _POP_CALL_ONE_LOAD_CONST_INLINE_BORROW_r31 1299 -#define _POP_CALL_TWO_r30 1300 -#define _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW_r31 1301 -#define _POP_EXCEPT_r10 1302 -#define _POP_ITER_r20 1303 -#define _POP_JUMP_IF_FALSE_r00 1304 -#define _POP_JUMP_IF_FALSE_r10 1305 -#define _POP_JUMP_IF_FALSE_r21 1306 -#define _POP_JUMP_IF_FALSE_r32 1307 -#define _POP_JUMP_IF_TRUE_r00 1308 -#define _POP_JUMP_IF_TRUE_r10 1309 -#define _POP_JUMP_IF_TRUE_r21 1310 -#define _POP_JUMP_IF_TRUE_r32 1311 -#define _POP_TOP_r10 1312 -#define _POP_TOP_FLOAT_r00 1313 -#define _POP_TOP_FLOAT_r10 1314 -#define _POP_TOP_FLOAT_r21 1315 -#define _POP_TOP_FLOAT_r32 1316 -#define _POP_TOP_INT_r00 1317 -#define _POP_TOP_INT_r10 1318 -#define _POP_TOP_INT_r21 1319 -#define _POP_TOP_INT_r32 1320 -#define _POP_TOP_LOAD_CONST_INLINE_r11 1321 -#define _POP_TOP_LOAD_CONST_INLINE_BORROW_r11 1322 -#define _POP_TOP_NOP_r00 1323 -#define _POP_TOP_NOP_r10 1324 -#define _POP_TOP_NOP_r21 1325 -#define _POP_TOP_NOP_r32 1326 -#define _POP_TOP_UNICODE_r00 1327 -#define _POP_TOP_UNICODE_r10 1328 -#define _POP_TOP_UNICODE_r21 1329 -#define _POP_TOP_UNICODE_r32 1330 -#define _POP_TWO_r20 1331 -#define _POP_TWO_LOAD_CONST_INLINE_BORROW_r21 1332 -#define _PUSH_EXC_INFO_r02 1333 -#define _PUSH_EXC_INFO_r12 1334 -#define _PUSH_EXC_INFO_r23 1335 -#define _PUSH_FRAME_r10 1336 -#define _PUSH_NULL_r01 1337 -#define _PUSH_NULL_r12 1338 -#define _PUSH_NULL_r23 1339 -#define _PUSH_NULL_CONDITIONAL_r00 1340 -#define _PY_FRAME_EX_r31 1341 -#define _PY_FRAME_GENERAL_r01 1342 -#define _PY_FRAME_KW_r11 1343 -#define _QUICKEN_RESUME_r00 1344 -#define _QUICKEN_RESUME_r11 1345 -#define _QUICKEN_RESUME_r22 1346 -#define _QUICKEN_RESUME_r33 1347 -#define _REPLACE_WITH_TRUE_r02 1348 -#define _REPLACE_WITH_TRUE_r12 1349 -#define _REPLACE_WITH_TRUE_r23 1350 -#define _RESUME_CHECK_r00 1351 -#define _RESUME_CHECK_r11 1352 -#define _RESUME_CHECK_r22 1353 -#define _RESUME_CHECK_r33 1354 -#define _RETURN_GENERATOR_r01 1355 -#define _RETURN_VALUE_r11 1356 -#define _SAVE_RETURN_OFFSET_r00 1357 -#define _SAVE_RETURN_OFFSET_r11 1358 -#define _SAVE_RETURN_OFFSET_r22 1359 -#define _SAVE_RETURN_OFFSET_r33 1360 -#define _SEND_r22 1361 -#define _SEND_GEN_FRAME_r22 1362 -#define _SETUP_ANNOTATIONS_r00 1363 -#define _SET_ADD_r10 1364 -#define _SET_FUNCTION_ATTRIBUTE_r01 1365 -#define _SET_FUNCTION_ATTRIBUTE_r11 1366 -#define _SET_FUNCTION_ATTRIBUTE_r21 1367 -#define _SET_FUNCTION_ATTRIBUTE_r32 1368 -#define _SET_IP_r00 1369 -#define _SET_IP_r11 1370 -#define _SET_IP_r22 1371 -#define _SET_IP_r33 1372 -#define _SET_UPDATE_r10 1373 -#define _SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r02 1374 -#define _SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r12 1375 -#define _SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r22 1376 -#define _SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r32 1377 -#define _SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r03 1378 -#define _SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r13 1379 -#define _SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r23 1380 -#define _SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r33 1381 -#define _SPILL_OR_RELOAD_r01 1382 -#define _SPILL_OR_RELOAD_r02 1383 -#define _SPILL_OR_RELOAD_r03 1384 -#define _SPILL_OR_RELOAD_r10 1385 -#define _SPILL_OR_RELOAD_r12 1386 -#define _SPILL_OR_RELOAD_r13 1387 -#define _SPILL_OR_RELOAD_r20 1388 -#define _SPILL_OR_RELOAD_r21 1389 -#define _SPILL_OR_RELOAD_r23 1390 -#define _SPILL_OR_RELOAD_r30 1391 -#define _SPILL_OR_RELOAD_r31 1392 -#define _SPILL_OR_RELOAD_r32 1393 -#define _START_EXECUTOR_r00 1394 -#define _STORE_ATTR_r20 1395 -#define _STORE_ATTR_INSTANCE_VALUE_r21 1396 -#define _STORE_ATTR_SLOT_r21 1397 -#define _STORE_ATTR_WITH_HINT_r21 1398 -#define _STORE_DEREF_r10 1399 -#define _STORE_FAST_LOAD_FAST_r11 1400 -#define _STORE_FAST_STORE_FAST_r20 1401 -#define _STORE_GLOBAL_r10 1402 -#define _STORE_NAME_r10 1403 -#define _STORE_SLICE_r30 1404 -#define _STORE_SUBSCR_r30 1405 -#define _STORE_SUBSCR_DICT_r31 1406 -#define _STORE_SUBSCR_LIST_INT_r32 1407 -#define _SWAP_r11 1408 -#define _SWAP_2_r02 1409 -#define _SWAP_2_r12 1410 -#define _SWAP_2_r22 1411 -#define _SWAP_2_r33 1412 -#define _SWAP_3_r03 1413 -#define _SWAP_3_r13 1414 -#define _SWAP_3_r23 1415 -#define _SWAP_3_r33 1416 -#define _SWAP_FAST_r01 1417 -#define _SWAP_FAST_r11 1418 -#define _SWAP_FAST_r22 1419 -#define _SWAP_FAST_r33 1420 -#define _SWAP_FAST_0_r01 1421 -#define _SWAP_FAST_0_r11 1422 -#define _SWAP_FAST_0_r22 1423 -#define _SWAP_FAST_0_r33 1424 -#define _SWAP_FAST_1_r01 1425 -#define _SWAP_FAST_1_r11 1426 -#define _SWAP_FAST_1_r22 1427 -#define _SWAP_FAST_1_r33 1428 -#define _SWAP_FAST_2_r01 1429 -#define _SWAP_FAST_2_r11 1430 -#define _SWAP_FAST_2_r22 1431 -#define _SWAP_FAST_2_r33 1432 -#define _SWAP_FAST_3_r01 1433 -#define _SWAP_FAST_3_r11 1434 -#define _SWAP_FAST_3_r22 1435 -#define _SWAP_FAST_3_r33 1436 -#define _SWAP_FAST_4_r01 1437 -#define _SWAP_FAST_4_r11 1438 -#define _SWAP_FAST_4_r22 1439 -#define _SWAP_FAST_4_r33 1440 -#define _SWAP_FAST_5_r01 1441 -#define _SWAP_FAST_5_r11 1442 -#define _SWAP_FAST_5_r22 1443 -#define _SWAP_FAST_5_r33 1444 -#define _SWAP_FAST_6_r01 1445 -#define _SWAP_FAST_6_r11 1446 -#define _SWAP_FAST_6_r22 1447 -#define _SWAP_FAST_6_r33 1448 -#define _SWAP_FAST_7_r01 1449 -#define _SWAP_FAST_7_r11 1450 -#define _SWAP_FAST_7_r22 1451 -#define _SWAP_FAST_7_r33 1452 -#define _TIER2_RESUME_CHECK_r00 1453 -#define _TIER2_RESUME_CHECK_r11 1454 -#define _TIER2_RESUME_CHECK_r22 1455 -#define _TIER2_RESUME_CHECK_r33 1456 -#define _TO_BOOL_r11 1457 -#define _TO_BOOL_BOOL_r01 1458 -#define _TO_BOOL_BOOL_r11 1459 -#define _TO_BOOL_BOOL_r22 1460 -#define _TO_BOOL_BOOL_r33 1461 -#define _TO_BOOL_INT_r02 1462 -#define _TO_BOOL_INT_r12 1463 -#define _TO_BOOL_INT_r23 1464 -#define _TO_BOOL_LIST_r02 1465 -#define _TO_BOOL_LIST_r12 1466 -#define _TO_BOOL_LIST_r23 1467 -#define _TO_BOOL_NONE_r01 1468 -#define _TO_BOOL_NONE_r11 1469 -#define _TO_BOOL_NONE_r22 1470 -#define _TO_BOOL_NONE_r33 1471 -#define _TO_BOOL_STR_r02 1472 -#define _TO_BOOL_STR_r12 1473 -#define _TO_BOOL_STR_r23 1474 -#define _TRACE_RECORD_r00 1475 -#define _UNARY_INVERT_r12 1476 -#define _UNARY_NEGATIVE_r12 1477 -#define _UNARY_NOT_r01 1478 -#define _UNARY_NOT_r11 1479 -#define _UNARY_NOT_r22 1480 -#define _UNARY_NOT_r33 1481 -#define _UNPACK_EX_r10 1482 -#define _UNPACK_SEQUENCE_r10 1483 -#define _UNPACK_SEQUENCE_LIST_r10 1484 -#define _UNPACK_SEQUENCE_TUPLE_r10 1485 -#define _UNPACK_SEQUENCE_TWO_TUPLE_r12 1486 -#define _WITH_EXCEPT_START_r33 1487 -#define _YIELD_VALUE_r11 1488 -#define MAX_UOP_REGS_ID 1488 +#define _MATCH_CLASS_ISINSTANCE_r22 1276 +#define _MATCH_KEYS_r23 1277 +#define _MATCH_MAPPING_r02 1278 +#define _MATCH_MAPPING_r12 1279 +#define _MATCH_MAPPING_r23 1280 +#define _MATCH_SEQUENCE_r02 1281 +#define _MATCH_SEQUENCE_r12 1282 +#define _MATCH_SEQUENCE_r23 1283 +#define _MAYBE_EXPAND_METHOD_r00 1284 +#define _MAYBE_EXPAND_METHOD_KW_r11 1285 +#define _MONITOR_CALL_r00 1286 +#define _MONITOR_CALL_KW_r11 1287 +#define _MONITOR_JUMP_BACKWARD_r00 1288 +#define _MONITOR_JUMP_BACKWARD_r11 1289 +#define _MONITOR_JUMP_BACKWARD_r22 1290 +#define _MONITOR_JUMP_BACKWARD_r33 1291 +#define _MONITOR_RESUME_r00 1292 +#define _NOP_r00 1293 +#define _NOP_r11 1294 +#define _NOP_r22 1295 +#define _NOP_r33 1296 +#define _POP_CALL_r20 1297 +#define _POP_CALL_LOAD_CONST_INLINE_BORROW_r21 1298 +#define _POP_CALL_ONE_r30 1299 +#define _POP_CALL_ONE_LOAD_CONST_INLINE_BORROW_r31 1300 +#define _POP_CALL_TWO_r30 1301 +#define _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW_r31 1302 +#define _POP_EXCEPT_r10 1303 +#define _POP_ITER_r20 1304 +#define _POP_JUMP_IF_FALSE_r00 1305 +#define _POP_JUMP_IF_FALSE_r10 1306 +#define _POP_JUMP_IF_FALSE_r21 1307 +#define _POP_JUMP_IF_FALSE_r32 1308 +#define _POP_JUMP_IF_TRUE_r00 1309 +#define _POP_JUMP_IF_TRUE_r10 1310 +#define _POP_JUMP_IF_TRUE_r21 1311 +#define _POP_JUMP_IF_TRUE_r32 1312 +#define _POP_TOP_r10 1313 +#define _POP_TOP_FLOAT_r00 1314 +#define _POP_TOP_FLOAT_r10 1315 +#define _POP_TOP_FLOAT_r21 1316 +#define _POP_TOP_FLOAT_r32 1317 +#define _POP_TOP_INT_r00 1318 +#define _POP_TOP_INT_r10 1319 +#define _POP_TOP_INT_r21 1320 +#define _POP_TOP_INT_r32 1321 +#define _POP_TOP_LOAD_CONST_INLINE_r11 1322 +#define _POP_TOP_LOAD_CONST_INLINE_BORROW_r11 1323 +#define _POP_TOP_NOP_r00 1324 +#define _POP_TOP_NOP_r10 1325 +#define _POP_TOP_NOP_r21 1326 +#define _POP_TOP_NOP_r32 1327 +#define _POP_TOP_UNICODE_r00 1328 +#define _POP_TOP_UNICODE_r10 1329 +#define _POP_TOP_UNICODE_r21 1330 +#define _POP_TOP_UNICODE_r32 1331 +#define _POP_TWO_r20 1332 +#define _POP_TWO_LOAD_CONST_INLINE_BORROW_r21 1333 +#define _PUSH_EXC_INFO_r02 1334 +#define _PUSH_EXC_INFO_r12 1335 +#define _PUSH_EXC_INFO_r23 1336 +#define _PUSH_FRAME_r10 1337 +#define _PUSH_NULL_r01 1338 +#define _PUSH_NULL_r12 1339 +#define _PUSH_NULL_r23 1340 +#define _PUSH_NULL_CONDITIONAL_r00 1341 +#define _PY_FRAME_EX_r31 1342 +#define _PY_FRAME_GENERAL_r01 1343 +#define _PY_FRAME_KW_r11 1344 +#define _QUICKEN_RESUME_r00 1345 +#define _QUICKEN_RESUME_r11 1346 +#define _QUICKEN_RESUME_r22 1347 +#define _QUICKEN_RESUME_r33 1348 +#define _REPLACE_WITH_TRUE_r02 1349 +#define _REPLACE_WITH_TRUE_r12 1350 +#define _REPLACE_WITH_TRUE_r23 1351 +#define _RESUME_CHECK_r00 1352 +#define _RESUME_CHECK_r11 1353 +#define _RESUME_CHECK_r22 1354 +#define _RESUME_CHECK_r33 1355 +#define _RETURN_GENERATOR_r01 1356 +#define _RETURN_VALUE_r11 1357 +#define _SAVE_RETURN_OFFSET_r00 1358 +#define _SAVE_RETURN_OFFSET_r11 1359 +#define _SAVE_RETURN_OFFSET_r22 1360 +#define _SAVE_RETURN_OFFSET_r33 1361 +#define _SEND_r22 1362 +#define _SEND_GEN_FRAME_r22 1363 +#define _SETUP_ANNOTATIONS_r00 1364 +#define _SET_ADD_r10 1365 +#define _SET_FUNCTION_ATTRIBUTE_r01 1366 +#define _SET_FUNCTION_ATTRIBUTE_r11 1367 +#define _SET_FUNCTION_ATTRIBUTE_r21 1368 +#define _SET_FUNCTION_ATTRIBUTE_r32 1369 +#define _SET_IP_r00 1370 +#define _SET_IP_r11 1371 +#define _SET_IP_r22 1372 +#define _SET_IP_r33 1373 +#define _SET_UPDATE_r10 1374 +#define _SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r02 1375 +#define _SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r12 1376 +#define _SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r22 1377 +#define _SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r32 1378 +#define _SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r03 1379 +#define _SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r13 1380 +#define _SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r23 1381 +#define _SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r33 1382 +#define _SPILL_OR_RELOAD_r01 1383 +#define _SPILL_OR_RELOAD_r02 1384 +#define _SPILL_OR_RELOAD_r03 1385 +#define _SPILL_OR_RELOAD_r10 1386 +#define _SPILL_OR_RELOAD_r12 1387 +#define _SPILL_OR_RELOAD_r13 1388 +#define _SPILL_OR_RELOAD_r20 1389 +#define _SPILL_OR_RELOAD_r21 1390 +#define _SPILL_OR_RELOAD_r23 1391 +#define _SPILL_OR_RELOAD_r30 1392 +#define _SPILL_OR_RELOAD_r31 1393 +#define _SPILL_OR_RELOAD_r32 1394 +#define _START_EXECUTOR_r00 1395 +#define _STORE_ATTR_r20 1396 +#define _STORE_ATTR_INSTANCE_VALUE_r21 1397 +#define _STORE_ATTR_SLOT_r21 1398 +#define _STORE_ATTR_WITH_HINT_r21 1399 +#define _STORE_DEREF_r10 1400 +#define _STORE_FAST_LOAD_FAST_r11 1401 +#define _STORE_FAST_STORE_FAST_r20 1402 +#define _STORE_GLOBAL_r10 1403 +#define _STORE_NAME_r10 1404 +#define _STORE_SLICE_r30 1405 +#define _STORE_SUBSCR_r30 1406 +#define _STORE_SUBSCR_DICT_r31 1407 +#define _STORE_SUBSCR_LIST_INT_r32 1408 +#define _SWAP_r11 1409 +#define _SWAP_2_r02 1410 +#define _SWAP_2_r12 1411 +#define _SWAP_2_r22 1412 +#define _SWAP_2_r33 1413 +#define _SWAP_3_r03 1414 +#define _SWAP_3_r13 1415 +#define _SWAP_3_r23 1416 +#define _SWAP_3_r33 1417 +#define _SWAP_FAST_r01 1418 +#define _SWAP_FAST_r11 1419 +#define _SWAP_FAST_r22 1420 +#define _SWAP_FAST_r33 1421 +#define _SWAP_FAST_0_r01 1422 +#define _SWAP_FAST_0_r11 1423 +#define _SWAP_FAST_0_r22 1424 +#define _SWAP_FAST_0_r33 1425 +#define _SWAP_FAST_1_r01 1426 +#define _SWAP_FAST_1_r11 1427 +#define _SWAP_FAST_1_r22 1428 +#define _SWAP_FAST_1_r33 1429 +#define _SWAP_FAST_2_r01 1430 +#define _SWAP_FAST_2_r11 1431 +#define _SWAP_FAST_2_r22 1432 +#define _SWAP_FAST_2_r33 1433 +#define _SWAP_FAST_3_r01 1434 +#define _SWAP_FAST_3_r11 1435 +#define _SWAP_FAST_3_r22 1436 +#define _SWAP_FAST_3_r33 1437 +#define _SWAP_FAST_4_r01 1438 +#define _SWAP_FAST_4_r11 1439 +#define _SWAP_FAST_4_r22 1440 +#define _SWAP_FAST_4_r33 1441 +#define _SWAP_FAST_5_r01 1442 +#define _SWAP_FAST_5_r11 1443 +#define _SWAP_FAST_5_r22 1444 +#define _SWAP_FAST_5_r33 1445 +#define _SWAP_FAST_6_r01 1446 +#define _SWAP_FAST_6_r11 1447 +#define _SWAP_FAST_6_r22 1448 +#define _SWAP_FAST_6_r33 1449 +#define _SWAP_FAST_7_r01 1450 +#define _SWAP_FAST_7_r11 1451 +#define _SWAP_FAST_7_r22 1452 +#define _SWAP_FAST_7_r33 1453 +#define _TIER2_RESUME_CHECK_r00 1454 +#define _TIER2_RESUME_CHECK_r11 1455 +#define _TIER2_RESUME_CHECK_r22 1456 +#define _TIER2_RESUME_CHECK_r33 1457 +#define _TO_BOOL_r11 1458 +#define _TO_BOOL_BOOL_r01 1459 +#define _TO_BOOL_BOOL_r11 1460 +#define _TO_BOOL_BOOL_r22 1461 +#define _TO_BOOL_BOOL_r33 1462 +#define _TO_BOOL_INT_r02 1463 +#define _TO_BOOL_INT_r12 1464 +#define _TO_BOOL_INT_r23 1465 +#define _TO_BOOL_LIST_r02 1466 +#define _TO_BOOL_LIST_r12 1467 +#define _TO_BOOL_LIST_r23 1468 +#define _TO_BOOL_NONE_r01 1469 +#define _TO_BOOL_NONE_r11 1470 +#define _TO_BOOL_NONE_r22 1471 +#define _TO_BOOL_NONE_r33 1472 +#define _TO_BOOL_STR_r02 1473 +#define _TO_BOOL_STR_r12 1474 +#define _TO_BOOL_STR_r23 1475 +#define _TRACE_RECORD_r00 1476 +#define _UNARY_INVERT_r12 1477 +#define _UNARY_NEGATIVE_r12 1478 +#define _UNARY_NOT_r01 1479 +#define _UNARY_NOT_r11 1480 +#define _UNARY_NOT_r22 1481 +#define _UNARY_NOT_r33 1482 +#define _UNPACK_EX_r10 1483 +#define _UNPACK_SEQUENCE_r10 1484 +#define _UNPACK_SEQUENCE_LIST_r10 1485 +#define _UNPACK_SEQUENCE_TUPLE_r10 1486 +#define _UNPACK_SEQUENCE_TWO_TUPLE_r12 1487 +#define _WITH_EXCEPT_START_r33 1488 +#define _YIELD_VALUE_r11 1489 +#define MAX_UOP_REGS_ID 1489 #ifdef __cplusplus } diff --git a/Include/internal/pycore_uop_metadata.h b/Include/internal/pycore_uop_metadata.h index 9a0852f872d763..c3a5ae7b897c0a 100644 --- a/Include/internal/pycore_uop_metadata.h +++ b/Include/internal/pycore_uop_metadata.h @@ -225,6 +225,7 @@ const uint32_t _PyUop_Flags[MAX_UOP_ID+1] = { [_IMPORT_FROM] = HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, [_IS_NONE] = HAS_ESCAPES_FLAG, [_GET_LEN] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_MATCH_CLASS_ISINSTANCE] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, [_MATCH_CLASS] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, [_MATCH_MAPPING] = 0, [_MATCH_SEQUENCE] = 0, @@ -2115,6 +2116,15 @@ const _PyUopCachingInfo _PyUop_Caching[MAX_UOP_ID+1] = { { -1, -1, -1 }, }, }, + [_MATCH_CLASS_ISINSTANCE] = { + .best = { 2, 2, 2, 2 }, + .entries = { + { -1, -1, -1 }, + { -1, -1, -1 }, + { 2, 2, _MATCH_CLASS_ISINSTANCE_r22 }, + { -1, -1, -1 }, + }, + }, [_MATCH_CLASS] = { .best = { 3, 3, 3, 3 }, .entries = { @@ -3955,6 +3965,7 @@ const uint16_t _PyUop_Uncached[MAX_UOP_REGS_ID+1] = { [_IMPORT_FROM_r12] = _IMPORT_FROM, [_IS_NONE_r11] = _IS_NONE, [_GET_LEN_r12] = _GET_LEN, + [_MATCH_CLASS_ISINSTANCE_r22] = _MATCH_CLASS_ISINSTANCE, [_MATCH_CLASS_r33] = _MATCH_CLASS, [_MATCH_MAPPING_r02] = _MATCH_MAPPING, [_MATCH_MAPPING_r12] = _MATCH_MAPPING, @@ -5246,6 +5257,8 @@ const char *const _PyOpcode_uop_name[MAX_UOP_REGS_ID+1] = { [_MAP_ADD_r20] = "_MAP_ADD_r20", [_MATCH_CLASS] = "_MATCH_CLASS", [_MATCH_CLASS_r33] = "_MATCH_CLASS_r33", + [_MATCH_CLASS_ISINSTANCE] = "_MATCH_CLASS_ISINSTANCE", + [_MATCH_CLASS_ISINSTANCE_r22] = "_MATCH_CLASS_ISINSTANCE_r22", [_MATCH_KEYS] = "_MATCH_KEYS", [_MATCH_KEYS_r23] = "_MATCH_KEYS_r23", [_MATCH_MAPPING] = "_MATCH_MAPPING", @@ -5913,6 +5926,8 @@ int _PyUop_num_popped(int opcode, int oparg) return 1; case _GET_LEN: return 0; + case _MATCH_CLASS_ISINSTANCE: + return 1; case _MATCH_CLASS: return 3; case _MATCH_MAPPING: diff --git a/Include/opcode_ids.h b/Include/opcode_ids.h index c46368444f4c59..2deb73e16ed0d8 100644 --- a/Include/opcode_ids.h +++ b/Include/opcode_ids.h @@ -34,103 +34,104 @@ extern "C" { #define LOAD_BUILD_CLASS 21 #define LOAD_LOCALS 22 #define MAKE_FUNCTION 23 -#define MATCH_KEYS 24 -#define MATCH_MAPPING 25 -#define MATCH_SEQUENCE 26 -#define NOP 27 -#define NOT_TAKEN 28 -#define POP_EXCEPT 29 -#define POP_ITER 30 -#define POP_TOP 31 -#define PUSH_EXC_INFO 32 -#define PUSH_NULL 33 -#define RETURN_GENERATOR 34 -#define RETURN_VALUE 35 -#define SETUP_ANNOTATIONS 36 -#define STORE_SLICE 37 -#define STORE_SUBSCR 38 -#define TO_BOOL 39 -#define UNARY_INVERT 40 -#define UNARY_NEGATIVE 41 -#define UNARY_NOT 42 -#define WITH_EXCEPT_START 43 -#define BINARY_OP 44 -#define BUILD_INTERPOLATION 45 -#define BUILD_LIST 46 -#define BUILD_MAP 47 -#define BUILD_SET 48 -#define BUILD_SLICE 49 -#define BUILD_STRING 50 -#define BUILD_TUPLE 51 -#define CALL 52 -#define CALL_INTRINSIC_1 53 -#define CALL_INTRINSIC_2 54 -#define CALL_KW 55 -#define COMPARE_OP 56 -#define CONTAINS_OP 57 -#define CONVERT_VALUE 58 -#define COPY 59 -#define COPY_FREE_VARS 60 -#define DELETE_ATTR 61 -#define DELETE_DEREF 62 -#define DELETE_FAST 63 -#define DELETE_GLOBAL 64 -#define DELETE_NAME 65 -#define DICT_MERGE 66 -#define DICT_UPDATE 67 -#define END_ASYNC_FOR 68 -#define EXTENDED_ARG 69 -#define FOR_ITER 70 -#define GET_AWAITABLE 71 -#define IMPORT_FROM 72 -#define IMPORT_NAME 73 -#define IS_OP 74 -#define JUMP_BACKWARD 75 -#define JUMP_BACKWARD_NO_INTERRUPT 76 -#define JUMP_FORWARD 77 -#define LIST_APPEND 78 -#define LIST_EXTEND 79 -#define LOAD_ATTR 80 -#define LOAD_COMMON_CONSTANT 81 -#define LOAD_CONST 82 -#define LOAD_DEREF 83 -#define LOAD_FAST 84 -#define LOAD_FAST_AND_CLEAR 85 -#define LOAD_FAST_BORROW 86 -#define LOAD_FAST_BORROW_LOAD_FAST_BORROW 87 -#define LOAD_FAST_CHECK 88 -#define LOAD_FAST_LOAD_FAST 89 -#define LOAD_FROM_DICT_OR_DEREF 90 -#define LOAD_FROM_DICT_OR_GLOBALS 91 -#define LOAD_GLOBAL 92 -#define LOAD_NAME 93 -#define LOAD_SMALL_INT 94 -#define LOAD_SPECIAL 95 -#define LOAD_SUPER_ATTR 96 -#define MAKE_CELL 97 -#define MAP_ADD 98 -#define MATCH_CLASS 99 -#define POP_JUMP_IF_FALSE 100 -#define POP_JUMP_IF_NONE 101 -#define POP_JUMP_IF_NOT_NONE 102 -#define POP_JUMP_IF_TRUE 103 -#define RAISE_VARARGS 104 -#define RERAISE 105 -#define SEND 106 -#define SET_ADD 107 -#define SET_FUNCTION_ATTRIBUTE 108 -#define SET_UPDATE 109 -#define STORE_ATTR 110 -#define STORE_DEREF 111 -#define STORE_FAST 112 -#define STORE_FAST_LOAD_FAST 113 -#define STORE_FAST_STORE_FAST 114 -#define STORE_GLOBAL 115 -#define STORE_NAME 116 -#define SWAP 117 -#define UNPACK_EX 118 -#define UNPACK_SEQUENCE 119 -#define YIELD_VALUE 120 +#define MATCH_CLASS_ISINSTANCE 24 +#define MATCH_KEYS 25 +#define MATCH_MAPPING 26 +#define MATCH_SEQUENCE 27 +#define NOP 28 +#define NOT_TAKEN 29 +#define POP_EXCEPT 30 +#define POP_ITER 31 +#define POP_TOP 32 +#define PUSH_EXC_INFO 33 +#define PUSH_NULL 34 +#define RETURN_GENERATOR 35 +#define RETURN_VALUE 36 +#define SETUP_ANNOTATIONS 37 +#define STORE_SLICE 38 +#define STORE_SUBSCR 39 +#define TO_BOOL 40 +#define UNARY_INVERT 41 +#define UNARY_NEGATIVE 42 +#define UNARY_NOT 43 +#define WITH_EXCEPT_START 44 +#define BINARY_OP 45 +#define BUILD_INTERPOLATION 46 +#define BUILD_LIST 47 +#define BUILD_MAP 48 +#define BUILD_SET 49 +#define BUILD_SLICE 50 +#define BUILD_STRING 51 +#define BUILD_TUPLE 52 +#define CALL 53 +#define CALL_INTRINSIC_1 54 +#define CALL_INTRINSIC_2 55 +#define CALL_KW 56 +#define COMPARE_OP 57 +#define CONTAINS_OP 58 +#define CONVERT_VALUE 59 +#define COPY 60 +#define COPY_FREE_VARS 61 +#define DELETE_ATTR 62 +#define DELETE_DEREF 63 +#define DELETE_FAST 64 +#define DELETE_GLOBAL 65 +#define DELETE_NAME 66 +#define DICT_MERGE 67 +#define DICT_UPDATE 68 +#define END_ASYNC_FOR 69 +#define EXTENDED_ARG 70 +#define FOR_ITER 71 +#define GET_AWAITABLE 72 +#define IMPORT_FROM 73 +#define IMPORT_NAME 74 +#define IS_OP 75 +#define JUMP_BACKWARD 76 +#define JUMP_BACKWARD_NO_INTERRUPT 77 +#define JUMP_FORWARD 78 +#define LIST_APPEND 79 +#define LIST_EXTEND 80 +#define LOAD_ATTR 81 +#define LOAD_COMMON_CONSTANT 82 +#define LOAD_CONST 83 +#define LOAD_DEREF 84 +#define LOAD_FAST 85 +#define LOAD_FAST_AND_CLEAR 86 +#define LOAD_FAST_BORROW 87 +#define LOAD_FAST_BORROW_LOAD_FAST_BORROW 88 +#define LOAD_FAST_CHECK 89 +#define LOAD_FAST_LOAD_FAST 90 +#define LOAD_FROM_DICT_OR_DEREF 91 +#define LOAD_FROM_DICT_OR_GLOBALS 92 +#define LOAD_GLOBAL 93 +#define LOAD_NAME 94 +#define LOAD_SMALL_INT 95 +#define LOAD_SPECIAL 96 +#define LOAD_SUPER_ATTR 97 +#define MAKE_CELL 98 +#define MAP_ADD 99 +#define MATCH_CLASS 100 +#define POP_JUMP_IF_FALSE 101 +#define POP_JUMP_IF_NONE 102 +#define POP_JUMP_IF_NOT_NONE 103 +#define POP_JUMP_IF_TRUE 104 +#define RAISE_VARARGS 105 +#define RERAISE 106 +#define SEND 107 +#define SET_ADD 108 +#define SET_FUNCTION_ATTRIBUTE 109 +#define SET_UPDATE 110 +#define STORE_ATTR 111 +#define STORE_DEREF 112 +#define STORE_FAST 113 +#define STORE_FAST_LOAD_FAST 114 +#define STORE_FAST_STORE_FAST 115 +#define STORE_GLOBAL 116 +#define STORE_NAME 117 +#define SWAP 118 +#define UNPACK_EX 119 +#define UNPACK_SEQUENCE 120 +#define YIELD_VALUE 121 #define RESUME 128 #define BINARY_OP_ADD_FLOAT 129 #define BINARY_OP_ADD_INT 130 @@ -251,7 +252,7 @@ extern "C" { #define SETUP_WITH 265 #define STORE_FAST_MAYBE_NULL 266 -#define HAVE_ARGUMENT 43 +#define HAVE_ARGUMENT 44 #define MIN_SPECIALIZED_OPCODE 129 #define MIN_INSTRUMENTED_OPCODE 233 diff --git a/Lib/_opcode_metadata.py b/Lib/_opcode_metadata.py index 6e37288c32dd9a..d6a56054d7e0c7 100644 --- a/Lib/_opcode_metadata.py +++ b/Lib/_opcode_metadata.py @@ -240,103 +240,104 @@ LOAD_BUILD_CLASS=21, LOAD_LOCALS=22, MAKE_FUNCTION=23, - MATCH_KEYS=24, - MATCH_MAPPING=25, - MATCH_SEQUENCE=26, - NOP=27, - NOT_TAKEN=28, - POP_EXCEPT=29, - POP_ITER=30, - POP_TOP=31, - PUSH_EXC_INFO=32, - PUSH_NULL=33, - RETURN_GENERATOR=34, - RETURN_VALUE=35, - SETUP_ANNOTATIONS=36, - STORE_SLICE=37, - STORE_SUBSCR=38, - TO_BOOL=39, - UNARY_INVERT=40, - UNARY_NEGATIVE=41, - UNARY_NOT=42, - WITH_EXCEPT_START=43, - BINARY_OP=44, - BUILD_INTERPOLATION=45, - BUILD_LIST=46, - BUILD_MAP=47, - BUILD_SET=48, - BUILD_SLICE=49, - BUILD_STRING=50, - BUILD_TUPLE=51, - CALL=52, - CALL_INTRINSIC_1=53, - CALL_INTRINSIC_2=54, - CALL_KW=55, - COMPARE_OP=56, - CONTAINS_OP=57, - CONVERT_VALUE=58, - COPY=59, - COPY_FREE_VARS=60, - DELETE_ATTR=61, - DELETE_DEREF=62, - DELETE_FAST=63, - DELETE_GLOBAL=64, - DELETE_NAME=65, - DICT_MERGE=66, - DICT_UPDATE=67, - END_ASYNC_FOR=68, - EXTENDED_ARG=69, - FOR_ITER=70, - GET_AWAITABLE=71, - IMPORT_FROM=72, - IMPORT_NAME=73, - IS_OP=74, - JUMP_BACKWARD=75, - JUMP_BACKWARD_NO_INTERRUPT=76, - JUMP_FORWARD=77, - LIST_APPEND=78, - LIST_EXTEND=79, - LOAD_ATTR=80, - LOAD_COMMON_CONSTANT=81, - LOAD_CONST=82, - LOAD_DEREF=83, - LOAD_FAST=84, - LOAD_FAST_AND_CLEAR=85, - LOAD_FAST_BORROW=86, - LOAD_FAST_BORROW_LOAD_FAST_BORROW=87, - LOAD_FAST_CHECK=88, - LOAD_FAST_LOAD_FAST=89, - LOAD_FROM_DICT_OR_DEREF=90, - LOAD_FROM_DICT_OR_GLOBALS=91, - LOAD_GLOBAL=92, - LOAD_NAME=93, - LOAD_SMALL_INT=94, - LOAD_SPECIAL=95, - LOAD_SUPER_ATTR=96, - MAKE_CELL=97, - MAP_ADD=98, - MATCH_CLASS=99, - POP_JUMP_IF_FALSE=100, - POP_JUMP_IF_NONE=101, - POP_JUMP_IF_NOT_NONE=102, - POP_JUMP_IF_TRUE=103, - RAISE_VARARGS=104, - RERAISE=105, - SEND=106, - SET_ADD=107, - SET_FUNCTION_ATTRIBUTE=108, - SET_UPDATE=109, - STORE_ATTR=110, - STORE_DEREF=111, - STORE_FAST=112, - STORE_FAST_LOAD_FAST=113, - STORE_FAST_STORE_FAST=114, - STORE_GLOBAL=115, - STORE_NAME=116, - SWAP=117, - UNPACK_EX=118, - UNPACK_SEQUENCE=119, - YIELD_VALUE=120, + MATCH_CLASS_ISINSTANCE=24, + MATCH_KEYS=25, + MATCH_MAPPING=26, + MATCH_SEQUENCE=27, + NOP=28, + NOT_TAKEN=29, + POP_EXCEPT=30, + POP_ITER=31, + POP_TOP=32, + PUSH_EXC_INFO=33, + PUSH_NULL=34, + RETURN_GENERATOR=35, + RETURN_VALUE=36, + SETUP_ANNOTATIONS=37, + STORE_SLICE=38, + STORE_SUBSCR=39, + TO_BOOL=40, + UNARY_INVERT=41, + UNARY_NEGATIVE=42, + UNARY_NOT=43, + WITH_EXCEPT_START=44, + BINARY_OP=45, + BUILD_INTERPOLATION=46, + BUILD_LIST=47, + BUILD_MAP=48, + BUILD_SET=49, + BUILD_SLICE=50, + BUILD_STRING=51, + BUILD_TUPLE=52, + CALL=53, + CALL_INTRINSIC_1=54, + CALL_INTRINSIC_2=55, + CALL_KW=56, + COMPARE_OP=57, + CONTAINS_OP=58, + CONVERT_VALUE=59, + COPY=60, + COPY_FREE_VARS=61, + DELETE_ATTR=62, + DELETE_DEREF=63, + DELETE_FAST=64, + DELETE_GLOBAL=65, + DELETE_NAME=66, + DICT_MERGE=67, + DICT_UPDATE=68, + END_ASYNC_FOR=69, + EXTENDED_ARG=70, + FOR_ITER=71, + GET_AWAITABLE=72, + IMPORT_FROM=73, + IMPORT_NAME=74, + IS_OP=75, + JUMP_BACKWARD=76, + JUMP_BACKWARD_NO_INTERRUPT=77, + JUMP_FORWARD=78, + LIST_APPEND=79, + LIST_EXTEND=80, + LOAD_ATTR=81, + LOAD_COMMON_CONSTANT=82, + LOAD_CONST=83, + LOAD_DEREF=84, + LOAD_FAST=85, + LOAD_FAST_AND_CLEAR=86, + LOAD_FAST_BORROW=87, + LOAD_FAST_BORROW_LOAD_FAST_BORROW=88, + LOAD_FAST_CHECK=89, + LOAD_FAST_LOAD_FAST=90, + LOAD_FROM_DICT_OR_DEREF=91, + LOAD_FROM_DICT_OR_GLOBALS=92, + LOAD_GLOBAL=93, + LOAD_NAME=94, + LOAD_SMALL_INT=95, + LOAD_SPECIAL=96, + LOAD_SUPER_ATTR=97, + MAKE_CELL=98, + MAP_ADD=99, + MATCH_CLASS=100, + POP_JUMP_IF_FALSE=101, + POP_JUMP_IF_NONE=102, + POP_JUMP_IF_NOT_NONE=103, + POP_JUMP_IF_TRUE=104, + RAISE_VARARGS=105, + RERAISE=106, + SEND=107, + SET_ADD=108, + SET_FUNCTION_ATTRIBUTE=109, + SET_UPDATE=110, + STORE_ATTR=111, + STORE_DEREF=112, + STORE_FAST=113, + STORE_FAST_LOAD_FAST=114, + STORE_FAST_STORE_FAST=115, + STORE_GLOBAL=116, + STORE_NAME=117, + SWAP=118, + UNPACK_EX=119, + UNPACK_SEQUENCE=120, + YIELD_VALUE=121, INSTRUMENTED_END_FOR=233, INSTRUMENTED_POP_ITER=234, INSTRUMENTED_END_SEND=235, @@ -370,5 +371,5 @@ STORE_FAST_MAYBE_NULL=266, ) -HAVE_ARGUMENT = 43 +HAVE_ARGUMENT = 44 MIN_INSTRUMENTED_OPCODE = 233 diff --git a/Lib/test/test_capi/test_opt.py b/Lib/test/test_capi/test_opt.py index e5fada1f40ce43..0737ed066ca5e4 100644 --- a/Lib/test/test_capi/test_opt.py +++ b/Lib/test/test_capi/test_opt.py @@ -3953,12 +3953,13 @@ def testfunc(n): def test_match_class(self): def testfunc(n): class A: + __match_args__ = ("val",) val = 1 x = A() ret = 0 for _ in range(n): match x: - case A(): + case A(1): ret += x.val return ret @@ -3967,7 +3968,7 @@ class A: uops = get_opnames(ex) self.assertIn("_MATCH_CLASS", uops) - self.assertEqual(count_ops(ex, "_POP_TOP_NOP"), 4) + self.assertEqual(count_ops(ex, "_POP_TOP_NOP"), 5) def test_143026(self): # https://github.com/python/cpython/issues/143026 diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py index cefd64ddfe8417..41a8591223adb7 100644 --- a/Lib/test/test_dis.py +++ b/Lib/test/test_dis.py @@ -1035,7 +1035,8 @@ def test_widths(self): long_opcodes = set(['JUMP_BACKWARD_NO_INTERRUPT', 'LOAD_FAST_BORROW_LOAD_FAST_BORROW', 'INSTRUMENTED_CALL_FUNCTION_EX', - 'ANNOTATIONS_PLACEHOLDER']) + 'ANNOTATIONS_PLACEHOLDER', + 'MATCH_CLASS_ISINSTANCE']) for op, opname in enumerate(dis.opname): if opname in long_opcodes or opname.startswith("INSTRUMENTED"): continue diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-02-14-16-19-22.gh-issue-138912.TKMC9K.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-02-14-16-19-22.gh-issue-138912.TKMC9K.rst new file mode 100644 index 00000000000000..1e9d0067027631 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-02-14-16-19-22.gh-issue-138912.TKMC9K.rst @@ -0,0 +1,3 @@ +Add :opcode:`MATCH_CLASS_ISINSTANCE` opcode to improve the performance of +:keyword:`match` class patterns without any sub-patterns by ~24%. +Patch by Marc Mueller. diff --git a/Modules/_testinternalcapi/test_cases.c.h b/Modules/_testinternalcapi/test_cases.c.h index 9e86bc42f20074..8478c124bdfd13 100644 --- a/Modules/_testinternalcapi/test_cases.c.h +++ b/Modules/_testinternalcapi/test_cases.c.h @@ -10045,6 +10045,52 @@ DISPATCH(); } + TARGET(MATCH_CLASS_ISINSTANCE) { + #if _Py_TAIL_CALL_INTERP + int opcode = MATCH_CLASS_ISINSTANCE; + (void)(opcode); + #endif + frame->instr_ptr = next_instr; + next_instr += 1; + INSTRUCTION_STATS(MATCH_CLASS_ISINSTANCE); + _PyStackRef subject; + _PyStackRef type; + _PyStackRef res; + type = stack_pointer[-1]; + subject = stack_pointer[-2]; + PyObject *subject_o = PyStackRef_AsPyObjectBorrow(subject); + PyObject *type_o = PyStackRef_AsPyObjectBorrow(type); + if (!PyType_Check(type_o)) { + const char *e = "called match pattern must be a class"; + _PyFrame_SetStackPointer(frame, stack_pointer); + _PyErr_Format(tstate, PyExc_TypeError, e); + stack_pointer = _PyFrame_GetStackPointer(frame); + stack_pointer += -1; + ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); + _PyFrame_SetStackPointer(frame, stack_pointer); + PyStackRef_CLOSE(type); + stack_pointer = _PyFrame_GetStackPointer(frame); + JUMP_TO_LABEL(error); + } + _PyFrame_SetStackPointer(frame, stack_pointer); + int retval = PyObject_IsInstance(subject_o, type_o); + stack_pointer = _PyFrame_GetStackPointer(frame); + stack_pointer += -1; + ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); + _PyFrame_SetStackPointer(frame, stack_pointer); + PyStackRef_CLOSE(type); + stack_pointer = _PyFrame_GetStackPointer(frame); + if (retval < 0) { + JUMP_TO_LABEL(error); + } + assert(!_PyErr_Occurred(tstate)); + res = retval ? PyStackRef_True : PyStackRef_False; + stack_pointer[0] = res; + stack_pointer += 1; + ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); + DISPATCH(); + } + TARGET(MATCH_KEYS) { #if _Py_TAIL_CALL_INTERP int opcode = MATCH_KEYS; diff --git a/Modules/_testinternalcapi/test_targets.h b/Modules/_testinternalcapi/test_targets.h index f57c33feec2ac2..0be9dbbf36e32e 100644 --- a/Modules/_testinternalcapi/test_targets.h +++ b/Modules/_testinternalcapi/test_targets.h @@ -24,6 +24,7 @@ static void *opcode_targets_table[256] = { &&TARGET_LOAD_BUILD_CLASS, &&TARGET_LOAD_LOCALS, &&TARGET_MAKE_FUNCTION, + &&TARGET_MATCH_CLASS_ISINSTANCE, &&TARGET_MATCH_KEYS, &&TARGET_MATCH_MAPPING, &&TARGET_MATCH_SEQUENCE, @@ -127,7 +128,6 @@ static void *opcode_targets_table[256] = { &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, - &&_unknown_opcode, &&TARGET_RESUME, &&TARGET_BINARY_OP_ADD_FLOAT, &&TARGET_BINARY_OP_ADD_INT, @@ -380,7 +380,7 @@ static void *opcode_tracing_targets_table[256] = { &&TARGET_TRACE_RECORD, &&TARGET_TRACE_RECORD, &&TARGET_TRACE_RECORD, - &&_unknown_opcode, + &&TARGET_TRACE_RECORD, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, @@ -699,6 +699,7 @@ static PyObject *Py_PRESERVE_NONE_CC _TAIL_CALL_MAKE_CELL(TAIL_CALL_PARAMS); static PyObject *Py_PRESERVE_NONE_CC _TAIL_CALL_MAKE_FUNCTION(TAIL_CALL_PARAMS); static PyObject *Py_PRESERVE_NONE_CC _TAIL_CALL_MAP_ADD(TAIL_CALL_PARAMS); static PyObject *Py_PRESERVE_NONE_CC _TAIL_CALL_MATCH_CLASS(TAIL_CALL_PARAMS); +static PyObject *Py_PRESERVE_NONE_CC _TAIL_CALL_MATCH_CLASS_ISINSTANCE(TAIL_CALL_PARAMS); static PyObject *Py_PRESERVE_NONE_CC _TAIL_CALL_MATCH_KEYS(TAIL_CALL_PARAMS); static PyObject *Py_PRESERVE_NONE_CC _TAIL_CALL_MATCH_MAPPING(TAIL_CALL_PARAMS); static PyObject *Py_PRESERVE_NONE_CC _TAIL_CALL_MATCH_SEQUENCE(TAIL_CALL_PARAMS); @@ -940,6 +941,7 @@ static py_tail_call_funcptr instruction_funcptr_handler_table[256] = { [MAKE_FUNCTION] = _TAIL_CALL_MAKE_FUNCTION, [MAP_ADD] = _TAIL_CALL_MAP_ADD, [MATCH_CLASS] = _TAIL_CALL_MATCH_CLASS, + [MATCH_CLASS_ISINSTANCE] = _TAIL_CALL_MATCH_CLASS_ISINSTANCE, [MATCH_KEYS] = _TAIL_CALL_MATCH_KEYS, [MATCH_MAPPING] = _TAIL_CALL_MATCH_MAPPING, [MATCH_SEQUENCE] = _TAIL_CALL_MATCH_SEQUENCE, @@ -1000,7 +1002,6 @@ static py_tail_call_funcptr instruction_funcptr_handler_table[256] = { [UNPACK_SEQUENCE_TWO_TUPLE] = _TAIL_CALL_UNPACK_SEQUENCE_TWO_TUPLE, [WITH_EXCEPT_START] = _TAIL_CALL_WITH_EXCEPT_START, [YIELD_VALUE] = _TAIL_CALL_YIELD_VALUE, - [121] = _TAIL_CALL_UNKNOWN_OPCODE, [122] = _TAIL_CALL_UNKNOWN_OPCODE, [123] = _TAIL_CALL_UNKNOWN_OPCODE, [124] = _TAIL_CALL_UNKNOWN_OPCODE, @@ -1198,6 +1199,7 @@ static py_tail_call_funcptr instruction_funcptr_tracing_table[256] = { [MAKE_FUNCTION] = _TAIL_CALL_TRACE_RECORD, [MAP_ADD] = _TAIL_CALL_TRACE_RECORD, [MATCH_CLASS] = _TAIL_CALL_TRACE_RECORD, + [MATCH_CLASS_ISINSTANCE] = _TAIL_CALL_TRACE_RECORD, [MATCH_KEYS] = _TAIL_CALL_TRACE_RECORD, [MATCH_MAPPING] = _TAIL_CALL_TRACE_RECORD, [MATCH_SEQUENCE] = _TAIL_CALL_TRACE_RECORD, @@ -1258,7 +1260,6 @@ static py_tail_call_funcptr instruction_funcptr_tracing_table[256] = { [UNPACK_SEQUENCE_TWO_TUPLE] = _TAIL_CALL_TRACE_RECORD, [WITH_EXCEPT_START] = _TAIL_CALL_TRACE_RECORD, [YIELD_VALUE] = _TAIL_CALL_TRACE_RECORD, - [121] = _TAIL_CALL_UNKNOWN_OPCODE, [122] = _TAIL_CALL_UNKNOWN_OPCODE, [123] = _TAIL_CALL_UNKNOWN_OPCODE, [124] = _TAIL_CALL_UNKNOWN_OPCODE, diff --git a/Programs/test_frozenmain.h b/Programs/test_frozenmain.h index f808544045e153..f5f1f85045d1bd 100644 --- a/Programs/test_frozenmain.h +++ b/Programs/test_frozenmain.h @@ -1,19 +1,19 @@ // Auto-generated by Programs/freeze_test_frozenmain.py unsigned char M_test_frozenmain[] = { 227,0,0,0,0,0,0,0,0,0,0,0,0,9,0,0, - 0,0,0,0,0,243,184,0,0,0,128,0,94,0,82,1, - 73,0,116,0,94,0,82,1,73,4,116,1,93,2,33,0, - 82,2,52,1,0,0,0,0,0,0,31,0,93,2,33,0, - 82,3,93,0,80,6,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,52,2,0,0,0,0,0,0, - 31,0,93,1,80,8,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,33,0,52,0,0,0,0,0, - 0,0,82,4,44,26,0,0,0,0,0,0,0,0,0,0, - 116,5,82,7,16,0,70,24,0,0,116,6,93,2,33,0, - 82,5,93,6,12,0,82,6,93,5,93,6,44,26,0,0, - 0,0,0,0,0,0,0,0,12,0,50,4,52,1,0,0, - 0,0,0,0,31,0,75,26,0,0,9,0,30,0,82,1, - 35,0,41,8,233,0,0,0,0,78,122,18,70,114,111,122, + 0,0,0,0,0,243,184,0,0,0,128,0,95,0,83,1, + 74,0,117,0,95,0,83,1,74,4,117,1,94,2,34,0, + 83,2,53,1,0,0,0,0,0,0,32,0,94,2,34,0, + 83,3,94,0,81,6,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,53,2,0,0,0,0,0,0, + 32,0,94,1,81,8,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,34,0,53,0,0,0,0,0, + 0,0,83,4,45,26,0,0,0,0,0,0,0,0,0,0, + 117,5,83,7,16,0,71,24,0,0,117,6,94,2,34,0, + 83,5,94,6,12,0,83,6,94,5,94,6,45,26,0,0, + 0,0,0,0,0,0,0,0,12,0,51,4,53,1,0,0, + 0,0,0,0,32,0,76,26,0,0,9,0,31,0,83,1, + 36,0,41,8,233,0,0,0,0,78,122,18,70,114,111,122, 101,110,32,72,101,108,108,111,32,87,111,114,108,100,122,8, 115,121,115,46,97,114,103,118,218,6,99,111,110,102,105,103, 122,7,99,111,110,102,105,103,32,122,2,58,32,41,5,218, diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 43a512611fb1ee..d7e4e157f0c3a2 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -3254,6 +3254,22 @@ dummy_func( len = PyStackRef_FromPyObjectSteal(len_o); } + inst(MATCH_CLASS_ISINSTANCE, (subject, type -- subject, res)) { + PyObject *subject_o = PyStackRef_AsPyObjectBorrow(subject); + PyObject *type_o = PyStackRef_AsPyObjectBorrow(type); + if (!PyType_Check(type_o)) { + const char *e = "called match pattern must be a class"; + _PyErr_Format(tstate, PyExc_TypeError, e); + PyStackRef_CLOSE(type); + ERROR_IF(true); + } + int retval = PyObject_IsInstance(subject_o, type_o); + PyStackRef_CLOSE(type); + ERROR_IF(retval < 0); + assert(!_PyErr_Occurred(tstate)); + res = retval ? PyStackRef_True : PyStackRef_False; + } + op(_MATCH_CLASS, (subject, type, names -- attrs, s, tp, n)) { // Pop TOS and TOS1. Set TOS to a tuple of attributes on success, or // None on failure. diff --git a/Python/codegen.c b/Python/codegen.c index 5749b615386717..0e82700cd50d69 100644 --- a/Python/codegen.c +++ b/Python/codegen.c @@ -6068,6 +6068,24 @@ validate_kwd_attrs(compiler *c, asdl_identifier_seq *attrs, asdl_pattern_seq* pa return SUCCESS; } +static int +codegen_pattern_class_fast(compiler *c, pattern_ty p, pattern_context *pc) +{ + NEW_JUMP_TARGET_LABEL(c, end); + assert(p->kind == MatchClass_kind); + assert(!asdl_seq_LEN(p->v.MatchClass.patterns)); + assert(!asdl_seq_LEN(p->v.MatchClass.kwd_attrs)); + VISIT(c, expr, p->v.MatchClass.cls); + ADDOP(c, LOC(p), MATCH_CLASS_ISINSTANCE); + // TOS is now subject: + pc->on_top++; + RETURN_IF_ERROR(jump_to_fail_pop(c, LOC(p), pc, POP_JUMP_IF_FALSE)); + pc->on_top--; + // Success! POP subject: + ADDOP(c, LOC(p), POP_TOP); + return SUCCESS; +} + static int codegen_pattern_class(compiler *c, pattern_ty p, pattern_context *pc) { @@ -6091,6 +6109,10 @@ codegen_pattern_class(compiler *c, pattern_ty p, pattern_context *pc) if (nattrs) { RETURN_IF_ERROR(validate_kwd_attrs(c, kwd_attrs, kwd_patterns)); } + if (!nargs && !nattrs) { + // Fast path if there are no sub-patterns + return codegen_pattern_class_fast(c, p, pc); + } VISIT(c, expr, p->v.MatchClass.cls); PyObject *attr_names = PyTuple_New(nattrs); if (attr_names == NULL) { diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 7a698e422abd77..62c712263baef8 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -11292,6 +11292,63 @@ break; } + case _MATCH_CLASS_ISINSTANCE_r22: { + CHECK_CURRENT_CACHED_VALUES(2); + assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE()); + _PyStackRef type; + _PyStackRef subject; + _PyStackRef res; + _PyStackRef _stack_item_0 = _tos_cache0; + _PyStackRef _stack_item_1 = _tos_cache1; + type = _stack_item_1; + subject = _stack_item_0; + PyObject *subject_o = PyStackRef_AsPyObjectBorrow(subject); + PyObject *type_o = PyStackRef_AsPyObjectBorrow(type); + if (!PyType_Check(type_o)) { + const char *e = "called match pattern must be a class"; + stack_pointer[0] = subject; + stack_pointer[1] = type; + stack_pointer += 2; + ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); + _PyFrame_SetStackPointer(frame, stack_pointer); + _PyErr_Format(tstate, PyExc_TypeError, e); + stack_pointer = _PyFrame_GetStackPointer(frame); + stack_pointer += -1; + ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); + _PyFrame_SetStackPointer(frame, stack_pointer); + PyStackRef_CLOSE(type); + stack_pointer = _PyFrame_GetStackPointer(frame); + SET_CURRENT_CACHED_VALUES(0); + JUMP_TO_ERROR(); + } + stack_pointer[0] = subject; + stack_pointer[1] = type; + stack_pointer += 2; + ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); + _PyFrame_SetStackPointer(frame, stack_pointer); + int retval = PyObject_IsInstance(subject_o, type_o); + stack_pointer = _PyFrame_GetStackPointer(frame); + stack_pointer += -1; + ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); + _PyFrame_SetStackPointer(frame, stack_pointer); + PyStackRef_CLOSE(type); + stack_pointer = _PyFrame_GetStackPointer(frame); + if (retval < 0) { + SET_CURRENT_CACHED_VALUES(0); + JUMP_TO_ERROR(); + } + assert(!_PyErr_Occurred(tstate)); + res = retval ? PyStackRef_True : PyStackRef_False; + _tos_cache1 = res; + _tos_cache0 = subject; + _tos_cache2 = PyStackRef_ZERO_BITS; + SET_CURRENT_CACHED_VALUES(2); + stack_pointer += -1; + ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); + assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE()); + break; + } + case _MATCH_CLASS_r33: { CHECK_CURRENT_CACHED_VALUES(3); assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE()); diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 72619fd3afa91a..3684b964d844ed 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -10043,6 +10043,52 @@ DISPATCH(); } + TARGET(MATCH_CLASS_ISINSTANCE) { + #if _Py_TAIL_CALL_INTERP + int opcode = MATCH_CLASS_ISINSTANCE; + (void)(opcode); + #endif + frame->instr_ptr = next_instr; + next_instr += 1; + INSTRUCTION_STATS(MATCH_CLASS_ISINSTANCE); + _PyStackRef subject; + _PyStackRef type; + _PyStackRef res; + type = stack_pointer[-1]; + subject = stack_pointer[-2]; + PyObject *subject_o = PyStackRef_AsPyObjectBorrow(subject); + PyObject *type_o = PyStackRef_AsPyObjectBorrow(type); + if (!PyType_Check(type_o)) { + const char *e = "called match pattern must be a class"; + _PyFrame_SetStackPointer(frame, stack_pointer); + _PyErr_Format(tstate, PyExc_TypeError, e); + stack_pointer = _PyFrame_GetStackPointer(frame); + stack_pointer += -1; + ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); + _PyFrame_SetStackPointer(frame, stack_pointer); + PyStackRef_CLOSE(type); + stack_pointer = _PyFrame_GetStackPointer(frame); + JUMP_TO_LABEL(error); + } + _PyFrame_SetStackPointer(frame, stack_pointer); + int retval = PyObject_IsInstance(subject_o, type_o); + stack_pointer = _PyFrame_GetStackPointer(frame); + stack_pointer += -1; + ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); + _PyFrame_SetStackPointer(frame, stack_pointer); + PyStackRef_CLOSE(type); + stack_pointer = _PyFrame_GetStackPointer(frame); + if (retval < 0) { + JUMP_TO_LABEL(error); + } + assert(!_PyErr_Occurred(tstate)); + res = retval ? PyStackRef_True : PyStackRef_False; + stack_pointer[0] = res; + stack_pointer += 1; + ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); + DISPATCH(); + } + TARGET(MATCH_KEYS) { #if _Py_TAIL_CALL_INTERP int opcode = MATCH_KEYS; diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index f57c33feec2ac2..0be9dbbf36e32e 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -24,6 +24,7 @@ static void *opcode_targets_table[256] = { &&TARGET_LOAD_BUILD_CLASS, &&TARGET_LOAD_LOCALS, &&TARGET_MAKE_FUNCTION, + &&TARGET_MATCH_CLASS_ISINSTANCE, &&TARGET_MATCH_KEYS, &&TARGET_MATCH_MAPPING, &&TARGET_MATCH_SEQUENCE, @@ -127,7 +128,6 @@ static void *opcode_targets_table[256] = { &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, - &&_unknown_opcode, &&TARGET_RESUME, &&TARGET_BINARY_OP_ADD_FLOAT, &&TARGET_BINARY_OP_ADD_INT, @@ -380,7 +380,7 @@ static void *opcode_tracing_targets_table[256] = { &&TARGET_TRACE_RECORD, &&TARGET_TRACE_RECORD, &&TARGET_TRACE_RECORD, - &&_unknown_opcode, + &&TARGET_TRACE_RECORD, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, @@ -699,6 +699,7 @@ static PyObject *Py_PRESERVE_NONE_CC _TAIL_CALL_MAKE_CELL(TAIL_CALL_PARAMS); static PyObject *Py_PRESERVE_NONE_CC _TAIL_CALL_MAKE_FUNCTION(TAIL_CALL_PARAMS); static PyObject *Py_PRESERVE_NONE_CC _TAIL_CALL_MAP_ADD(TAIL_CALL_PARAMS); static PyObject *Py_PRESERVE_NONE_CC _TAIL_CALL_MATCH_CLASS(TAIL_CALL_PARAMS); +static PyObject *Py_PRESERVE_NONE_CC _TAIL_CALL_MATCH_CLASS_ISINSTANCE(TAIL_CALL_PARAMS); static PyObject *Py_PRESERVE_NONE_CC _TAIL_CALL_MATCH_KEYS(TAIL_CALL_PARAMS); static PyObject *Py_PRESERVE_NONE_CC _TAIL_CALL_MATCH_MAPPING(TAIL_CALL_PARAMS); static PyObject *Py_PRESERVE_NONE_CC _TAIL_CALL_MATCH_SEQUENCE(TAIL_CALL_PARAMS); @@ -940,6 +941,7 @@ static py_tail_call_funcptr instruction_funcptr_handler_table[256] = { [MAKE_FUNCTION] = _TAIL_CALL_MAKE_FUNCTION, [MAP_ADD] = _TAIL_CALL_MAP_ADD, [MATCH_CLASS] = _TAIL_CALL_MATCH_CLASS, + [MATCH_CLASS_ISINSTANCE] = _TAIL_CALL_MATCH_CLASS_ISINSTANCE, [MATCH_KEYS] = _TAIL_CALL_MATCH_KEYS, [MATCH_MAPPING] = _TAIL_CALL_MATCH_MAPPING, [MATCH_SEQUENCE] = _TAIL_CALL_MATCH_SEQUENCE, @@ -1000,7 +1002,6 @@ static py_tail_call_funcptr instruction_funcptr_handler_table[256] = { [UNPACK_SEQUENCE_TWO_TUPLE] = _TAIL_CALL_UNPACK_SEQUENCE_TWO_TUPLE, [WITH_EXCEPT_START] = _TAIL_CALL_WITH_EXCEPT_START, [YIELD_VALUE] = _TAIL_CALL_YIELD_VALUE, - [121] = _TAIL_CALL_UNKNOWN_OPCODE, [122] = _TAIL_CALL_UNKNOWN_OPCODE, [123] = _TAIL_CALL_UNKNOWN_OPCODE, [124] = _TAIL_CALL_UNKNOWN_OPCODE, @@ -1198,6 +1199,7 @@ static py_tail_call_funcptr instruction_funcptr_tracing_table[256] = { [MAKE_FUNCTION] = _TAIL_CALL_TRACE_RECORD, [MAP_ADD] = _TAIL_CALL_TRACE_RECORD, [MATCH_CLASS] = _TAIL_CALL_TRACE_RECORD, + [MATCH_CLASS_ISINSTANCE] = _TAIL_CALL_TRACE_RECORD, [MATCH_KEYS] = _TAIL_CALL_TRACE_RECORD, [MATCH_MAPPING] = _TAIL_CALL_TRACE_RECORD, [MATCH_SEQUENCE] = _TAIL_CALL_TRACE_RECORD, @@ -1258,7 +1260,6 @@ static py_tail_call_funcptr instruction_funcptr_tracing_table[256] = { [UNPACK_SEQUENCE_TWO_TUPLE] = _TAIL_CALL_TRACE_RECORD, [WITH_EXCEPT_START] = _TAIL_CALL_TRACE_RECORD, [YIELD_VALUE] = _TAIL_CALL_TRACE_RECORD, - [121] = _TAIL_CALL_UNKNOWN_OPCODE, [122] = _TAIL_CALL_UNKNOWN_OPCODE, [123] = _TAIL_CALL_UNKNOWN_OPCODE, [124] = _TAIL_CALL_UNKNOWN_OPCODE, diff --git a/Python/optimizer_cases.c.h b/Python/optimizer_cases.c.h index 2df50ebbcaa1c0..c213b744c39597 100644 --- a/Python/optimizer_cases.c.h +++ b/Python/optimizer_cases.c.h @@ -2648,6 +2648,13 @@ break; } + case _MATCH_CLASS_ISINSTANCE: { + JitOptRef res; + res = sym_new_not_null(ctx); + stack_pointer[-1] = res; + break; + } + case _MATCH_CLASS: { JitOptRef names; JitOptRef type;