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

fix(EVM): Change caching of fixed context values #1161

Open
wants to merge 1 commit into
base: evm-emulator/fixes
Choose a base branch
from

Conversation

vladimirradosavljevic
Copy link

What ❔

Instead of caching these values in memory, cache them in local variables that are defined before the main loop.

Why ❔

By doing this, one load will be removed and store will be changed to add that spills variable onto the stack:

before:
	ldm.h	768, r1
	sub!	r1, r0, r0
...
	stm.h	768, r1

after:
	sub!	stack-[12], r0, r0
...
	add	r1, r0, stack-[12]              ; 32-byte Folded Spill

Checklist

  • PR title corresponds to the body of PR (we generate changelog entries from PRs).
  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.

Instead of caching these values in memory, cache
them in local variables that are defined before the
main loop.

Signed-off-by: Vladimir Radosavljevic <vr@matterlabs.dev>
@vladimirradosavljevic
Copy link
Author

Numbers after this change:

╠═╡ Ergs/gas (-%) ╞═╡ EVMInterpreter M3B3 ╞═╣
║ ORIGIN                              3.033 ║
║ CODESIZE                            7.671 ║
║ GASPRICE                            3.040 ║
║ COINBASE                            3.035 ║
║ TIMESTAMP                           3.040 ║
║ NUMBER                              3.040 ║
║ PREVRANDAO                          3.040 ║
║ GASLIMIT                            3.035 ║
║ CHAINID                             3.045 ║
║ BASEFEE                             3.040 ║
║ CALL                               -0.153 ║
║ STATICCALL                         -0.153 ║
║ DELEGATECALL                       -0.164 ║
║ CREATE                             -0.029 ║
║ CREATE2                            -0.031 ║
╚═══════════════════════════════════════════╝

@0xVolosnikov PTAL.

@vladimirradosavljevic vladimirradosavljevic changed the title fix(EVM): Change caching fixed context values fix(EVM): Change caching of fixed context values Dec 20, 2024
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.

1 participant