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

Jit #134

Draft
wants to merge 157 commits into
base: master
Choose a base branch
from
Draft

Jit #134

wants to merge 157 commits into from

Conversation

b-studios
Copy link
Collaborator

This PR is only for discussion and keeping track of the changes in JIT.

Copied from implementation based on old machine,
with new Transformer and minor changes.
Also, collect all used datatypes over program
since all locals are positional in machine, we can just use those
positions as register numbers.

Removes the now unnecessary `RegisterAllocation` analysis on JIT code
Generate information on the used datatypes (which alternatives there
are, with how many fields of what types) into the output for the JIT.
* the main statement is run in an empty environment
* `BlockLabel` does not need to be a `Tree`
Allows easier extension with more register types and handling of registers
Clauses describe the values closed over explicitly,
passed parameters are implicit.
This is now reflected in the name.
The Environment describes the variables currently in scope.
The FrameDescriptor describes merely their numbers (i.e. how many
registers are needed).
There are two ways a clause may be compiled:
As a "closure": only free variables of the clause are copied over, a
new frame is generated.

"inlined": All variables in the current environment survive,
the enclosing frame is extended to leave enough space for the new locals.
For now. Later, maybe add additional Bool registers.
The substitutions generated in machine do not necessarily list all
live variables
Make the frame big enough to fit locals of inline clause
Now also using `transformInline` for consistency
Leave this to the jit executable, which has the frame sizes
we can now run programs using the JIT backend with
`--backend jit --lib libraries/jit <source file>`.

This adds the 5.7M executable to the repository for now.
In the future, we should find a different solution to this.
* Use numbered register for output of Let
* Use `ListMap`s in `PrettyPrinter` (preserve order)
Implement SWITCH for Unit
This is a first step, reusing registers when choosing the names
of the parameters of clauses transformed inline.
Registers are reused if they are not free in the clause.
Currently just throwing an error
* `Let` would not get a new register for the result
* `Switch` would reuse registers, which is not possible with the
  current semantics of the `Match` instruction
b-studios and others added 30 commits January 24, 2023 17:26
i.e.
Return *pre*pends the value to the environment,
as does Invoke.
Also changes findJITBinary to make this easier
This requires a version of the jit binary after
46005416a819a850cd342a7447a7f05e21163e87.
So it can find the data type declarations. We need a better solution for
this.
Breaking change in the output format!

Corresponds to ca28a1f4d030b2bf26700912510666468396699b in
jitting-effects.
Namely: MUL, PRINT, ISZERO, RESUME, RESET
Codata (including closures) will now only capture what's free in at
least one of the clauses.
This drops the spurious 'ev_zero = 0; ev_acc = ev0 + ev_zero; ...' in
evidence composition, simplifying generated code.
block labels for generated blocks are now based on where they are
generated from:
- match: m0,m1,...,m*
- push: p
- if: ?t,?f
- new stack (in reset): r
- codata/effects: c0,c1,...
For now, just use the evidence in Allocate. This requires the smallest
change in the actual jit implementation.
TODO We should evaluate what's the best implementation strategy here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants