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

feat: integrate Control with heap #18

Merged
merged 13 commits into from
Apr 1, 2024
Merged

Conversation

shenyih0ng
Copy link
Owner

@shenyih0ng shenyih0ng commented Mar 31, 2024

Description

This PR integrates the Control with the heap, allocating values that can appear in the Control stack on the heap and only keeping track of of the heap address.

There are however still a bunch of operations that are not supported on the heap currently, namely PopTillMOp, BranchOp and Marker ops. I have deliberately left it out as I would like to revisit how we can refactor the PopTillMOp so that it is easier to serialise on the heap. PopTillMOp was conceptualised as a "catch-all" op where you can pop till any one of the specified markers. This introduces some difficulties in trying to minimise heap footprint as we need to support arbitrary number of markers if we are trying go for generality.

This is mainly so that we are able to maintain a state to keep track of
what is the next `uid` for a AST node. We need to produce more uid since
we may do runtime transpilation (e.g. `ForClause` -> `ForCondition`) that
introduces more AST nodes. A more straightforward example would be the
inject of `main()` call expression to the AST before the execution,
where the `CallExpression` needs a uid.
@shenyih0ng shenyih0ng self-assigned this Mar 31, 2024
`pre-commit` and `pre-push` hooks are super slow and we don't have any
tests right now so I decided to remove it temporarily (we can always
revert it later).
Added helper functions in the heap to allocate/resolve multiple values.
This would prevent having to `H.(alloc/resolve).bind(H)` multiple times
in the ECE
Bunch of minor refactors to make code more readable
Currently, we are doing a in-place uid assign to `CALL_MAIN` and we only
assign a uid if there no uid in the node. However, since `CALL_MAIN` in
the outer scope of `evaluate`, we do not assign the right uid on each
run of `evaluate`, since the `SourceFile` uid changes.
@shenyih0ng shenyih0ng force-pushed the feat/control-heap-integration branch from 34fa897 to 9e7ea09 Compare March 31, 2024 07:23
@shenyih0ng shenyih0ng force-pushed the feat/control-heap-integration branch from 9e7ea09 to c483776 Compare March 31, 2024 07:40
@shenyih0ng shenyih0ng marked this pull request as ready for review April 1, 2024 06:57
@shenyih0ng shenyih0ng merged commit 983a274 into master Apr 1, 2024
1 check passed
@shenyih0ng shenyih0ng deleted the feat/control-heap-integration branch April 1, 2024 06:59
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