KEMBAR78
[mypyc] Add LoadLiteral and use tables to construct and store literals, try 2 by JukkaL · Pull Request #10147 · python/mypy · GitHub
Skip to content

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Feb 27, 2021

This is my second attempt to land this. See the first attempt (#10040) for the details.

Previously this broke Windows wheel builds. The change from the first attempt is that
instead of generating long static C strings, we generate arrays of shorter strings.

#10040)

Redesign the implementation of constant `PyObject *` values, such as string and integer 
literals.

There are several related changes:
* Add `LoadLiteral` op for loading literal values instead of using `LoadStatic`.
* No longer store all literals in a table while we construct IR to make it easier to remove
  literals no longer needed after optimizations in the future.
* Simplify the pretty-printed IR for loading literals.
* Rename the helpers used to construct literal references (e.g. `load_static_unicode` -> 
  `load_str`).
* Collect all used literals values after we have final IR.
* Store literal value initialization information in C arrays instead of generating code for 
  each value.
* Store constructed literal objects in a single `CPyStatics` array.

The goal is to speed up compiles (slightly) and to make it easy to support tuple literals
and efficient table-driven import statements. Both of these can use the `CPyStatics` array.

Closes mypyc/mypyc#794. Closes mypyc/mypyc#797.
This hopefully helps with MSVC build failures.
@JukkaL JukkaL merged commit 5eecc40 into master Feb 27, 2021
@JukkaL JukkaL deleted the table-based-literals branch February 27, 2021 16:33
JukkaL added a commit that referenced this pull request Feb 27, 2021
…y 2 (#10148)

This adds back #10041 that was reverted because of failing Windows builds.

The Windows issue was fixed in #10147, so this is just a rebased version of the
original PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant