Skip to content

Commit

Permalink
Optimize sload
Browse files Browse the repository at this point in the history
  • Loading branch information
gianbelinche committed May 17, 2024
1 parent 19b81f7 commit fb88864
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 @@ -578,13 +578,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 @@ -1870,13 +1870,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 @@ -4457,13 +4459,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 fb88864

Please sign in to comment.