cpython icon indicating copy to clipboard operation
cpython copied to clipboard

The tier 2 optimizer specification contains too much boilerplate

Open markshannon opened this issue 1 year ago • 0 comments

The tier 2 optimizer specification (optimizer_bytecodes.c) contains lots of boilerplate for handling contradictions and running out of space in the optimizer's data structures. These can be handled but setting flags on the optimizer context and checking those in the abstract interpreter loop.

For example OUT_OF_SPACE_IF_NULL(res = sym_new_unknown(ctx)); can be replaced with res = sym_new_unknown(ctx) and

if (!sym_set_type(right, &PyUnicode_Type)) {
    goto hit_bottom;
}

can be replaced with sym_set_type(left, &PyUnicode_Type);

Hopefully this will make the optimizer a bit more approachable and maintainable

Linked PRs

  • gh-118913

markshannon avatar May 10 '24 14:05 markshannon