Frontend: patch cmp imm8 for cache

Usually imm8 seem more likely to be a function of the code around them, but
this one seems used by Mono for varying data over execution of same code.
Maybe an ID of some kind.
This commit is contained in:
Pierre-Loup A. Griffais committed 2026-09-14 21:57:54 -07:00
1 parent 56a4f11ddb
commit 3f8f886f65
2 files changed
+28 -3

No files matched your search

+23 -1
View File
@@ -1395,11 +1395,33 @@ bool Decoder::CheckIfCacheable(FEXCore::Core::InternalThreadState& Thread, const
}
void Decoder::DetectDataMasks(uint64_t OpAddress, DecodedBlocks& Block) {
FEXCore::X86Tables::DecodedOperand* LiteralToPatch = nullptr;
// cmp *, imm8 - seen varying in mono jitted code
{
FEXCore::X86Tables::ModRMDecoded ModRM;
ModRM.Hex = DecodeInst->ModRM;
if ((DecodeInst->OPRaw == 0x80 || DecodeInst->OPRaw == 0x83) && ModRM.reg == 7 && LastFieldReadSize == 1) {
for (auto& Src : DecodeInst->Src) {
if (Src.IsLiteral()) {
LiteralToPatch = &Src;
break;
}
}
if (LiteralToPatch && LiteralToPatch->Literal() != 0) {
Block.DataMasks.push_back({OpAddress + LastFieldReadOffset, DataMaskType::MOV, LastFieldReadSize});
LiteralToPatch->Type = X86Tables::DecodedOperand::OpType::LiteralPatchable;
LiteralToPatch->Data.LiteralPatchable.FieldOffset = LastFieldReadOffset;
LiteralToPatch->Data.LiteralPatchable.Width = LastFieldReadSize;
}
}
}
if (LastFieldReadSize < 4) {
return;
}
FEXCore::X86Tables::DecodedOperand* LiteralToPatch = nullptr;
DataMaskType Type = DataMaskType::NONE;
// imm32 or imm64 at the end type instructions