runtime
runtime copied to clipboard
[RyuJIT] Opcode's offset calculation during importation
In Compiler::impImportBlockCode method if opcode is CEE_PREFIX1 firstly we change codeAddr and then calculate opcodeOffs:
case CEE_PREFIX1:
opcode = (OPCODE)(getU1LittleEndian(codeAddr) + 256);
codeAddr += sizeof(__int8);
opcodeOffs = (IL_OFFSET)(codeAddr - info.compCode);
goto DECODE_OPCODE;
The same situation for PREFIX label:
PREFIX:
opcode = (OPCODE)getU1LittleEndian(codeAddr);
codeAddr += sizeof(__int8);
opcodeOffs = (IL_OFFSET)(codeAddr - info.compCode);
goto DECODE_OPCODE;
In this case for following IL code:
constrained. var<u1>
callvirt instance int32 [System.Private.CoreLib]System.Object::GetHashCode()
opcodeOffs for callvirt points to the 2nd byte of the instruction, because after processing constrained. we goto PREFIX label.
I think we should firstly calculate offset and then change codeAddr (in this case offset points to the 1st byte of instruction as expected). Is it correct?
cc @Dmitri-Botcharnikov @ayuckhulk
@dotnet/jit-contrib
Fixed in dotnet/coreclr#13685