[netcore] Implement Object.GetRawData#17295
Conversation
|
I forgot there is intrinsic for it so it never gets executed but I think we can safely use the managed code instead. |
|
Note that these kinds of code only have the same perf if you have an optimizing compiler like llvm or the coreclr jit, it will be slower with the mono JIT or interpreter. So we should keep the intrinsics. |
|
I checked the codegen and in both cases it ends up |
|
Ok, the NULL check comes from here: Lines 9265 to 9268 in 9cc5ea3 |
|
The null check actually gets eliminated when the code gets inlined on the sites so it should work even in non-LLVM case. |
|
|
||
| [Intrinsic] | ||
| internal ref byte GetRawData () => throw new NotImplementedException (); | ||
| internal ref byte GetRawData () => ref Unsafe.As<Mono.RawData>(this).Data; |
There was a problem hiding this comment.
Not in favour of this. We have Intrinsic why to have managed code and dependencies which will never be used?
There was a problem hiding this comment.
The idea was to remove the intrinsic in favour of the managed code. It seems to produce the same codegen.
There was a problem hiding this comment.
I don't think it's worth it, as we already have the instrincis and the managed code is not really improving the readability or performance.
There was a problem hiding this comment.
I beg to differ on the readability but I am fine with closing this as the improvement is questionable.
There was a problem hiding this comment.
Also, we can share the implementation with CoreCLR which uses basically the same code as I used here.
There was a problem hiding this comment.
Is the interpreter keeping up with the intrinsics?
There was a problem hiding this comment.
For this particular case the interpreter has both object.GetRawData (netcore only) and Unsafe.As. Unsafe.As is NOP in interpreter so it's quite cheap overall.
There was a problem hiding this comment.
I don't mean performance, but in recognition.
Having the IL loosens the requirement of keeping up with recognition.
No description provided.