Description
In #592 (and python/cpython#104909) we're trying to split bytecode ops into micro ops (uops) with the constraint of one "data item" per uop, where a data item is either oparg
or a cache item.
This runs into some issues with conditional stack effects. For example, take the specializations for LOAD_GLOBAL
(LOAD_GLOBAL_MODULE
and LOAD_GLOBAL_BUILTIN
) and for LOAD_ATTR
(e.g. LOAD_ATTR_INSTANCE_VALUE
). These opcodes must end in something that pushes either a NULL
and a result, or just a result, depending on the low bit of oparg
. But the result being pushed also depends on a cached value. We also can't push the NULL
before the last DEOPT_IF
or ERROR_IF
call.
Maybe we can add the conditionality to the macro itself, e.g.
macro(FOO) = (oparg & 1) ? A + B + C : A + C; // Syntax to be bikeshedded
Here B
would be the uop that pushes NULL
.
Or maybe the null if (oparg & 1)
phrasing of the output stack effect in the uop definition is enough?
For reference:
LOAD_GLOBAL
: https://github.com/python/cpython/compare/main...faster-cpython:cpython:split-load-global?expand=1LOAD_ATTR
: https://github.com/python/cpython/compare/main...faster-cpython:cpython:split-load-attr?expand=1#diff-729a985b0cb8b431cb291f1edb561bbbfea22e3f8c262451cd83328a0936a342R1787