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