-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Emit PUSH0 as junk in evm code transform, if available. #14133
Conversation
if (m_assembly.evmVersion().hasPush0()) | ||
m_assembly.appendConstant(0); | ||
else | ||
m_assembly.appendInstruction(evmasm::Instruction::CODESIZE); |
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 wonder if PC
would have been nicer, given that is never used, and such is easier to detect at runtime (in case of a bug).
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.
Well, maybe, I won't change it here, though, in any case :-).
if (m_assembly.evmVersion().hasPush0()) | ||
m_assembly.appendConstant(0); | ||
else | ||
m_assembly.appendInstruction(evmasm::Instruction::CODESIZE); |
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.
As the comment says: we can push anything here - the reason why we used CODESIZE
was that it's only 1 byte and 2 gas (whereas a PUSH1 0
was 2 bytes and 3 gas) - if we have PUSH0
(which is also 1 byte and 2 gas), that's definitely the nicer choice.
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 this needs a changelog entry given the effect on generated code.
I'd have said this falls under the entry of #14107 |
378a2b8
to
3458da9
Compare
Added an explicit changelog entry now in any case. |
Part of #14073
Changes the code transform towards producing a less-weird
PUSH0
instead ofCODESIZE
- this doesn't make much of a difference other than aesthetics (codesize
occurring in these cases was a bit weird).