You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
No inline of method on value type injected to generic method: Fail Reason: noinline per IL/cached result #35791
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIuntriagedNew issue has not been triaged by the area owner
Hmm I guess the following issue touches upon it #10048, which means I should just give up and this is probably a duplicate. Unfortunate. This would reduce code, not increase it. The other fail reason probably was more relevant:
Ah is it m_compare(x, y) that's not getting inlined rather than comparer.Compare(v, value) ?
@benaadams might be 😄 From #10048 I thought it might be the regular method it self. Perhaps I can change code so easier to distinguish the two. Or other suggestions?
@benaadams I definitely do 😉 BUT that is a pointer and cannot be inlined itself, what I want is the ability to do both. Using a value type "functor" fulfilling a given interface as the base for all code paths 😃 That is so I could write something a ala:
publicstructSingleLess:ILess<float>{publicboolLess(floatx,floaty)=>x<y;}publicstructFunctionPointerLess<T>:ILess<T>{FunctionPointerLess(/* function pointer */ptr){...}publicboolLess(Tx,Ty)=>ptr(x,y);}// Etc.
When T is a reference type there are still issues around the canonical representation and that Less then still can't be inlined then, but with hackery/unsafe code, one can perhaps define this as:
publicstructObjectFunctionPointerLess:ILess<object>{ObjectFunctionPointerLess(/* function pointer */ptr){...}publicboolLess(objectx,objecty)=>ptr(x,y);}
so in reality I want generic, inlineable functors, but that conflicts with the canonical representation of reference type code. Wish one could opt out of that for some scenarios.
If you change it to an interface call rather than a delegate its happy enough to inline it
@benaadams if delegates would implement an interface and such calls were as fast as delegate calls then that would have been a path too. Many paths explored I have 😁
No of course not :) But a method containing a calli should now be inlined. bing uses calli and I think I remember they called out that methods with that could now be inlined which was a benefit for them. Unfortunately, what I am doing should work well on older runtimes so I can't use calli and hence I have to resort to code duplication.
I am closing this PR since it is a duplicate of #10048
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIuntriagedNew issue has not been triaged by the area owner
Activity
nietras commentedon May 4, 2020
Hmm I guess the following issue touches upon it #10048, which means I should just give up and this is probably a duplicate. Unfortunate. This would reduce code, not increase it. The other fail reason probably was more relevant:
:)
benaadams commentedon May 4, 2020
Why is it a delegate invoke? Looks like a regular method call?
benaadams commentedon May 4, 2020
Ah is it
m_compare(x, y)that's not getting inlined rather thancomparer.Compare(v, value)?nietras commentedon May 4, 2020
@benaadams might be 😄 From #10048 I thought it might be the regular method it self. Perhaps I can change code so easier to distinguish the two. Or other suggestions?
nietras commentedon May 4, 2020
@benaadams actually the fail reason is pretty clear:
if I understand it correctly.
benaadams commentedon May 4, 2020
Ah, so calling a delegate blocks the inlining of the method that calls it. Seems a bit weird as it isn't a very exciting method
If you change it to an interface call rather than a delegate its happy enough to inline it
Even though that's a slightly more complex call site
nietras commentedon May 4, 2020
@benaadams indeed 😄 I probably have to revert to
calli🙄 In general I could wish for better support around this form of inlineable "functor" pattern.benaadams commentedon May 4, 2020
Sounds like you want Function Pointers for C# 😉 https://github.com/dotnet/csharplang/blob/master/proposals/function-pointers.md
nietras commentedon May 4, 2020
@benaadams I definitely do 😉 BUT that is a pointer and cannot be inlined itself, what I want is the ability to do both. Using a value type "functor" fulfilling a given interface as the base for all code paths 😃 That is so I could write something a ala:
When
Tis a reference type there are still issues around the canonical representation and thatLessthen still can't be inlined then, but with hackery/unsafe code, one can perhaps define this as:so in reality I want generic, inlineable functors, but that conflicts with the canonical representation of reference type code. Wish one could opt out of that for some scenarios.
Ideas are welcome! 😃
nietras commentedon May 4, 2020
I've probably been using the STL too much but it's basically just that. I'd like STL-like code in C# for some things. :)
nietras commentedon May 4, 2020
@benaadams if delegates would implement an interface and such calls were as fast as delegate calls then that would have been a path too. Many paths explored I have 😁
hypeartist commentedon May 5, 2020
But
callialso isn't getting inlined 🙄nietras commentedon May 5, 2020
No of course not :) But a method containing a
callishould now be inlined. bing usescalliand I think I remember they called out that methods with that could now be inlined which was a benefit for them. Unfortunately, what I am doing should work well on older runtimes so I can't usecalliand hence I have to resort to code duplication.I am closing this PR since it is a duplicate of #10048