Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tier 2 optimizer's abstract interpreter #114058

Closed
Tracked by #113710
Fidget-Spinner opened this issue Jan 14, 2024 · 7 comments
Closed
Tracked by #113710

Tier 2 optimizer's abstract interpreter #114058

Fidget-Spinner opened this issue Jan 14, 2024 · 7 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@Eclips4 Eclips4 added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Jan 14, 2024
@markshannon
Copy link
Member

We need a lattice of values that embodies type information, NULLness, Noneness, constant values, version numbers, at the least.

The lattice should look something like this:

graph BT;
    t("True");
    f("False");
    bl("bool");
    nnull(not NULL);
    nnone(not None);
    ot(other types);
    oc(other constants);
    b("bottom(unknown)");
    b-->NULL;
    b-->nnull;
    nnull-->nnone;
    nnull-->None;
    nnone-->ot;
    nnone-->bl;
    ot-->oc;
    oc-->top;
    None-->top;
    NULL-->top;
    bl-->t;
    bl-->f;
    t-->top;
    f-->top;
Loading

@markshannon
Copy link
Member

There should be edges from all the nodes (except bottom) to top, but I've omitted those to avoid the diagram becoming a mess

Fidget-Spinner added a commit that referenced this issue Feb 13, 2024
---------

Co-authored-by: Mark Shannon <[email protected]>
Co-authored-by: Jules <[email protected]>
Co-authored-by: Guido van Rossum <[email protected]>
fsc-eriker pushed a commit to fsc-eriker/cpython that referenced this issue Feb 14, 2024
…onGH-115085)

---------

Co-authored-by: Mark Shannon <[email protected]>
Co-authored-by: Jules <[email protected]>
Co-authored-by: Guido van Rossum <[email protected]>
fsc-eriker pushed a commit to fsc-eriker/cpython that referenced this issue Feb 14, 2024
@gvanrossum
Copy link
Member

There should be edges from all the nodes (except bottom) to top, but I've omitted those to avoid the diagram becoming a mess

Maybe top needn't be part of the diagram at all? It ought to be unreachable (IIUC it represents an impossible condition). Might as well simplify the diagram a bit further.

@gvanrossum
Copy link
Member

gvanrossum commented Feb 25, 2024

According to Wikipedia, in type theory, Bottom (⊥) is the type that has no values, whereas Top (⊤) is the type that encompasses all values. Maybe we should switch to this terminology, and swap top and bottom in the diagram above, so that "unknown" is named "top" and there is an arrow from every other nod to "bottom"? (Possibly also just flipping the diagram upside down so that "top" is drawn at the top and "bottom" at the bottom?)

@gvanrossum
Copy link
Member

gvanrossum commented Feb 25, 2024

graph TB;
    t("True");
    f("False");
    bl("bool");
    nnull(not NULL);
    nnone(not None);
    ot(other types);
    oc(other constants);
    top("top (unknown)");
    bottom("bottom (contradiction)");
    top-->NULL;
    top-->nnull;
    nnull-->nnone;
    nnull-->None;
    nnone-->ot;
    nnone-->bl;
    ot-->oc;
    oc-->bottom;
    None-->bottom;
    NULL-->bottom;
    bl-->t;
    bl-->f;
    t-->bottom;
    f-->bottom;
Loading

@gvanrossum
Copy link
Member

Offline we agreed that Top is the universal type and Bottom is the empty type, like in my latest diagram. I will update diagrams and text where these terms are used.

@gvanrossum
Copy link
Member

See faster-cpython/ideas#658

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants