runtime icon indicating copy to clipboard operation
runtime copied to clipboard

ARM32 switch jump table generation [Legacy Jit + CoreRT]

Open BredPet opened this issue 9 years ago • 3 comments

genTableSwitch generates wrong Switch jump table on arm32 in Legacy Jit when we compile something with CoreRT. If we have more than 3 or 4 cases, it generates jump table, but values of table are like this:

DCD 0xB26910B9
DCD 0xB2691113
DCD 0xB2691175
DCD 0xB269104D

I think it's due to while we emit table by emitBBTableDataGenBeg, we pass absolute addressing mode there. But when we compile with CoreRT, exe has PIC flag. Or maybe allocMem from CoreRT generates 'wrong' for CoreCLR addresses of blocks. I don't know exactly. I think maybe better emit relative jump table, as it in RyuJIT for other platfroms. Can anyone suggest anything about this?

BredPet avatar Aug 03 '17 09:08 BredPet

@sergign60 @MichalStrehovsky @jkotas please take a look

BredPet avatar Aug 03 '17 09:08 BredPet

cc @sandreenko

For legacy JIT, it maybe easiest to disable the switch table generation for CoreRT ABI on Unix in CodeGen::genTableSwitch and always use the (slower) inlined cmp+conditiona jump sequence. This should get you unblocked in CoreRT bring up.

Then focus on fixing this for the RyuJIT backend.

I think maybe better emit relative jump table

Is it what C/C++ compilers do for similar code on Unix ARM?

jkotas avatar Aug 03 '17 11:08 jkotas

In the end, I did so already ;-) but without taking into account the CoreRT ABI. Ok, I'll add ABI and Unix condition and create PR later. // clang uses tbb and relative addresses on Unix arm32 in such cases Thanks

BredPet avatar Aug 03 '17 11:08 BredPet