memory_table.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. package vm
  17. func memorySha3(stack *Stack) (uint64, bool) {
  18. return calcMemSize64(stack.Back(0), stack.Back(1))
  19. }
  20. func memoryCallDataCopy(stack *Stack) (uint64, bool) {
  21. return calcMemSize64(stack.Back(0), stack.Back(2))
  22. }
  23. func memoryReturnDataCopy(stack *Stack) (uint64, bool) {
  24. return calcMemSize64(stack.Back(0), stack.Back(2))
  25. }
  26. func memoryCodeCopy(stack *Stack) (uint64, bool) {
  27. return calcMemSize64(stack.Back(0), stack.Back(2))
  28. }
  29. func memoryExtCodeCopy(stack *Stack) (uint64, bool) {
  30. return calcMemSize64(stack.Back(1), stack.Back(3))
  31. }
  32. func memoryMLoad(stack *Stack) (uint64, bool) {
  33. return calcMemSize64WithUint(stack.Back(0), 32)
  34. }
  35. func memoryMStore8(stack *Stack) (uint64, bool) {
  36. return calcMemSize64WithUint(stack.Back(0), 1)
  37. }
  38. func memoryMStore(stack *Stack) (uint64, bool) {
  39. return calcMemSize64WithUint(stack.Back(0), 32)
  40. }
  41. func memoryCreate(stack *Stack) (uint64, bool) {
  42. return calcMemSize64(stack.Back(1), stack.Back(2))
  43. }
  44. func memoryCreate2(stack *Stack) (uint64, bool) {
  45. return calcMemSize64(stack.Back(1), stack.Back(2))
  46. }
  47. func memoryCall(stack *Stack) (uint64, bool) {
  48. x, overflow := calcMemSize64(stack.Back(5), stack.Back(6))
  49. if overflow {
  50. return 0, true
  51. }
  52. y, overflow := calcMemSize64(stack.Back(3), stack.Back(4))
  53. if overflow {
  54. return 0, true
  55. }
  56. if x > y {
  57. return x, false
  58. }
  59. return y, false
  60. }
  61. func memoryDelegateCall(stack *Stack) (uint64, bool) {
  62. x, overflow := calcMemSize64(stack.Back(4), stack.Back(5))
  63. if overflow {
  64. return 0, true
  65. }
  66. y, overflow := calcMemSize64(stack.Back(2), stack.Back(3))
  67. if overflow {
  68. return 0, true
  69. }
  70. if x > y {
  71. return x, false
  72. }
  73. return y, false
  74. }
  75. func memoryStaticCall(stack *Stack) (uint64, bool) {
  76. x, overflow := calcMemSize64(stack.Back(4), stack.Back(5))
  77. if overflow {
  78. return 0, true
  79. }
  80. y, overflow := calcMemSize64(stack.Back(2), stack.Back(3))
  81. if overflow {
  82. return 0, true
  83. }
  84. if x > y {
  85. return x, false
  86. }
  87. return y, false
  88. }
  89. func memoryReturn(stack *Stack) (uint64, bool) {
  90. return calcMemSize64(stack.Back(0), stack.Back(1))
  91. }
  92. func memoryRevert(stack *Stack) (uint64, bool) {
  93. return calcMemSize64(stack.Back(0), stack.Back(1))
  94. }
  95. func memoryLog(stack *Stack) (uint64, bool) {
  96. return calcMemSize64(stack.Back(0), stack.Back(1))
  97. }