-
Notifications
You must be signed in to change notification settings - Fork 95
/
memory_table.go
70 lines (54 loc) · 1.59 KB
/
memory_table.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package vm
import (
"github.com/vitelabs/go-vite/common/helper"
"math/big"
)
// calculates the memory size required for a step
func calcMemSize(off, l *big.Int) *big.Int {
if l.Sign() == 0 {
return helper.Big0
}
return new(big.Int).Add(off, l)
}
func memoryBlake2b(stack *stack) *big.Int {
return calcMemSize(stack.back(0), stack.back(1))
}
func memoryCallDataCopy(stack *stack) *big.Int {
return calcMemSize(stack.back(0), stack.back(2))
}
func memoryCodeCopy(stack *stack) *big.Int {
return calcMemSize(stack.back(0), stack.back(2))
}
func memoryExtCodeCopy(stack *stack) *big.Int {
return calcMemSize(stack.back(1), stack.back(3))
}
func memoryReturnDataCopy(stack *stack) *big.Int {
return calcMemSize(stack.back(0), stack.back(2))
}
func memoryMLoad(stack *stack) *big.Int {
return calcMemSize(stack.back(0), helper.Big32)
}
func memoryMStore(stack *stack) *big.Int {
return calcMemSize(stack.back(0), helper.Big32)
}
func memoryMStore8(stack *stack) *big.Int {
return calcMemSize(stack.back(0), helper.Big1)
}
func memoryLog(stack *stack) *big.Int {
mSize, mStart := stack.back(1), stack.back(0)
return calcMemSize(mStart, mSize)
}
func memoryDelegateCall(stack *stack) *big.Int {
x := calcMemSize(stack.back(3), stack.back(4))
y := calcMemSize(stack.back(1), stack.back(2))
return helper.BigMax(x, y)
}
func memoryCall(stack *stack) *big.Int {
return calcMemSize(stack.back(3), stack.back(4))
}
func memoryReturn(stack *stack) *big.Int {
return calcMemSize(stack.back(0), stack.back(1))
}
func memoryRevert(stack *stack) *big.Int {
return calcMemSize(stack.back(0), stack.back(1))
}