core/vm: order opcodes properly (#27113)

This commit is contained in:
Alex Beregszaszi 2023-04-20 08:52:00 +02:00 committed by GitHub
parent f2df2b1981
commit 3f7afc3f57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 18 deletions

View File

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