Replies: 1 comment
-
The JIT optimizations are depending more and more on accurate type information and type safety. The unsafe casts that reinterpret data as a different type have potential to confuse JIT optimizations today or in the future. I do not think that this is a reliable pattern. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This is a pattern I've written a few times:
Now, ideally I'd be able to mark
DoSomething
'sT
asallows ref struct
in a lot of cases, but doing that with this pattern would require markingWrapper<T>
as aref struct
, like so:But,
ref struct
s are supposed to be not on the managed heap, which I obviously violate above - my understanding, however, is that the runtime currently only makes assumptions about this when it actually has an interior reference in it - so my question is basically, assuming my understanding is correct to begin with, is that something I can rely on, or not?An adjacent question, to which I assume the answer is probably no, is whether it's legal to define the following type in IL:
If so, then it could be used as an alternative to just having the 1
ref struct
wrapper, with the real solution either being the answer to the first question being "yes, it's fine to rely on that" and/or getting generic bridges.The answer to neither of these questions is clear to me based on the addendum.
/cc @jkotas @tannergooding
Beta Was this translation helpful? Give feedback.
All reactions