instructions_test.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  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. import (
  18. "math/big"
  19. "testing"
  20. "github.com/ethereum/go-ethereum/common"
  21. "github.com/ethereum/go-ethereum/params"
  22. )
  23. type twoOperandTest struct {
  24. x string
  25. y string
  26. expected string
  27. }
  28. func testTwoOperandOp(t *testing.T, tests []twoOperandTest, opFn func(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error)) {
  29. var (
  30. env = NewEVM(Context{}, nil, params.TestChainConfig, Config{})
  31. stack = newstack()
  32. pc = uint64(0)
  33. )
  34. for i, test := range tests {
  35. x := new(big.Int).SetBytes(common.Hex2Bytes(test.x))
  36. shift := new(big.Int).SetBytes(common.Hex2Bytes(test.y))
  37. expected := new(big.Int).SetBytes(common.Hex2Bytes(test.expected))
  38. stack.push(x)
  39. stack.push(shift)
  40. opFn(&pc, env, nil, nil, stack)
  41. actual := stack.pop()
  42. if actual.Cmp(expected) != 0 {
  43. t.Errorf("Testcase %d, expected %v, got %v", i, expected, actual)
  44. }
  45. // Check pool usage
  46. // 1.pool is not allowed to contain anything on the stack
  47. // 2.pool is not allowed to contain the same pointers twice
  48. if env.interpreter.intPool.pool.len() > 0 {
  49. poolvals := make(map[*big.Int]struct{})
  50. poolvals[actual] = struct{}{}
  51. for env.interpreter.intPool.pool.len() > 0 {
  52. key := env.interpreter.intPool.get()
  53. if _, exist := poolvals[key]; exist {
  54. t.Errorf("Testcase %d, pool contains double-entry", i)
  55. }
  56. poolvals[key] = struct{}{}
  57. }
  58. }
  59. }
  60. }
  61. func TestByteOp(t *testing.T) {
  62. var (
  63. env = NewEVM(Context{}, nil, params.TestChainConfig, Config{})
  64. stack = newstack()
  65. )
  66. tests := []struct {
  67. v string
  68. th uint64
  69. expected *big.Int
  70. }{
  71. {"ABCDEF0908070605040302010000000000000000000000000000000000000000", 0, big.NewInt(0xAB)},
  72. {"ABCDEF0908070605040302010000000000000000000000000000000000000000", 1, big.NewInt(0xCD)},
  73. {"00CDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff", 0, big.NewInt(0x00)},
  74. {"00CDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff", 1, big.NewInt(0xCD)},
  75. {"0000000000000000000000000000000000000000000000000000000000102030", 31, big.NewInt(0x30)},
  76. {"0000000000000000000000000000000000000000000000000000000000102030", 30, big.NewInt(0x20)},
  77. {"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 32, big.NewInt(0x0)},
  78. {"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 0xFFFFFFFFFFFFFFFF, big.NewInt(0x0)},
  79. }
  80. pc := uint64(0)
  81. for _, test := range tests {
  82. val := new(big.Int).SetBytes(common.Hex2Bytes(test.v))
  83. th := new(big.Int).SetUint64(test.th)
  84. stack.push(val)
  85. stack.push(th)
  86. opByte(&pc, env, nil, nil, stack)
  87. actual := stack.pop()
  88. if actual.Cmp(test.expected) != 0 {
  89. t.Fatalf("Expected [%v] %v:th byte to be %v, was %v.", test.v, test.th, test.expected, actual)
  90. }
  91. }
  92. }
  93. func TestSHL(t *testing.T) {
  94. // Testcases from https://github.com/ethereum/EIPs/blob/master/EIPS/eip-145.md#shl-shift-left
  95. tests := []twoOperandTest{
  96. {"0000000000000000000000000000000000000000000000000000000000000001", "00", "0000000000000000000000000000000000000000000000000000000000000001"},
  97. {"0000000000000000000000000000000000000000000000000000000000000001", "01", "0000000000000000000000000000000000000000000000000000000000000002"},
  98. {"0000000000000000000000000000000000000000000000000000000000000001", "ff", "8000000000000000000000000000000000000000000000000000000000000000"},
  99. {"0000000000000000000000000000000000000000000000000000000000000001", "0100", "0000000000000000000000000000000000000000000000000000000000000000"},
  100. {"0000000000000000000000000000000000000000000000000000000000000001", "0101", "0000000000000000000000000000000000000000000000000000000000000000"},
  101. {"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "00", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},
  102. {"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "01", "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe"},
  103. {"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "ff", "8000000000000000000000000000000000000000000000000000000000000000"},
  104. {"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0100", "0000000000000000000000000000000000000000000000000000000000000000"},
  105. {"0000000000000000000000000000000000000000000000000000000000000000", "01", "0000000000000000000000000000000000000000000000000000000000000000"},
  106. {"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "01", "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe"},
  107. }
  108. testTwoOperandOp(t, tests, opSHL)
  109. }
  110. func TestSHR(t *testing.T) {
  111. // Testcases from https://github.com/ethereum/EIPs/blob/master/EIPS/eip-145.md#shr-logical-shift-right
  112. tests := []twoOperandTest{
  113. {"0000000000000000000000000000000000000000000000000000000000000001", "00", "0000000000000000000000000000000000000000000000000000000000000001"},
  114. {"0000000000000000000000000000000000000000000000000000000000000001", "01", "0000000000000000000000000000000000000000000000000000000000000000"},
  115. {"8000000000000000000000000000000000000000000000000000000000000000", "01", "4000000000000000000000000000000000000000000000000000000000000000"},
  116. {"8000000000000000000000000000000000000000000000000000000000000000", "ff", "0000000000000000000000000000000000000000000000000000000000000001"},
  117. {"8000000000000000000000000000000000000000000000000000000000000000", "0100", "0000000000000000000000000000000000000000000000000000000000000000"},
  118. {"8000000000000000000000000000000000000000000000000000000000000000", "0101", "0000000000000000000000000000000000000000000000000000000000000000"},
  119. {"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "00", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},
  120. {"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "01", "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},
  121. {"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "ff", "0000000000000000000000000000000000000000000000000000000000000001"},
  122. {"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0100", "0000000000000000000000000000000000000000000000000000000000000000"},
  123. {"0000000000000000000000000000000000000000000000000000000000000000", "01", "0000000000000000000000000000000000000000000000000000000000000000"},
  124. }
  125. testTwoOperandOp(t, tests, opSHR)
  126. }
  127. func TestSAR(t *testing.T) {
  128. // Testcases from https://github.com/ethereum/EIPs/blob/master/EIPS/eip-145.md#sar-arithmetic-shift-right
  129. tests := []twoOperandTest{
  130. {"0000000000000000000000000000000000000000000000000000000000000001", "00", "0000000000000000000000000000000000000000000000000000000000000001"},
  131. {"0000000000000000000000000000000000000000000000000000000000000001", "01", "0000000000000000000000000000000000000000000000000000000000000000"},
  132. {"8000000000000000000000000000000000000000000000000000000000000000", "01", "c000000000000000000000000000000000000000000000000000000000000000"},
  133. {"8000000000000000000000000000000000000000000000000000000000000000", "ff", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},
  134. {"8000000000000000000000000000000000000000000000000000000000000000", "0100", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},
  135. {"8000000000000000000000000000000000000000000000000000000000000000", "0101", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},
  136. {"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "00", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},
  137. {"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "01", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},
  138. {"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "ff", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},
  139. {"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0100", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},
  140. {"0000000000000000000000000000000000000000000000000000000000000000", "01", "0000000000000000000000000000000000000000000000000000000000000000"},
  141. {"4000000000000000000000000000000000000000000000000000000000000000", "fe", "0000000000000000000000000000000000000000000000000000000000000001"},
  142. {"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "f8", "000000000000000000000000000000000000000000000000000000000000007f"},
  143. {"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "fe", "0000000000000000000000000000000000000000000000000000000000000001"},
  144. {"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "ff", "0000000000000000000000000000000000000000000000000000000000000000"},
  145. {"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0100", "0000000000000000000000000000000000000000000000000000000000000000"},
  146. }
  147. testTwoOperandOp(t, tests, opSAR)
  148. }
  149. func TestSGT(t *testing.T) {
  150. tests := []twoOperandTest{
  151. {"0000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000000"},
  152. {"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000000"},
  153. {"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000000"},
  154. {"0000000000000000000000000000000000000000000000000000000000000001", "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000001"},
  155. {"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000000"},
  156. {"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000001"},
  157. {"0000000000000000000000000000000000000000000000000000000000000001", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000000"},
  158. {"8000000000000000000000000000000000000000000000000000000000000001", "8000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000000"},
  159. {"8000000000000000000000000000000000000000000000000000000000000001", "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000001"},
  160. {"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "8000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000000"},
  161. {"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb", "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd", "0000000000000000000000000000000000000000000000000000000000000001"},
  162. {"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd", "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb", "0000000000000000000000000000000000000000000000000000000000000000"},
  163. }
  164. testTwoOperandOp(t, tests, opSgt)
  165. }
  166. func TestSLT(t *testing.T) {
  167. tests := []twoOperandTest{
  168. {"0000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000000"},
  169. {"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000000"},
  170. {"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000000"},
  171. {"0000000000000000000000000000000000000000000000000000000000000001", "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000000"},
  172. {"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000001"},
  173. {"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000000"},
  174. {"0000000000000000000000000000000000000000000000000000000000000001", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000001"},
  175. {"8000000000000000000000000000000000000000000000000000000000000001", "8000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000000"},
  176. {"8000000000000000000000000000000000000000000000000000000000000001", "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000000"},
  177. {"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "8000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000001"},
  178. {"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb", "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd", "0000000000000000000000000000000000000000000000000000000000000000"},
  179. {"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd", "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb", "0000000000000000000000000000000000000000000000000000000000000001"},
  180. }
  181. testTwoOperandOp(t, tests, opSlt)
  182. }
  183. func opBenchmark(bench *testing.B, op func(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error), args ...string) {
  184. var (
  185. env = NewEVM(Context{}, nil, params.TestChainConfig, Config{})
  186. stack = newstack()
  187. )
  188. // convert args
  189. byteArgs := make([][]byte, len(args))
  190. for i, arg := range args {
  191. byteArgs[i] = common.Hex2Bytes(arg)
  192. }
  193. pc := uint64(0)
  194. bench.ResetTimer()
  195. for i := 0; i < bench.N; i++ {
  196. for _, arg := range byteArgs {
  197. a := new(big.Int).SetBytes(arg)
  198. stack.push(a)
  199. }
  200. op(&pc, env, nil, nil, stack)
  201. stack.pop()
  202. }
  203. }
  204. func BenchmarkOpAdd64(b *testing.B) {
  205. x := "ffffffff"
  206. y := "fd37f3e2bba2c4f"
  207. opBenchmark(b, opAdd, x, y)
  208. }
  209. func BenchmarkOpAdd128(b *testing.B) {
  210. x := "ffffffffffffffff"
  211. y := "f5470b43c6549b016288e9a65629687"
  212. opBenchmark(b, opAdd, x, y)
  213. }
  214. func BenchmarkOpAdd256(b *testing.B) {
  215. x := "0802431afcbce1fc194c9eaa417b2fb67dc75a95db0bc7ec6b1c8af11df6a1da9"
  216. y := "a1f5aac137876480252e5dcac62c354ec0d42b76b0642b6181ed099849ea1d57"
  217. opBenchmark(b, opAdd, x, y)
  218. }
  219. func BenchmarkOpSub64(b *testing.B) {
  220. x := "51022b6317003a9d"
  221. y := "a20456c62e00753a"
  222. opBenchmark(b, opSub, x, y)
  223. }
  224. func BenchmarkOpSub128(b *testing.B) {
  225. x := "4dde30faaacdc14d00327aac314e915d"
  226. y := "9bbc61f5559b829a0064f558629d22ba"
  227. opBenchmark(b, opSub, x, y)
  228. }
  229. func BenchmarkOpSub256(b *testing.B) {
  230. x := "4bfcd8bb2ac462735b48a17580690283980aa2d679f091c64364594df113ea37"
  231. y := "97f9b1765588c4e6b69142eb00d20507301545acf3e1238c86c8b29be227d46e"
  232. opBenchmark(b, opSub, x, y)
  233. }
  234. func BenchmarkOpMul(b *testing.B) {
  235. x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  236. y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  237. opBenchmark(b, opMul, x, y)
  238. }
  239. func BenchmarkOpDiv256(b *testing.B) {
  240. x := "ff3f9014f20db29ae04af2c2d265de17"
  241. y := "fe7fb0d1f59dfe9492ffbf73683fd1e870eec79504c60144cc7f5fc2bad1e611"
  242. opBenchmark(b, opDiv, x, y)
  243. }
  244. func BenchmarkOpDiv128(b *testing.B) {
  245. x := "fdedc7f10142ff97"
  246. y := "fbdfda0e2ce356173d1993d5f70a2b11"
  247. opBenchmark(b, opDiv, x, y)
  248. }
  249. func BenchmarkOpDiv64(b *testing.B) {
  250. x := "fcb34eb3"
  251. y := "f97180878e839129"
  252. opBenchmark(b, opDiv, x, y)
  253. }
  254. func BenchmarkOpSdiv(b *testing.B) {
  255. x := "ff3f9014f20db29ae04af2c2d265de17"
  256. y := "fe7fb0d1f59dfe9492ffbf73683fd1e870eec79504c60144cc7f5fc2bad1e611"
  257. opBenchmark(b, opSdiv, x, y)
  258. }
  259. func BenchmarkOpMod(b *testing.B) {
  260. x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  261. y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  262. opBenchmark(b, opMod, x, y)
  263. }
  264. func BenchmarkOpSmod(b *testing.B) {
  265. x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  266. y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  267. opBenchmark(b, opSmod, x, y)
  268. }
  269. func BenchmarkOpExp(b *testing.B) {
  270. x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  271. y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  272. opBenchmark(b, opExp, x, y)
  273. }
  274. func BenchmarkOpSignExtend(b *testing.B) {
  275. x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  276. y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  277. opBenchmark(b, opSignExtend, x, y)
  278. }
  279. func BenchmarkOpLt(b *testing.B) {
  280. x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  281. y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  282. opBenchmark(b, opLt, x, y)
  283. }
  284. func BenchmarkOpGt(b *testing.B) {
  285. x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  286. y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  287. opBenchmark(b, opGt, x, y)
  288. }
  289. func BenchmarkOpSlt(b *testing.B) {
  290. x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  291. y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  292. opBenchmark(b, opSlt, x, y)
  293. }
  294. func BenchmarkOpSgt(b *testing.B) {
  295. x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  296. y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  297. opBenchmark(b, opSgt, x, y)
  298. }
  299. func BenchmarkOpEq(b *testing.B) {
  300. x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  301. y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  302. opBenchmark(b, opEq, x, y)
  303. }
  304. func BenchmarkOpEq2(b *testing.B) {
  305. x := "FBCDEF090807060504030201ffffffffFBCDEF090807060504030201ffffffff"
  306. y := "FBCDEF090807060504030201ffffffffFBCDEF090807060504030201fffffffe"
  307. opBenchmark(b, opEq, x, y)
  308. }
  309. func BenchmarkOpAnd(b *testing.B) {
  310. x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  311. y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  312. opBenchmark(b, opAnd, x, y)
  313. }
  314. func BenchmarkOpOr(b *testing.B) {
  315. x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  316. y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  317. opBenchmark(b, opOr, x, y)
  318. }
  319. func BenchmarkOpXor(b *testing.B) {
  320. x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  321. y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  322. opBenchmark(b, opXor, x, y)
  323. }
  324. func BenchmarkOpByte(b *testing.B) {
  325. x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  326. y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  327. opBenchmark(b, opByte, x, y)
  328. }
  329. func BenchmarkOpAddmod(b *testing.B) {
  330. x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  331. y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  332. z := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  333. opBenchmark(b, opAddmod, x, y, z)
  334. }
  335. func BenchmarkOpMulmod(b *testing.B) {
  336. x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  337. y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  338. z := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
  339. opBenchmark(b, opMulmod, x, y, z)
  340. }
  341. func BenchmarkOpSHL(b *testing.B) {
  342. x := "FBCDEF090807060504030201ffffffffFBCDEF090807060504030201ffffffff"
  343. y := "ff"
  344. opBenchmark(b, opSHL, x, y)
  345. }
  346. func BenchmarkOpSHR(b *testing.B) {
  347. x := "FBCDEF090807060504030201ffffffffFBCDEF090807060504030201ffffffff"
  348. y := "ff"
  349. opBenchmark(b, opSHR, x, y)
  350. }
  351. func BenchmarkOpSAR(b *testing.B) {
  352. x := "FBCDEF090807060504030201ffffffffFBCDEF090807060504030201ffffffff"
  353. y := "ff"
  354. opBenchmark(b, opSAR, x, y)
  355. }
  356. func BenchmarkOpIsZero(b *testing.B) {
  357. x := "FBCDEF090807060504030201ffffffffFBCDEF090807060504030201ffffffff"
  358. opBenchmark(b, opIszero, x)
  359. }