mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 18:30:45 +00:00
core/vm: use pointers to operations vs. copy by value (#21336)
This commit is contained in:
parent
192edc0c63
commit
06d5da016c
3 changed files with 16 additions and 159 deletions
|
|
@ -52,12 +52,11 @@ func enable1884(jt *JumpTable) {
|
||||||
jt[EXTCODEHASH].constantGas = params.ExtcodeHashGasEIP1884
|
jt[EXTCODEHASH].constantGas = params.ExtcodeHashGasEIP1884
|
||||||
|
|
||||||
// New opcode
|
// New opcode
|
||||||
jt[SELFBALANCE] = operation{
|
jt[SELFBALANCE] = &operation{
|
||||||
execute: opSelfBalance,
|
execute: opSelfBalance,
|
||||||
constantGas: GasFastStep,
|
constantGas: GasFastStep,
|
||||||
minStack: minStack(0, 1),
|
minStack: minStack(0, 1),
|
||||||
maxStack: maxStack(0, 1),
|
maxStack: maxStack(0, 1),
|
||||||
valid: true,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,12 +70,11 @@ func opSelfBalance(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx
|
||||||
// - Adds an opcode that returns the current chain’s EIP-155 unique identifier
|
// - Adds an opcode that returns the current chain’s EIP-155 unique identifier
|
||||||
func enable1344(jt *JumpTable) {
|
func enable1344(jt *JumpTable) {
|
||||||
// New opcode
|
// New opcode
|
||||||
jt[CHAINID] = operation{
|
jt[CHAINID] = &operation{
|
||||||
execute: opChainID,
|
execute: opChainID,
|
||||||
constantGas: GasQuickStep,
|
constantGas: GasQuickStep,
|
||||||
minStack: minStack(0, 1),
|
minStack: minStack(0, 1),
|
||||||
maxStack: maxStack(0, 1),
|
maxStack: maxStack(0, 1),
|
||||||
valid: true,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ type Config struct {
|
||||||
NoRecursion bool // Disables call, callcode, delegate call and create
|
NoRecursion bool // Disables call, callcode, delegate call and create
|
||||||
EnablePreimageRecording bool // Enables recording of SHA3/keccak preimages
|
EnablePreimageRecording bool // Enables recording of SHA3/keccak preimages
|
||||||
|
|
||||||
JumpTable [256]operation // EVM instruction table, automatically populated if unset
|
JumpTable [256]*operation // EVM instruction table, automatically populated if unset
|
||||||
|
|
||||||
EWASMInterpreter string // External EWASM interpreter options
|
EWASMInterpreter string // External EWASM interpreter options
|
||||||
EVMInterpreter string // External EVM interpreter options
|
EVMInterpreter string // External EVM interpreter options
|
||||||
|
|
@ -95,7 +95,7 @@ func NewEVMInterpreter(evm *EVM, cfg Config) *EVMInterpreter {
|
||||||
// We use the STOP instruction whether to see
|
// We use the STOP instruction whether to see
|
||||||
// the jump table was initialised. If it was not
|
// the jump table was initialised. If it was not
|
||||||
// we'll set the default jump table.
|
// we'll set the default jump table.
|
||||||
if !cfg.JumpTable[STOP].valid {
|
if cfg.JumpTable[STOP] == nil {
|
||||||
var jt JumpTable
|
var jt JumpTable
|
||||||
switch {
|
switch {
|
||||||
case evm.chainRules.IsIstanbul:
|
case evm.chainRules.IsIstanbul:
|
||||||
|
|
@ -209,7 +209,7 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
|
||||||
// enough stack items available to perform the operation.
|
// enough stack items available to perform the operation.
|
||||||
op = contract.GetOp(pc)
|
op = contract.GetOp(pc)
|
||||||
operation := in.cfg.JumpTable[op]
|
operation := in.cfg.JumpTable[op]
|
||||||
if !operation.valid {
|
if operation == nil {
|
||||||
return nil, &ErrInvalidOpCode{opcode: op}
|
return nil, &ErrInvalidOpCode{opcode: op}
|
||||||
}
|
}
|
||||||
// Validate stack
|
// Validate stack
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue