Auto-adapted calling conventions for avoiding stack overhead #61249
Unanswered
WhiteBlackGoose
asked this question in
Ideas
Replies: 1 comment
-
I think it can confuse a lot for diagnostic tools. And also, when modifying calling convention can benefit, it should likely be more beneficial to inline the callee. |
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
-
Hello. Playing with codegen and structs I noticed that one of the overheads a call introduces is working with the arguments. Consider a case:
(sharplab)
In the caller, it first populates ram with the struct's fields, then packs that 8-byte piece of memory into
rcx
.On the callee side, it packs
rcx
into ram back, and then assigns its 4-byte piece toeax
(and then reads from ram again toadd
).Instead, it would be nice to have the caller and the callee to "agree" that the arguments are passed in
eax
andecx
, then it would look much simplier.Caller:
Callee:
That's not an existing calling convention. So the idea here is to introduce special callconvs for some functions, to speed them up a bit. I'm not a RyuJIT expert, but I'd assume that it would be like this: we make a special bit of metadata for each function, where we store if the function uses a custom callconv. If it does, there will be a reference to table, like this:
It will be quite light-weight as there are not too many combinations (because most of combinations can be simplified to just one with a slight argument reorder or other minor adjustments).
Of course, it will be disabled for native export scenarios (and other where our functions are exposed outside of the current jit session).
What do you think?
Beta Was this translation helpful? Give feedback.
All reactions