Skip to content
Prev Previous commit
Next Next commit
Apply suggestions from code review
  • Loading branch information
Eclips4 committed Feb 22, 2024
commit bb951796824b649d6a00367844929df797f3b4e2
26 changes: 13 additions & 13 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ dummy_func(
TO_BOOL_STR,
};

tier1 specializing op(_SPECIALIZE_TO_BOOL, (counter/1, value -- value)) {
specializing op(_SPECIALIZE_TO_BOOL, (counter/1, value -- value)) {
#if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_IS_ZERO(counter)) {
next_instr = this_instr;
Expand Down Expand Up @@ -539,7 +539,7 @@ dummy_func(
BINARY_SUBSCR_TUPLE_INT,
};

tier1 specializing op(_SPECIALIZE_BINARY_SUBSCR, (counter/1, container, sub -- container, sub)) {
specializing op(_SPECIALIZE_BINARY_SUBSCR, (counter/1, container, sub -- container, sub)) {
#if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_IS_ZERO(counter)) {
next_instr = this_instr;
Expand Down Expand Up @@ -686,7 +686,7 @@ dummy_func(
STORE_SUBSCR_LIST_INT,
};

tier1 specializing op(_SPECIALIZE_STORE_SUBSCR, (counter/1, container, sub -- container, sub)) {
specializing op(_SPECIALIZE_STORE_SUBSCR, (counter/1, container, sub -- container, sub)) {
#if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_IS_ZERO(counter)) {
next_instr = this_instr;
Expand Down Expand Up @@ -970,7 +970,7 @@ dummy_func(
SEND_GEN,
};

tier1 specializing op(_SPECIALIZE_SEND, (counter/1, receiver, unused -- receiver, unused)) {
specializing op(_SPECIALIZE_SEND, (counter/1, receiver, unused -- receiver, unused)) {
#if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_IS_ZERO(counter)) {
next_instr = this_instr;
Expand Down Expand Up @@ -1199,7 +1199,7 @@ dummy_func(
UNPACK_SEQUENCE_LIST,
};

tier1 specializing op(_SPECIALIZE_UNPACK_SEQUENCE, (counter/1, seq -- seq)) {
specializing op(_SPECIALIZE_UNPACK_SEQUENCE, (counter/1, seq -- seq)) {
#if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_IS_ZERO(counter)) {
next_instr = this_instr;
Expand Down Expand Up @@ -1268,7 +1268,7 @@ dummy_func(
STORE_ATTR_WITH_HINT,
};

tier1 specializing op(_SPECIALIZE_STORE_ATTR, (counter/1, owner -- owner)) {
specializing op(_SPECIALIZE_STORE_ATTR, (counter/1, owner -- owner)) {
#if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_IS_ZERO(counter)) {
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
Expand Down Expand Up @@ -1386,7 +1386,7 @@ dummy_func(
LOAD_GLOBAL_BUILTIN,
};

tier1 specializing op(_SPECIALIZE_LOAD_GLOBAL, (counter/1 -- )) {
specializing op(_SPECIALIZE_LOAD_GLOBAL, (counter/1 -- )) {
#if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_IS_ZERO(counter)) {
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
Expand Down Expand Up @@ -1713,7 +1713,7 @@ dummy_func(
LOAD_SUPER_ATTR_METHOD,
};

tier1 specializing op(_SPECIALIZE_LOAD_SUPER_ATTR, (counter/1, global_super, class, unused -- global_super, class, unused)) {
specializing op(_SPECIALIZE_LOAD_SUPER_ATTR, (counter/1, global_super, class, unused -- global_super, class, unused)) {
#if ENABLE_SPECIALIZATION
int load_method = oparg & 1;
if (ADAPTIVE_COUNTER_IS_ZERO(counter)) {
Expand Down Expand Up @@ -1827,7 +1827,7 @@ dummy_func(
LOAD_ATTR_NONDESCRIPTOR_NO_DICT,
};

tier1 specializing op(_SPECIALIZE_LOAD_ATTR, (counter/1, owner -- owner)) {
specializing op(_SPECIALIZE_LOAD_ATTR, (counter/1, owner -- owner)) {
#if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_IS_ZERO(counter)) {
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
Expand Down Expand Up @@ -2151,7 +2151,7 @@ dummy_func(
COMPARE_OP_STR,
};

tier1 specializing op(_SPECIALIZE_COMPARE_OP, (counter/1, left, right -- left, right)) {
specializing op(_SPECIALIZE_COMPARE_OP, (counter/1, left, right -- left, right)) {
#if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_IS_ZERO(counter)) {
next_instr = this_instr;
Expand Down Expand Up @@ -2492,7 +2492,7 @@ dummy_func(
FOR_ITER_GEN,
};

tier1 specializing op(_SPECIALIZE_FOR_ITER, (counter/1, iter -- iter)) {
specializing op(_SPECIALIZE_FOR_ITER, (counter/1, iter -- iter)) {
#if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_IS_ZERO(counter)) {
next_instr = this_instr;
Expand Down Expand Up @@ -2989,7 +2989,7 @@ dummy_func(
CALL_ALLOC_AND_ENTER_INIT,
};

tier1 specializing op(_SPECIALIZE_CALL, (counter/1, callable, self_or_null, args[oparg] -- callable, self_or_null, args[oparg])) {
specializing op(_SPECIALIZE_CALL, (counter/1, callable, self_or_null, args[oparg] -- callable, self_or_null, args[oparg])) {
#if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_IS_ZERO(counter)) {
next_instr = this_instr;
Expand Down Expand Up @@ -3854,7 +3854,7 @@ dummy_func(
top = Py_NewRef(bottom);
}

tier1 specializing op(_SPECIALIZE_BINARY_OP, (counter/1, lhs, rhs -- lhs, rhs)) {
specializing op(_SPECIALIZE_BINARY_OP, (counter/1, lhs, rhs -- lhs, rhs)) {
#if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_IS_ZERO(counter)) {
next_instr = this_instr;
Expand Down
4 changes: 3 additions & 1 deletion Tools/cases_generator/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ def choice(*opts: str) -> str:
"pure",
"split",
"replicate",
"tier1",
"tier2",
}

__all__ = []
Expand Down Expand Up @@ -288,7 +290,7 @@ def tokenize(src: str, line: int = 1, filename: str = "") -> Iterator[Token]:
text = m.group(0)
if text in keywords:
kind = keywords[text]
elif text in annotations or "tier" in text:
elif text in annotations:
kind = ANNOTATION
elif letter.match(text):
kind = IDENTIFIER
Expand Down
2 changes: 1 addition & 1 deletion Tools/cases_generator/tier2_abstract_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def generate_abstract_interpreter(
if uop.name in abstract.uops:
override = abstract.uops[uop.name]
validate_uop(override, uop)
if uop.properties.tier == 1:
if uop.properties.tier == 1 or "specializing" in uop.annotations:
continue
if uop.replicates:
continue
Expand Down
2 changes: 1 addition & 1 deletion Tools/cases_generator/tier2_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def generate_tier2(
out = CWriter(outfile, 2, lines)
out.emit("\n")
for name, uop in analysis.uops.items():
if uop.properties.tier == 1:
if uop.properties.tier == 1 or "specializing" in uop.annotations:
continue
if uop.properties.oparg_and_1:
out.emit(f"/* {uop.name} is split on (oparg & 1) */\n\n")
Expand Down