Skip to content

Commit

Permalink
core/vm: remove stack.pushN (ethereum#24040)
Browse files Browse the repository at this point in the history
  • Loading branch information
axic authored and gzliudan committed Mar 1, 2024
1 parent b1c0386 commit ae267d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 8 additions & 4 deletions core/vm/instructions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,12 +532,14 @@ func TestOpMstore(t *testing.T) {
mem.Resize(64)
pc := uint64(0)
v := "abcdef00000000000000abba000000000deaf000000c0de00100000000133700"
stack.pushN(*new(uint256.Int).SetBytes(common.Hex2Bytes(v)), *new(uint256.Int))
stack.push(new(uint256.Int).SetBytes(common.Hex2Bytes(v)))
stack.push(new(uint256.Int))
opMstore(&pc, evmInterpreter, &callCtx{mem, stack, nil})
if got := common.Bytes2Hex(mem.GetCopy(0, 32)); got != v {
t.Fatalf("Mstore fail, got %v, expected %v", got, v)
}
stack.pushN(*new(uint256.Int).SetUint64(0x1), *new(uint256.Int))
stack.push(new(uint256.Int).SetUint64(0x1))
stack.push(new(uint256.Int))
opMstore(&pc, evmInterpreter, &callCtx{mem, stack, nil})
if common.Bytes2Hex(mem.GetCopy(0, 32)) != "0000000000000000000000000000000000000000000000000000000000000001" {
t.Fatalf("Mstore failed to overwrite previous value")
Expand All @@ -560,7 +562,8 @@ func BenchmarkOpMstore(bench *testing.B) {

bench.ResetTimer()
for i := 0; i < bench.N; i++ {
stack.pushN(*value, *memStart)
stack.push(value)
stack.push(memStart)
opMstore(&pc, evmInterpreter, &callCtx{mem, stack, nil})
}
}
Expand All @@ -579,7 +582,8 @@ func BenchmarkOpKeccak256(bench *testing.B) {

bench.ResetTimer()
for i := 0; i < bench.N; i++ {
stack.pushN(*uint256.NewInt(32), *start)
stack.push(uint256.NewInt(32))
stack.push(start)
opKeccak256(&pc, evmInterpreter, &callCtx{mem, stack, nil})
}
}
Expand Down
4 changes: 0 additions & 4 deletions core/vm/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ func (st *Stack) push(d *uint256.Int) {
// NOTE push limit (1024) is checked in baseCheck
st.data = append(st.data, *d)
}
func (st *Stack) pushN(ds ...uint256.Int) {
// FIXME: Is there a way to pass args by pointers.
st.data = append(st.data, ds...)
}

func (st *Stack) pop() (ret uint256.Int) {
ret = st.data[len(st.data)-1]
Expand Down

0 comments on commit ae267d3

Please sign in to comment.