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
So the last piece of the puzzle for my C based closures is generating a thunk that inserts a pointer to the data for the closure in the argument list. I'm thinking I'll compile the thunk function once I have the address of the data (represented by 0x12345678 here):
typedef struct cl {
int a, b, c;
} *cl;
int c(const cl l, int d, int e) {
l->a = d;
return l->a + l->b + l->c + e;
}
int thunk(int d, int e) {
return c((const cl)0x12345678, d, e);
}
I know that MIR will generate a thunk for all functions and I would like to avoid doubling up the thunks. My question is, will thunk be optimized away somehow or is there a better approach, such as some kind of inlining trickery? The position of the data link l in c is unimportant of course.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
So the last piece of the puzzle for my C based closures is generating a thunk that inserts a pointer to the data for the closure in the argument list. I'm thinking I'll compile the
thunk
function once I have the address of the data (represented by0x12345678
here):I know that MIR will generate a thunk for all functions and I would like to avoid doubling up the thunks. My question is, will
thunk
be optimized away somehow or is there a better approach, such as some kind of inlining trickery? The position of the data linkl
inc
is unimportant of course.Beta Was this translation helpful? Give feedback.
All reactions