runtime icon indicating copy to clipboard operation
runtime copied to clipboard

[RyuJIT] Opcode's offset calculation during importation

Open kbaladurin opened this issue 9 years ago • 3 comments

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?

kbaladurin avatar Jul 06 '17 12:07 kbaladurin

cc @Dmitri-Botcharnikov @ayuckhulk

kbaladurin avatar Jul 06 '17 13:07 kbaladurin

@dotnet/jit-contrib

RussKeldorph avatar Jul 12 '17 20:07 RussKeldorph

Fixed in dotnet/coreclr#13685

kbaladurin avatar Sep 01 '17 05:09 kbaladurin