Skip to content

Commit e5e1bc7

Browse files
Revert changes to optimizer_bytecodes
1 parent 0c109e0 commit e5e1bc7

File tree

1 file changed

+31
-17
lines changed

1 file changed

+31
-17
lines changed

Python/optimizer_bytecodes.c

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,18 @@ dummy_func(void) {
104104
res = sym_new_null(ctx);
105105
}
106106

107-
op(_GUARD_TOS_INT, (tos -- type(&PyLong_Type) tos)) {
107+
op(_GUARD_TOS_INT, (tos -- tos)) {
108108
if (sym_matches_type(tos, &PyLong_Type)) {
109109
REPLACE_OP(this_instr, _NOP, 0, 0);
110110
}
111+
sym_set_type(tos, &PyLong_Type);
111112
}
112113

113-
op(_GUARD_NOS_INT, (nos, unused -- type(&PyLong_Type) nos, unused)) {
114+
op(_GUARD_NOS_INT, (nos, unused -- nos, unused)) {
114115
if (sym_matches_type(nos, &PyLong_Type)) {
115116
REPLACE_OP(this_instr, _NOP, 0, 0);
116117
}
118+
sym_set_type(nos, &PyLong_Type);
117119
}
118120

119121
op(_GUARD_TYPE_VERSION, (type_version/2, owner -- owner)) {
@@ -139,16 +141,18 @@ dummy_func(void) {
139141
}
140142
}
141143

142-
op(_GUARD_TOS_FLOAT, (tos -- type(&PyFloat_Type) tos)) {
144+
op(_GUARD_TOS_FLOAT, (tos -- tos)) {
143145
if (sym_matches_type(tos, &PyFloat_Type)) {
144146
REPLACE_OP(this_instr, _NOP, 0, 0);
145147
}
148+
sym_set_type(tos, &PyFloat_Type);
146149
}
147150

148-
op(_GUARD_NOS_FLOAT, (nos, unused -- type(&PyFloat_Type) nos, unused)) {
151+
op(_GUARD_NOS_FLOAT, (nos, unused -- nos, unused)) {
149152
if (sym_matches_type(nos, &PyFloat_Type)) {
150153
REPLACE_OP(this_instr, _NOP, 0, 0);
151154
}
155+
sym_set_type(nos, &PyFloat_Type);
152156
}
153157

154158
op(_BINARY_OP, (left, right -- res)) {
@@ -404,16 +408,18 @@ dummy_func(void) {
404408
}
405409
}
406410

407-
op(_GUARD_NOS_UNICODE, (nos, unused -- type(&PyUnicode_Type) nos, unused)) {
411+
op(_GUARD_NOS_UNICODE, (nos, unused -- nos, unused)) {
408412
if (sym_matches_type(nos, &PyUnicode_Type)) {
409413
REPLACE_OP(this_instr, _NOP, 0, 0);
410414
}
415+
sym_set_type(nos, &PyUnicode_Type);
411416
}
412417

413-
op(_GUARD_TOS_UNICODE, (value -- type(&PyUnicode_Type) value)) {
418+
op(_GUARD_TOS_UNICODE, (value -- value)) {
414419
if (sym_matches_type(value, &PyUnicode_Type)) {
415420
REPLACE_OP(this_instr, _NOP, 0, 0);
416421
}
422+
sym_set_type(value, &PyUnicode_Type);
417423
}
418424

419425
op(_TO_BOOL_STR, (value -- res)) {
@@ -423,7 +429,8 @@ dummy_func(void) {
423429
}
424430
}
425431

426-
op(_UNARY_NOT, (type(&PyBool_Type) value -- res)) {
432+
op(_UNARY_NOT, (value -- res)) {
433+
sym_set_type(value, &PyBool_Type);
427434
res = sym_new_truthiness(ctx, value, false);
428435
}
429436

@@ -624,12 +631,13 @@ dummy_func(void) {
624631
self_or_null = sym_new_not_null(ctx);
625632
}
626633

627-
op(_CHECK_FUNCTION_VERSION, (func_version/2, callable, self_or_null, unused[oparg] -- type(&PyFunction_Type) callable, self_or_null, unused[oparg])) {
634+
op(_CHECK_FUNCTION_VERSION, (func_version/2, callable, self_or_null, unused[oparg] -- callable, self_or_null, unused[oparg])) {
628635
if (sym_is_const(ctx, callable) && sym_matches_type(callable, &PyFunction_Type)) {
629636
assert(PyFunction_Check(sym_get_const(ctx, callable)));
630637
REPLACE_OP(this_instr, _CHECK_FUNCTION_VERSION_INLINE, 0, func_version);
631638
this_instr->operand1 = (uintptr_t)sym_get_const(ctx, callable);
632639
}
640+
sym_set_type(callable, &PyFunction_Type);
633641
}
634642

635643
op(_CHECK_FUNCTION_EXACT_ARGS, (callable, self_or_null, unused[oparg] -- callable, self_or_null, unused[oparg])) {
@@ -645,9 +653,9 @@ dummy_func(void) {
645653
}
646654
}
647655

648-
op(_CHECK_CALL_BOUND_METHOD_EXACT_ARGS, (callable, null, unused[oparg] -- type(&PyMethod_Type) callable, null, unused[oparg])) {
656+
op(_CHECK_CALL_BOUND_METHOD_EXACT_ARGS, (callable, null, unused[oparg] -- callable, null, unused[oparg])) {
649657
sym_set_null(null);
650-
(void)callable;
658+
sym_set_type(callable, &PyMethod_Type);
651659
}
652660

653661
op(_INIT_CALL_PY_EXACT_ARGS, (callable, self_or_null, args[oparg] -- new_frame: _Py_UOpsAbstractFrame *)) {
@@ -969,40 +977,46 @@ dummy_func(void) {
969977
}
970978
}
971979

972-
op(_GUARD_TOS_LIST, (tos -- type(&PyList_Type) tos)) {
980+
op(_GUARD_TOS_LIST, (tos -- tos)) {
973981
if (sym_matches_type(tos, &PyList_Type)) {
974982
REPLACE_OP(this_instr, _NOP, 0, 0);
975983
}
984+
sym_set_type(tos, &PyList_Type);
976985
}
977986

978-
op(_GUARD_NOS_LIST, (nos, unused -- type(&PyList_Type) nos, unused)) {
987+
op(_GUARD_NOS_LIST, (nos, unused -- nos, unused)) {
979988
if (sym_matches_type(nos, &PyList_Type)) {
980989
REPLACE_OP(this_instr, _NOP, 0, 0);
981990
}
991+
sym_set_type(nos, &PyList_Type);
982992
}
983993

984-
op(_GUARD_TOS_TUPLE, (tos -- type(&PyTuple_Type) tos)) {
994+
op(_GUARD_TOS_TUPLE, (tos -- tos)) {
985995
if (sym_matches_type(tos, &PyTuple_Type)) {
986996
REPLACE_OP(this_instr, _NOP, 0, 0);
987997
}
998+
sym_set_type(tos, &PyTuple_Type);
988999
}
9891000

990-
op(_GUARD_NOS_TUPLE, (nos, unused -- type(&PyTuple_Type) nos, unused)) {
1001+
op(_GUARD_NOS_TUPLE, (nos, unused -- nos, unused)) {
9911002
if (sym_matches_type(nos, &PyTuple_Type)) {
9921003
REPLACE_OP(this_instr, _NOP, 0, 0);
9931004
}
1005+
sym_set_type(nos, &PyTuple_Type);
9941006
}
9951007

996-
op(_GUARD_TOS_DICT, (tos -- type(&PyDict_Type) tos)) {
1008+
op(_GUARD_TOS_DICT, (tos -- tos)) {
9971009
if (sym_matches_type(tos, &PyDict_Type)) {
9981010
REPLACE_OP(this_instr, _NOP, 0, 0);
9991011
}
1012+
sym_set_type(tos, &PyDict_Type);
10001013
}
10011014

1002-
op(_GUARD_NOS_DICT, (nos, unused -- type(&PyDict_Type) nos, unused)) {
1015+
op(_GUARD_NOS_DICT, (nos, unused -- nos, unused)) {
10031016
if (sym_matches_type(nos, &PyDict_Type)) {
10041017
REPLACE_OP(this_instr, _NOP, 0, 0);
10051018
}
1019+
sym_set_type(nos, &PyDict_Type);
10061020
}
10071021

10081022
op(_GUARD_TOS_ANY_SET, (tos -- tos)) {
@@ -1041,7 +1055,7 @@ dummy_func(void) {
10411055
sym_set_const(callable, (PyObject *)&PyUnicode_Type);
10421056
}
10431057

1044-
op(_CALL_LEN, (callable[1], self_or_null[1], args[oparg] -- type(res)) {
1058+
op(_CALL_LEN, (callable[1], self_or_null[1], args[oparg] -- res)) {
10451059
res = sym_new_type(ctx, &PyLong_Type);
10461060
}
10471061

0 commit comments

Comments
 (0)