mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-19 03:10:48 +00:00
core/vm: normalize stack-helper call sites to one form
This commit is contained in:
parent
ed8c379f42
commit
87bf249b71
4 changed files with 17 additions and 16 deletions
|
|
@ -237,7 +237,8 @@ func enable3855(jt *JumpTable) {
|
||||||
|
|
||||||
// opPush0 implements the PUSH0 opcode
|
// opPush0 implements the PUSH0 opcode
|
||||||
func opPush0(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
func opPush0(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.get().Clear()
|
elem := scope.Stack.get()
|
||||||
|
elem.Clear()
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -536,12 +536,14 @@ func opJumpdest(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func opPc(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
func opPc(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.get().SetUint64(*pc)
|
elem := scope.Stack.get()
|
||||||
|
elem.SetUint64(*pc)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opMsize(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
func opMsize(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.get().SetUint64(uint64(scope.Memory.Len()))
|
elem := scope.Stack.get()
|
||||||
|
elem.SetUint64(uint64(scope.Memory.Len()))
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1131,10 +1133,8 @@ func makeLog(size int) executionFunc {
|
||||||
|
|
||||||
// opPush1 is a specialized version of pushN
|
// opPush1 is a specialized version of pushN
|
||||||
func opPush1(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
func opPush1(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
var (
|
codeLen := uint64(len(scope.Contract.Code))
|
||||||
codeLen = uint64(len(scope.Contract.Code))
|
elem := scope.Stack.get()
|
||||||
elem = scope.Stack.get()
|
|
||||||
)
|
|
||||||
*pc += 1
|
*pc += 1
|
||||||
if *pc < codeLen {
|
if *pc < codeLen {
|
||||||
elem.SetUint64(uint64(scope.Contract.Code[*pc]))
|
elem.SetUint64(uint64(scope.Contract.Code[*pc]))
|
||||||
|
|
@ -1146,10 +1146,8 @@ func opPush1(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
|
|
||||||
// opPush2 is a specialized version of pushN
|
// opPush2 is a specialized version of pushN
|
||||||
func opPush2(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
func opPush2(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
var (
|
codeLen := uint64(len(scope.Contract.Code))
|
||||||
codeLen = uint64(len(scope.Contract.Code))
|
elem := scope.Stack.get()
|
||||||
elem = scope.Stack.get()
|
|
||||||
)
|
|
||||||
if *pc+2 < codeLen {
|
if *pc+2 < codeLen {
|
||||||
elem.SetBytes2(scope.Contract.Code[*pc+1 : *pc+3])
|
elem.SetBytes2(scope.Contract.Code[*pc+1 : *pc+3])
|
||||||
} else if *pc+1 < codeLen {
|
} else if *pc+1 < codeLen {
|
||||||
|
|
|
||||||
|
|
@ -705,9 +705,10 @@ mainLoop:
|
||||||
return nil, ErrOutOfGas
|
return nil, ErrOutOfGas
|
||||||
}
|
}
|
||||||
contract.Gas.RegularGas -= 2
|
contract.Gas.RegularGas -= 2
|
||||||
stack.inner.data[stack.inner.top].SetUint64(pc)
|
elem := &stack.inner.data[stack.inner.top]
|
||||||
stack.inner.top++
|
stack.inner.top++
|
||||||
stack.size++
|
stack.size++
|
||||||
|
elem.SetUint64(pc)
|
||||||
pc++
|
pc++
|
||||||
continue mainLoop
|
continue mainLoop
|
||||||
|
|
||||||
|
|
@ -719,9 +720,10 @@ mainLoop:
|
||||||
return nil, ErrOutOfGas
|
return nil, ErrOutOfGas
|
||||||
}
|
}
|
||||||
contract.Gas.RegularGas -= 2
|
contract.Gas.RegularGas -= 2
|
||||||
stack.inner.data[stack.inner.top].SetUint64(uint64(scope.Memory.Len()))
|
elem := &stack.inner.data[stack.inner.top]
|
||||||
stack.inner.top++
|
stack.inner.top++
|
||||||
stack.size++
|
stack.size++
|
||||||
|
elem.SetUint64(uint64(scope.Memory.Len()))
|
||||||
pc++
|
pc++
|
||||||
continue mainLoop
|
continue mainLoop
|
||||||
|
|
||||||
|
|
@ -742,9 +744,10 @@ mainLoop:
|
||||||
return nil, ErrOutOfGas
|
return nil, ErrOutOfGas
|
||||||
}
|
}
|
||||||
contract.Gas.RegularGas -= 2
|
contract.Gas.RegularGas -= 2
|
||||||
stack.inner.data[stack.inner.top].Clear()
|
elem := &stack.inner.data[stack.inner.top]
|
||||||
stack.inner.top++
|
stack.inner.top++
|
||||||
stack.size++
|
stack.size++
|
||||||
|
elem.Clear()
|
||||||
pc++
|
pc++
|
||||||
continue mainLoop
|
continue mainLoop
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -105,10 +105,9 @@ func (s *Stack) push(d *uint256.Int) {
|
||||||
// get returns a pointer to a newly created element
|
// get returns a pointer to a newly created element
|
||||||
// on top of the stack
|
// on top of the stack
|
||||||
func (s *Stack) get() *uint256.Int {
|
func (s *Stack) get() *uint256.Int {
|
||||||
elem := &s.inner.data[s.inner.top]
|
|
||||||
s.inner.top++
|
s.inner.top++
|
||||||
s.size++
|
s.size++
|
||||||
return elem
|
return &s.inner.data[s.inner.top-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Stack) pop() uint256.Int {
|
func (s *Stack) pop() uint256.Int {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue