core/vm: optimize push1

This commit is contained in:
Martin Holst Swende 2019-03-04 08:59:17 +01:00
parent 97ab46ba19
commit bda409a02a
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0
2 changed files with 16 additions and 1 deletions

View file

@ -886,6 +886,21 @@ func opSuicide(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memo
return nil, nil
}
// opPush1 is a specialized version of pushN
func opPush1(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
var (
codeLen = uint64(len(contract.Code))
integer = interpreter.intPool.get()
)
*pc += 1
if *pc < codeLen {
stack.push(integer.SetUint64(uint64(contract.Code[*pc])))
} else {
stack.push(integer.SetUint64(0))
}
return nil, nil
}
// following functions are used by the instruction jump table
// make log instruction function

View file

@ -567,7 +567,7 @@ func newFrontierInstructionSet() [256]operation {
valid: true,
},
PUSH1: {
execute: makePush(1, 1),
execute: opPush1,
constantGas: GasFastestStep,
minStack: minStack(0, 1),
maxStack: maxStack(0, 1),