gh-109979: Unify _GUARD_TYPE_VERSION{,_STORE} (#110301)

Now the target for `DEOPT_IF()` is auto-filled,
we don't need a separate `_GUARD_TYPE_VERSION_STORE` uop.
This commit is contained in:
Guido van Rossum 2023-10-03 15:37:21 -07:00 committed by GitHub
parent a376a72bd9
commit 625ecbe92e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 63 deletions

View File

@ -49,37 +49,36 @@
#define _LOAD_ATTR_SLOT 321
#define _GUARD_DORV_VALUES 322
#define _STORE_ATTR_INSTANCE_VALUE 323
#define _GUARD_TYPE_VERSION_STORE 324
#define _STORE_ATTR_SLOT 325
#define _IS_NONE 326
#define _ITER_CHECK_LIST 327
#define _ITER_JUMP_LIST 328
#define _IS_ITER_EXHAUSTED_LIST 329
#define _ITER_NEXT_LIST 330
#define _ITER_CHECK_TUPLE 331
#define _ITER_JUMP_TUPLE 332
#define _IS_ITER_EXHAUSTED_TUPLE 333
#define _ITER_NEXT_TUPLE 334
#define _ITER_CHECK_RANGE 335
#define _ITER_JUMP_RANGE 336
#define _IS_ITER_EXHAUSTED_RANGE 337
#define _ITER_NEXT_RANGE 338
#define _GUARD_DORV_VALUES_INST_ATTR_FROM_DICT 339
#define _GUARD_KEYS_VERSION 340
#define _LOAD_ATTR_METHOD_WITH_VALUES 341
#define _LOAD_ATTR_METHOD_NO_DICT 342
#define _CHECK_CALL_BOUND_METHOD_EXACT_ARGS 343
#define _INIT_CALL_BOUND_METHOD_EXACT_ARGS 344
#define _CHECK_PEP_523 345
#define _CHECK_FUNCTION_EXACT_ARGS 346
#define _CHECK_STACK_SPACE 347
#define _INIT_CALL_PY_EXACT_ARGS 348
#define _PUSH_FRAME 349
#define _POP_JUMP_IF_FALSE 350
#define _POP_JUMP_IF_TRUE 351
#define _JUMP_TO_TOP 352
#define _SAVE_CURRENT_IP 353
#define _INSERT 354
#define _STORE_ATTR_SLOT 324
#define _IS_NONE 325
#define _ITER_CHECK_LIST 326
#define _ITER_JUMP_LIST 327
#define _IS_ITER_EXHAUSTED_LIST 328
#define _ITER_NEXT_LIST 329
#define _ITER_CHECK_TUPLE 330
#define _ITER_JUMP_TUPLE 331
#define _IS_ITER_EXHAUSTED_TUPLE 332
#define _ITER_NEXT_TUPLE 333
#define _ITER_CHECK_RANGE 334
#define _ITER_JUMP_RANGE 335
#define _IS_ITER_EXHAUSTED_RANGE 336
#define _ITER_NEXT_RANGE 337
#define _GUARD_DORV_VALUES_INST_ATTR_FROM_DICT 338
#define _GUARD_KEYS_VERSION 339
#define _LOAD_ATTR_METHOD_WITH_VALUES 340
#define _LOAD_ATTR_METHOD_NO_DICT 341
#define _CHECK_CALL_BOUND_METHOD_EXACT_ARGS 342
#define _INIT_CALL_BOUND_METHOD_EXACT_ARGS 343
#define _CHECK_PEP_523 344
#define _CHECK_FUNCTION_EXACT_ARGS 345
#define _CHECK_STACK_SPACE 346
#define _INIT_CALL_PY_EXACT_ARGS 347
#define _PUSH_FRAME 348
#define _POP_JUMP_IF_FALSE 349
#define _POP_JUMP_IF_TRUE 350
#define _JUMP_TO_TOP 351
#define _SAVE_CURRENT_IP 352
#define _INSERT 353
extern int _PyOpcode_num_popped(int opcode, int oparg, bool jump);
#ifdef NEED_OPCODE_METADATA
@ -383,8 +382,6 @@ int _PyOpcode_num_popped(int opcode, int oparg, bool jump) {
return 2;
case STORE_ATTR_WITH_HINT:
return 2;
case _GUARD_TYPE_VERSION_STORE:
return 1;
case _STORE_ATTR_SLOT:
return 2;
case STORE_ATTR_SLOT:
@ -941,8 +938,6 @@ int _PyOpcode_num_pushed(int opcode, int oparg, bool jump) {
return 0;
case STORE_ATTR_WITH_HINT:
return 0;
case _GUARD_TYPE_VERSION_STORE:
return 1;
case _STORE_ATTR_SLOT:
return 0;
case STORE_ATTR_SLOT:
@ -1413,7 +1408,6 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[OPCODE_METADATA_SIZE] = {
[_STORE_ATTR_INSTANCE_VALUE] = { true, INSTR_FMT_IXC, 0 },
[STORE_ATTR_INSTANCE_VALUE] = { true, INSTR_FMT_IXC000, HAS_DEOPT_FLAG },
[STORE_ATTR_WITH_HINT] = { true, INSTR_FMT_IBC000, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_DEOPT_FLAG },
[_GUARD_TYPE_VERSION_STORE] = { true, INSTR_FMT_IXC0, HAS_DEOPT_FLAG },
[_STORE_ATTR_SLOT] = { true, INSTR_FMT_IXC, 0 },
[STORE_ATTR_SLOT] = { true, INSTR_FMT_IXC000, HAS_DEOPT_FLAG },
[COMPARE_OP] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_ERROR_FLAG },
@ -1638,8 +1632,8 @@ const struct opcode_macro_expansion _PyOpcode_macro_expansion[OPCODE_MACRO_EXPAN
[LOAD_ATTR] = { .nuops = 1, .uops = { { LOAD_ATTR, 0, 0 } } },
[LOAD_ATTR_INSTANCE_VALUE] = { .nuops = 3, .uops = { { _GUARD_TYPE_VERSION, 2, 1 }, { _CHECK_MANAGED_OBJECT_HAS_VALUES, 0, 0 }, { _LOAD_ATTR_INSTANCE_VALUE, 1, 3 } } },
[LOAD_ATTR_SLOT] = { .nuops = 2, .uops = { { _GUARD_TYPE_VERSION, 2, 1 }, { _LOAD_ATTR_SLOT, 1, 3 } } },
[STORE_ATTR_INSTANCE_VALUE] = { .nuops = 3, .uops = { { _GUARD_TYPE_VERSION_STORE, 2, 1 }, { _GUARD_DORV_VALUES, 0, 0 }, { _STORE_ATTR_INSTANCE_VALUE, 1, 3 } } },
[STORE_ATTR_SLOT] = { .nuops = 2, .uops = { { _GUARD_TYPE_VERSION_STORE, 2, 1 }, { _STORE_ATTR_SLOT, 1, 3 } } },
[STORE_ATTR_INSTANCE_VALUE] = { .nuops = 3, .uops = { { _GUARD_TYPE_VERSION, 2, 1 }, { _GUARD_DORV_VALUES, 0, 0 }, { _STORE_ATTR_INSTANCE_VALUE, 1, 3 } } },
[STORE_ATTR_SLOT] = { .nuops = 2, .uops = { { _GUARD_TYPE_VERSION, 2, 1 }, { _STORE_ATTR_SLOT, 1, 3 } } },
[COMPARE_OP] = { .nuops = 1, .uops = { { COMPARE_OP, 0, 0 } } },
[COMPARE_OP_FLOAT] = { .nuops = 1, .uops = { { COMPARE_OP_FLOAT, 0, 0 } } },
[COMPARE_OP_INT] = { .nuops = 1, .uops = { { COMPARE_OP_INT, 0, 0 } } },
@ -1714,7 +1708,6 @@ const char * const _PyOpcode_uop_name[OPCODE_UOP_NAME_SIZE] = {
[_LOAD_ATTR_SLOT] = "_LOAD_ATTR_SLOT",
[_GUARD_DORV_VALUES] = "_GUARD_DORV_VALUES",
[_STORE_ATTR_INSTANCE_VALUE] = "_STORE_ATTR_INSTANCE_VALUE",
[_GUARD_TYPE_VERSION_STORE] = "_GUARD_TYPE_VERSION_STORE",
[_STORE_ATTR_SLOT] = "_STORE_ATTR_SLOT",
[_IS_NONE] = "_IS_NONE",
[_ITER_CHECK_LIST] = "_ITER_CHECK_LIST",

View File

@ -490,10 +490,6 @@
break;
}
case _GUARD_TYPE_VERSION_STORE: {
break;
}
case _STORE_ATTR_SLOT: {
STACK_SHRINK(2);
break;

View File

@ -2038,7 +2038,7 @@ dummy_func(
macro(STORE_ATTR_INSTANCE_VALUE) =
unused/1 +
_GUARD_TYPE_VERSION_STORE +
_GUARD_TYPE_VERSION +
_GUARD_DORV_VALUES +
_STORE_ATTR_INSTANCE_VALUE;
@ -2083,12 +2083,6 @@ dummy_func(
Py_DECREF(owner);
}
op(_GUARD_TYPE_VERSION_STORE, (type_version/2, owner -- owner)) {
PyTypeObject *tp = Py_TYPE(owner);
assert(type_version != 0);
DEOPT_IF(tp->tp_version_tag != type_version);
}
op(_STORE_ATTR_SLOT, (index/1, value, owner --)) {
char *addr = (char *)owner + index;
STAT_INC(STORE_ATTR, hit);
@ -2100,7 +2094,7 @@ dummy_func(
macro(STORE_ATTR_SLOT) =
unused/1 +
_GUARD_TYPE_VERSION_STORE +
_GUARD_TYPE_VERSION +
_STORE_ATTR_SLOT;
family(COMPARE_OP, INLINE_CACHE_ENTRIES_COMPARE_OP) = {

View File

@ -1761,16 +1761,6 @@
break;
}
case _GUARD_TYPE_VERSION_STORE: {
PyObject *owner;
owner = stack_pointer[-1];
uint32_t type_version = (uint32_t)operand;
PyTypeObject *tp = Py_TYPE(owner);
assert(type_version != 0);
DEOPT_IF(tp->tp_version_tag != type_version, _GUARD_TYPE_VERSION_STORE);
break;
}
case _STORE_ATTR_SLOT: {
PyObject *owner;
PyObject *value;

View File

@ -2616,7 +2616,7 @@
TARGET(STORE_ATTR_INSTANCE_VALUE) {
PyObject *owner;
PyObject *value;
// _GUARD_TYPE_VERSION_STORE
// _GUARD_TYPE_VERSION
owner = stack_pointer[-1];
{
uint32_t type_version = read_u32(&next_instr[1].cache);
@ -2705,7 +2705,7 @@
TARGET(STORE_ATTR_SLOT) {
PyObject *owner;
PyObject *value;
// _GUARD_TYPE_VERSION_STORE
// _GUARD_TYPE_VERSION
owner = stack_pointer[-1];
{
uint32_t type_version = read_u32(&next_instr[1].cache);