-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update mono to support Unsafe.BitCast #103915
Conversation
43247d6
to
433e2bb
Compare
433e2bb
to
99ffc6e
Compare
907e775
to
387ba2d
Compare
I was wanting to update Mono interpreter as well, which looks to be generally handled in |
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. |
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 |
bae04c3
to
4402ee9
Compare
70b64b5
to
9816091
Compare
src/mono/mono/mini/intrinsics.c
Outdated
} else if (tto_type == MONO_TYPE_I4) { | ||
opcode = OP_MOVE; | ||
tto_stack = STACK_I4; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe do I need to explicitly check for MONO_TYPE_I1/I2/U1/U2/U4/U8
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea, maybe that's it. compare to how we translate dup
:
case MONO_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
880a6eb
Compare
contributes to #101495 @fanyang-mono |
9bbca54
to
70cb65f
Compare
c8b6e0a
to
f8d605e
Compare
f8d605e
to
7ae32a6
Compare
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.