Skip to content

Conditional macro-op expansion? #595

Closed
@gvanrossum

Description

@gvanrossum

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions