github.com/MetalBlockchain/subnet-evm@v0.4.9/core/vm/memory_table.go (about)

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