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

Emit PUSH0 as junk in evm code transform, if available. #14133

Merged
merged 1 commit into from
Apr 17, 2023

Conversation

ekpyron
Copy link
Member

@ekpyron ekpyron commented Apr 17, 2023

Part of #14073

Changes the code transform towards producing a less-weird PUSH0 instead of CODESIZE - this doesn't make much of a difference other than aesthetics (codesize occurring in these cases was a bit weird).

@ekpyron ekpyron enabled auto-merge April 17, 2023 14:20
if (m_assembly.evmVersion().hasPush0())
m_assembly.appendConstant(0);
else
m_assembly.appendInstruction(evmasm::Instruction::CODESIZE);
Copy link
Member

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).

Copy link
Member Author

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 :-).

Comment on lines +354 to +357
if (m_assembly.evmVersion().hasPush0())
m_assembly.appendConstant(0);
else
m_assembly.appendInstruction(evmasm::Instruction::CODESIZE);
Copy link
Member Author

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.

Copy link
Member

@axic axic left a 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.

@ekpyron
Copy link
Member Author

ekpyron commented Apr 17, 2023

Maybe this needs a changelog entry given the effect on generated code.

I'd have said this falls under the entry of #14107

@ekpyron
Copy link
Member Author

ekpyron commented Apr 17, 2023

Added an explicit changelog entry now in any case.

@ekpyron ekpyron mentioned this pull request Apr 17, 2023
12 tasks
@ekpyron ekpyron merged commit 9befe1d into develop Apr 17, 2023
@ekpyron ekpyron deleted the codeTransformPush0 branch April 17, 2023 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants