Most instructions have the same stage- and commit-encoding, meaning that they don't depend on anything specific to their encoded location (such as having a RIP-relative operand). For such instructions, I think we could benefit from having a simple "cache" for these instruction encodings, so that we don't waste time re-encoding them. There are some options available to us.
One option is to re-use operand memory for this purpose, as there are almost certainly unused operands. This enables re-use of existing space.
Another option is to use Instruction::transient_meta. This would limit cached encodings to 8 bytes, but this is not too onerous.
Another option is to add in a whole new char[arch::Instruction::MAX_INSTRUCTION_LENGTH] array into the instruction. arch::Instructions are massive anyway so, in the grand scheme of things it's not making things much worse--especially if sizeof(NativeInstruction) is not a multiple of the cache line size, so there's that.
Anyway, this is a nice, simple-to-do thing that would require a bit of poking about in the instruction encoding to flag "uncachable" instructions as stage-encode time, then re-use cached encodings at commit-encode time.
Most instructions have the same stage- and commit-encoding, meaning that they don't depend on anything specific to their encoded location (such as having a
RIP
-relative operand). For such instructions, I think we could benefit from having a simple "cache" for these instruction encodings, so that we don't waste time re-encoding them. There are some options available to us.One option is to re-use operand memory for this purpose, as there are almost certainly unused operands. This enables re-use of existing space.
Another option is to use
Instruction::transient_meta
. This would limit cached encodings to 8 bytes, but this is not too onerous.Another option is to add in a whole new
char[arch::Instruction::MAX_INSTRUCTION_LENGTH]
array into the instruction.arch::Instruction
s are massive anyway so, in the grand scheme of things it's not making things much worse--especially ifsizeof(NativeInstruction)
is not a multiple of the cache line size, so there's that.Anyway, this is a nice, simple-to-do thing that would require a bit of poking about in the instruction encoding to flag "uncachable" instructions as stage-encode time, then re-use cached encodings at commit-encode time.