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

EOF: Refactor assemble functions in evmasm::Assembly #15446

Merged
merged 1 commit into from
Sep 25, 2024

Conversation

rodiazet
Copy link
Contributor

  • Separate common code from assembleLegacy and assebleEOF to be reused.
  • Separate big and unreadable switchs to corresponding functions.

Copy link

Thank you for your contribution to the Solidity compiler! A team member will follow up shortly.

If you haven't read our contributing guidelines and our review checklist before, please do it now, this makes the reviewing process and accepting your contribution smoother.

If you have any questions or need our help, feel free to post them in the PR or talk to us directly on the #solidity-dev channel on Matrix.

@cameel cameel changed the title eof: Refactor assemble functions in evmasm::Assembly` eof: Refactor assemble functions in evmasm::Assembly Sep 23, 2024
Copy link
Member

@cameel cameel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good in terms of correctness - I haven't noticed any actual problems or bugs. There some very easy to fix cosmetic style issues like the missing _ or tab alignment that would be nice to fix before we merge.

Since you were thinking about the best way to refactor it, I also left some of my reflections on that. Note that some of them are mutually exclusive (e.g. no point defining types if you take the suggestion not to move the switches into dispatch functions), so just choose one. But also please don't take those as requirements for this to be approved - they're just FYI if you want to improve it a bit before we merge, but the main issue (duplication) is solved so I'm just going to go along with whatever you push next. I want to get this merged quickly so that we can proceed with the next PR.

libevmasm/Assembly.h Outdated Show resolved Hide resolved
libevmasm/Assembly.h Outdated Show resolved Hide resolved
libevmasm/Assembly.h Outdated Show resolved Hide resolved
libevmasm/Assembly.h Outdated Show resolved Hide resolved
libevmasm/Assembly.cpp Outdated Show resolved Hide resolved
libevmasm/Assembly.cpp Outdated Show resolved Hide resolved
libevmasm/Assembly.h Show resolved Hide resolved
@rodiazet rodiazet force-pushed the eof-prep-4-refactor branch 3 times, most recently from 64aa730 to 2af37a1 Compare September 24, 2024 13:06
@rodiazet rodiazet changed the title eof: Refactor assemble functions in evmasm::Assembly EOF: Refactor assemble functions in evmasm::Assembly Sep 24, 2024
cameel
cameel previously approved these changes Sep 24, 2024
Copy link
Member

@cameel cameel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect.

I'd have merged it already but noticed some typos that I wanted to correct first. I wanted to just do it myself, but could not push a commit to your branch. I pushed a new branch instead: eof-prep-4-refactor. This solves the extra comments I left below. If you pull it into your branch and squash, we can merge.

libevmasm/Assembly.cpp Outdated Show resolved Hide resolved
libevmasm/LinkerObject.h Show resolved Hide resolved
solRequire(_pos < 0xffffffffL, AssemblyException, "Tag too large.");
size_t tagId = static_cast<size_t>(_item.data());
solRequire(m_tagPositionsInBytecode[tagId] == std::numeric_limits<size_t>::max(), AssemblyException, "Duplicate tag position.");
m_tagPositionsInBytecode[tagId] = _pos;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WTF, didn't even notice that we have that one defined as mutable :) I expected you to have to move it to m_tagPositionsInBytecode. But now I see that our assemble() is const too... Well, TBH I don't like how m_tagPositionsInBytecode works and I'd design it differently myself, but I want the PR merged, so probably no point messing with it now.

@rodiazet
Copy link
Contributor Author

Perfect.

I'd have merged it already but noticed some typos that I wanted to correct first. I wanted to just do it myself, but could not push a commit to your branch. I pushed a new branch instead: eof-prep-4-refactor. This solves the extra comments I left below. If you pull it into your branch and squash, we can merge.

Done. You can merge.

@cameel cameel enabled auto-merge September 25, 2024 11:58
@cameel cameel disabled auto-merge September 25, 2024 11:59
@cameel cameel enabled auto-merge September 25, 2024 11:59
@cameel cameel merged commit 4b285f1 into ethereum:develop Sep 25, 2024
72 checks passed
@rodiazet rodiazet deleted the eof-prep-4-refactor branch December 9, 2024 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants