-
-
Notifications
You must be signed in to change notification settings - Fork 401
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
Refactor vm calling convention to allow locals #3496
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
70c87f7
Refactor vm calling convention to allow locals
HalidOdat e41cc99
Move async generator object to the stack
HalidOdat 887a3f4
Apply review and some clean-up
HalidOdat a5628f3
Add todo for storing fp in CallFrame
HalidOdat 8d41a22
Rename ASYNC_GENERATOR_OBJECT_LOCAL_INDEX to ASYNC_GENERATOR_OBJECT_R…
HalidOdat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 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 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 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 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General thought on this: Would it be better to store this
fp
as asp
(although I'm not sure it's a true stack pointer, maybelp
for local pointer), and keep thefp
and make up the memory by computing the argument count viaself.sp - self.fp - Self::FUNCTION_PROLOGUE
or would computing the args count be more inefficient?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think calling it sp would be correct, sp is implict in the stack vec itself that being the length (pointing to the position that the next value will be put).
Native calling conventions the arguments passed are not part of the call frame of the callee. But it doesn't really matter, since we can make our own convention. 😄
The biggest reason for
fp
change is to reduce the computation needed to access locals before we would have to dofp + FUNCTION_PROLOGUE + arg_count + local_offset
with this change we only dofp + local_offset
.I kind of hinted at the next change, switching to a register based VM 😄 Registers will be used extensively so we want fast access. I think it's a good time to switch before we are too dependent on the stack version, while working on #3037 Modeling data flow of stack based VMs is much harder, and was conflicted whether to continue development, since it would make switching much harder and it will have to be redone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yepp! I noticed the register based shift!
Just for clarity, I meant keep
fp
and thenlocal pointer
/sp
(whatever we call it) in exchange forargument_count
. It would then exchangingrestore_fp
in exchange for calculatingargument_count
. I think we still compute the argument_start anyways, which can then just befp + FUNCTION_PROLOGUE
overfp - argument_count
.The idea was that maybe we save a bit of compute by not having to use
restore_fp
in exchange for calculating the arg_count. At least that was the thought I had (could be off on that), but thought I'd run it by you nonetheless. Of course, if that would somehow undercut the register shift you had in mind, then completely disregard this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay. I decided to leave this for after we implement the register VM, added a todo so I don't forget 😅 .
I renamed the fp into rp (register pointer), calling it register pointer, instead of local pointer for consistency with the registers that will be added into the future.