Skip to content

Commit

Permalink
Merge pull request #479 from lambdaclass/sload-optimization
Browse files Browse the repository at this point in the history
[EVM-Equivalence-YUL] Optimize sload
  • Loading branch information
jrchatruc authored May 22, 2024
2 parents 83f8847 + fb88864 commit b4788f6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions system-contracts/contracts/EvmInterpreterLoop.template.yul
Original file line number Diff line number Diff line change
Expand Up @@ -580,13 +580,15 @@ for { } true { } {

key, sp := popStackItem(sp)

if iszero(isSlotWarm(key)) {
let wasWarm := isSlotWarm(key)

if iszero(wasWarm) {
evmGasLeft := chargeGas(evmGasLeft, 2000)
}

value := sload(key)

if iszero(isSlotWarm(key)) {
if iszero(wasWarm) {
let _wasW, _orgV := warmSlot(key, value)
}

Expand Down
12 changes: 8 additions & 4 deletions system-contracts/contracts/EvmInterpreterPreprocessed.yul
Original file line number Diff line number Diff line change
Expand Up @@ -1872,13 +1872,15 @@ object "EVMInterpreter" {

key, sp := popStackItem(sp)

if iszero(isSlotWarm(key)) {
let wasWarm := isSlotWarm(key)

if iszero(wasWarm) {
evmGasLeft := chargeGas(evmGasLeft, 2000)
}

value := sload(key)

if iszero(isSlotWarm(key)) {
if iszero(wasWarm) {
let _wasW, _orgV := warmSlot(key, value)
}

Expand Down Expand Up @@ -4461,13 +4463,15 @@ object "EVMInterpreter" {

key, sp := popStackItem(sp)

if iszero(isSlotWarm(key)) {
let wasWarm := isSlotWarm(key)

if iszero(wasWarm) {
evmGasLeft := chargeGas(evmGasLeft, 2000)
}

value := sload(key)

if iszero(isSlotWarm(key)) {
if iszero(wasWarm) {
let _wasW, _orgV := warmSlot(key, value)
}

Expand Down

0 comments on commit b4788f6

Please sign in to comment.