mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46:43 +00:00
core/vm: opt opPushx
This commit is contained in:
parent
c3ef6c77c2
commit
0308afc443
2 changed files with 22 additions and 6 deletions
|
|
@ -990,12 +990,9 @@ func makePush(size uint64, pushByteSize int) executionFunc {
|
||||||
start = min(codeLen, int(*pc+1))
|
start = min(codeLen, int(*pc+1))
|
||||||
end = min(codeLen, start+pushByteSize)
|
end = min(codeLen, start+pushByteSize)
|
||||||
)
|
)
|
||||||
a := new(uint256.Int).SetBytes(scope.Contract.Code[start:end])
|
var b [32]byte
|
||||||
|
copy(b[:], scope.Contract.Code[start:end])
|
||||||
// Missing bytes: pushByteSize - len(pushData)
|
a := new(uint256.Int).SetBytes(b[:pushByteSize])
|
||||||
if missing := pushByteSize - (end - start); missing > 0 {
|
|
||||||
a.Lsh(a, uint(8*missing))
|
|
||||||
}
|
|
||||||
scope.Stack.push(a)
|
scope.Stack.push(a)
|
||||||
*pc += size
|
*pc += size
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|
|
||||||
|
|
@ -973,6 +973,25 @@ func TestPush(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkPush(b *testing.B) {
|
||||||
|
code := common.FromHex("ff")
|
||||||
|
|
||||||
|
push32 := makePush(32, 32)
|
||||||
|
|
||||||
|
scope := &ScopeContext{
|
||||||
|
Memory: nil,
|
||||||
|
Stack: newstack(),
|
||||||
|
Contract: &Contract{
|
||||||
|
Code: code,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
b.ResetTimer()
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
pc := new(uint64)
|
||||||
|
_, _ = push32(pc, nil, scope)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestOpCLZ(t *testing.T) {
|
func TestOpCLZ(t *testing.T) {
|
||||||
evm := NewEVM(BlockContext{}, nil, params.TestChainConfig, Config{})
|
evm := NewEVM(BlockContext{}, nil, params.TestChainConfig, Config{})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue