mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core/vm: optimize push1
This commit is contained in:
parent
97ab46ba19
commit
bda409a02a
2 changed files with 16 additions and 1 deletions
|
|
@ -886,6 +886,21 @@ func opSuicide(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memo
|
||||||
return nil, nil
|
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
|
// following functions are used by the instruction jump table
|
||||||
|
|
||||||
// make log instruction function
|
// make log instruction function
|
||||||
|
|
|
||||||
|
|
@ -567,7 +567,7 @@ func newFrontierInstructionSet() [256]operation {
|
||||||
valid: true,
|
valid: true,
|
||||||
},
|
},
|
||||||
PUSH1: {
|
PUSH1: {
|
||||||
execute: makePush(1, 1),
|
execute: opPush1,
|
||||||
constantGas: GasFastestStep,
|
constantGas: GasFastestStep,
|
||||||
minStack: minStack(0, 1),
|
minStack: minStack(0, 1),
|
||||||
maxStack: maxStack(0, 1),
|
maxStack: maxStack(0, 1),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue