github.hscsec.cn/juliankolbe/go-ethereum@v1.9.7/core/vm/memory_table.go (about) 1 // Copyright 2017 The go-ethereum Authors 2 // This file is part of the go-ethereum library. 3 // 4 // The go-ethereum library is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU Lesser General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // The go-ethereum library is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU Lesser General Public License for more details. 13 // 14 // You should have received a copy of the GNU Lesser General Public License 15 // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. 16 17 package vm 18 19 func memorySha3(stack *Stack) (uint64, bool) { 20 return calcMemSize64(stack.Back(0), stack.Back(1)) 21 } 22 23 func memoryCallDataCopy(stack *Stack) (uint64, bool) { 24 return calcMemSize64(stack.Back(0), stack.Back(2)) 25 } 26 27 func memoryReturnDataCopy(stack *Stack) (uint64, bool) { 28 return calcMemSize64(stack.Back(0), stack.Back(2)) 29 } 30 31 func memoryCodeCopy(stack *Stack) (uint64, bool) { 32 return calcMemSize64(stack.Back(0), stack.Back(2)) 33 } 34 35 func memoryExtCodeCopy(stack *Stack) (uint64, bool) { 36 return calcMemSize64(stack.Back(1), stack.Back(3)) 37 } 38 39 func memoryMLoad(stack *Stack) (uint64, bool) { 40 return calcMemSize64WithUint(stack.Back(0), 32) 41 } 42 43 func memoryMStore8(stack *Stack) (uint64, bool) { 44 return calcMemSize64WithUint(stack.Back(0), 1) 45 } 46 47 func memoryMStore(stack *Stack) (uint64, bool) { 48 return calcMemSize64WithUint(stack.Back(0), 32) 49 } 50 51 func memoryCreate(stack *Stack) (uint64, bool) { 52 return calcMemSize64(stack.Back(1), stack.Back(2)) 53 } 54 55 func memoryCreate2(stack *Stack) (uint64, bool) { 56 return calcMemSize64(stack.Back(1), stack.Back(2)) 57 } 58 59 func memoryCall(stack *Stack) (uint64, bool) { 60 x, overflow := calcMemSize64(stack.Back(5), stack.Back(6)) 61 if overflow { 62 return 0, true 63 } 64 y, overflow := calcMemSize64(stack.Back(3), stack.Back(4)) 65 if overflow { 66 return 0, true 67 } 68 if x > y { 69 return x, false 70 } 71 return y, false 72 } 73 func memoryDelegateCall(stack *Stack) (uint64, bool) { 74 x, overflow := calcMemSize64(stack.Back(4), stack.Back(5)) 75 if overflow { 76 return 0, true 77 } 78 y, overflow := calcMemSize64(stack.Back(2), stack.Back(3)) 79 if overflow { 80 return 0, true 81 } 82 if x > y { 83 return x, false 84 } 85 return y, false 86 } 87 88 func memoryStaticCall(stack *Stack) (uint64, bool) { 89 x, overflow := calcMemSize64(stack.Back(4), stack.Back(5)) 90 if overflow { 91 return 0, true 92 } 93 y, overflow := calcMemSize64(stack.Back(2), stack.Back(3)) 94 if overflow { 95 return 0, true 96 } 97 if x > y { 98 return x, false 99 } 100 return y, false 101 } 102 103 func memoryReturn(stack *Stack) (uint64, bool) { 104 return calcMemSize64(stack.Back(0), stack.Back(1)) 105 } 106 107 func memoryRevert(stack *Stack) (uint64, bool) { 108 return calcMemSize64(stack.Back(0), stack.Back(1)) 109 } 110 111 func memoryLog(stack *Stack) (uint64, bool) { 112 return calcMemSize64(stack.Back(0), stack.Back(1)) 113 }