core/vm: order opcodes properly (#27113)

pull/26894/head
Alex Beregszaszi 2 years ago committed by GitHub
parent f2df2b1981
commit 3f7afc3f57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 38
      core/vm/opcodes.go

@ -204,6 +204,12 @@ const (
LOG4
)
// 0xb0 range.
const (
TLOAD OpCode = 0xb3
TSTORE OpCode = 0xb4
)
// 0xf0 range - closures.
const (
CREATE OpCode = 0xf0
@ -219,12 +225,6 @@ const (
SELFDESTRUCT OpCode = 0xff
)
// 0xb0 range.
const (
TLOAD OpCode = 0xb3
TSTORE OpCode = 0xb4
)
// Since the opcodes aren't all in order we can't use a regular slice.
var opCodeToString = map[OpCode]string{
// 0x0 range - arithmetic ops.
@ -290,9 +290,7 @@ var opCodeToString = map[OpCode]string{
BASEFEE: "BASEFEE",
// 0x50 range - 'storage' and execution.
POP: "POP",
//DUP: "DUP",
//SWAP: "SWAP",
POP: "POP",
MLOAD: "MLOAD",
MSTORE: "MSTORE",
MSTORE8: "MSTORE8",
@ -306,7 +304,7 @@ var opCodeToString = map[OpCode]string{
JUMPDEST: "JUMPDEST",
PUSH0: "PUSH0",
// 0x60 range - push.
// 0x60 range - pushes.
PUSH1: "PUSH1",
PUSH2: "PUSH2",
PUSH3: "PUSH3",
@ -340,6 +338,7 @@ var opCodeToString = map[OpCode]string{
PUSH31: "PUSH31",
PUSH32: "PUSH32",
// 0x80 - dups.
DUP1: "DUP1",
DUP2: "DUP2",
DUP3: "DUP3",
@ -357,6 +356,7 @@ var opCodeToString = map[OpCode]string{
DUP15: "DUP15",
DUP16: "DUP16",
// 0x90 - swaps.
SWAP1: "SWAP1",
SWAP2: "SWAP2",
SWAP3: "SWAP3",
@ -373,17 +373,19 @@ var opCodeToString = map[OpCode]string{
SWAP14: "SWAP14",
SWAP15: "SWAP15",
SWAP16: "SWAP16",
LOG0: "LOG0",
LOG1: "LOG1",
LOG2: "LOG2",
LOG3: "LOG3",
LOG4: "LOG4",
// 0xa0 range - logging ops.
LOG0: "LOG0",
LOG1: "LOG1",
LOG2: "LOG2",
LOG3: "LOG3",
LOG4: "LOG4",
// 0xb0 range.
TLOAD: "TLOAD",
TSTORE: "TSTORE",
// 0xf0 range.
// 0xf0 range - closures.
CREATE: "CREATE",
CALL: "CALL",
RETURN: "RETURN",
@ -473,8 +475,6 @@ var stringToOp = map[string]OpCode{
"GAS": GAS,
"JUMPDEST": JUMPDEST,
"PUSH0": PUSH0,
"TLOAD": TLOAD,
"TSTORE": TSTORE,
"PUSH1": PUSH1,
"PUSH2": PUSH2,
"PUSH3": PUSH3,
@ -544,6 +544,8 @@ var stringToOp = map[string]OpCode{
"LOG2": LOG2,
"LOG3": LOG3,
"LOG4": LOG4,
"TLOAD": TLOAD,
"TSTORE": TSTORE,
"CREATE": CREATE,
"CREATE2": CREATE2,
"CALL": CALL,

Loading…
Cancel
Save