Uh oh!
There was an error while loading. Please reload this page.
Update mono to support Unsafe.BitCast - #103915
Conversation
43247d6 to
433e2bbCompare907e775 to
387ba2dCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
tannergooding
commented
Jun 25, 2024
I was wanting to update Mono interpreter as well, which looks to be generally handled in |
lambdageek
commented
Jun 25, 2024
In general with interp intrinsics the goals are:
So for something like On the other hand BitCast (if it's hot in startup profiling) which expands to a bunch of calls but could be replaced by a single move or load is probably more worthwhile. |
tannergooding
commented
Jun 25, 2024
I would expect the interpreter to see the same general benefits as RyuJIT here as well, which is that it improves the overall throughput and code quality as there is no need to execute the inliner for known hot methods that optimize down to functionally single opcodes. That is, most of the APIs on I don't think it's critical to handle them all immediately, per say, but I think that long term we should push to ensuring that Mono and RyuJIT try to consistently handle APIs intrinsically to ensure that we don't end up with cases where using an API improves RyuJIT but regresses Mono. |
@lambdageek, could you help diagnose the crash here? I think it's caused by the I had initially used Some other paths appear to use |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| } else if (tto_type == MONO_TYPE_I4) { | ||
| opcode = OP_MOVE; | ||
| tto_stack = STACK_I4; | ||
| } |
There was a problem hiding this comment.
There seems to be a failure around this path for small types (byte->byte, or ushort->short, etc).
Is there some Mono specific handling that's needed here @lambdageek?
There was a problem hiding this comment.
Or maybe do I need to explicitly check for MONO_TYPE_I1/I2/U1/U2/U4/U8?
There was a problem hiding this comment.
I don't know, I'm sorry. Though mini_type_to_stack_type seems to suggest that your latest idea is on the right track. From the failures it looks like maybe you need to set ins->klass too - it looks like there's some kind of sign extension happening when zero extension is expected.
There was a problem hiding this comment.
yea, maybe that's it. compare to how we translate dup:
caseMONO_CEE_DUP: {
MonoInst*temp, *store;
sp--;
ins=*sp;
klass=ins->klass;
temp=mono_compile_create_var (cfg, type_from_stack_type (ins), OP_LOCAL);
EMIT_NEW_TEMPSTORE (cfg, store, temp->inst_c0, ins);
EMIT_NEW_TEMPLOAD (cfg, ins, temp->inst_c0);
ins->klass=klass;
*sp++=ins;
EMIT_NEW_TEMPLOAD (cfg, ins, temp->inst_c0);
ins->klass=klass;
*sp++=ins;
inline_costs+=2;
break;
}558db9f to
880a6ebComparekasperk81
commented
Jun 27, 2024
contributes to #101495@fanyang-mono |
9bbca54 to
70cb65fComparec8b6e0a to
f8d605eComparetannergooding
commented
Jun 28, 2024
As much as I would like to finish this and get it in, even the simple primitive to primitive bitcasts that are mapping to existing Mono support are not working/seemingly causing CI crashes and I don't have the time/availability to continue debugging it. Anyone should feel free to pick this up if they have more context or time. |
No description provided.