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

Logic for allocating stack offsets for function arguments is brittle #151

Open
iafisher opened this issue Aug 31, 2022 · 0 comments
Open
Labels
internal Issues which do not affect end users

Comments

@iafisher
Copy link
Owner

Function arguments are stored on the stack before being moved into the parameter registers. This requires a stack_offset field to be set on each function argument. This would be simple enough if it only had to be set in analyze_call_expression, but there are myriad other places where the analyzer converts a syntactic construct into a new call expression (e.g., list literals turn into a call to venice_list_from_varargs), and in each place you have to remember to set the stack offset for each argument.

It would be better if the stack offsets were allocated in a second pass after generating the AST so that every call expression could be handled in one place. I tried doing this and the issue I ran into is that ast::Symbol looks up its symbol entry when the AST is constructed and stores its own copy, which means that any subsequent updates to the symbol entry's stack offset will be lost.

@iafisher iafisher added the internal Issues which do not affect end users label Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal Issues which do not affect end users
Projects
None yet
Development

No branches or pull requests

1 participant