forked from source-academy/js-slang
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
`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
force-pushed
the
feat/control-heap-integration
branch
from
March 31, 2024 07:23
34fa897
to
9e7ea09
Compare
shenyih0ng
force-pushed
the
feat/control-heap-integration
branch
from
March 31, 2024 07:40
9e7ea09
to
c483776
Compare
Added some helper functions to `AstMap`
Instead of having a extra `ApplyBuiltinOp`, we execute the op during the handling of `CallOp`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR integrates the
Control
with the heap, allocating values that can appear in theControl
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
andMarker
ops. I have deliberately left it out as I would like to revisit how we can refactor thePopTillMOp
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.