-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Yul codegen for immutables. #8583
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
Conversation
b5bfea6
to
857d8ec
Compare
99e7b93
to
120dd77
Compare
Still needs tests to be activated. |
d21b9fd
to
3fba8a4
Compare
Should be complete now. |
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 feel confident enough about this code to say that there isn't anything missing (hence no accept) but I carefully read through it all and did not notice anything that would be wrong in an obvious way. Just one stylistic remark about resetContext()
.
94d126c
to
45c99aa
Compare
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.
Looks good, but some comments and remarks.
I'd be fine with merging as is, though, so I'm already approving.
Also: what's the plan for this for wasm? Actually not sure at the moment what state the wasm codegen is in in general.
codecopy(0, dataoffset("<object>"), datasize("<object>")) | ||
|
||
<#storeImmutables> | ||
setimmutable("<immutableName>", <var>) |
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'm still wondering whether this should at some point have a much more general signature, like
setimmutable(0 /* memory offset of code to be modified */, "<object>", "<immutableName>", <var>)
Then immutable references would be an implicit property of yul objects and the semantics would be clearer even if e.g. there's no unique runtime object or a deploy routine that doesn't write code to zero in memory (although I'd not be sure about details, like if the memory offset should be a literal, etc.)...
But then again we might come up with an even better way in the future and I guess it's fine for now (especially since the assembly wouldn't support the extended signature right away).
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.
Referencing the object sounds like a good idea!
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.
Maybe we could come up with a more sophisticated codecopy
function that performs the code copy and the immutable replacement at the same time.
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'll create an issue for it.
Part of #8551