Øyvind Harboe wrote:
My worry is that the trampoline is only built once, but modified multiple times. How does the CRIS target know that the saved static chain register does not get overwritten by recursion?
This sounds wrong to me
I believe e.g. Windows XP service pack 2 has this protection enabled.
There is no problem in building trampolines in this environment as far as I know.
Zack says in his post that the Ada and Pascal nested functions do not use trampolines.
He said nothing of the kind. Please reread. He said that for many uses, they were not used, but when 'Access is taken in Ada (or in fact for all task types, which use this mechanism internally) or when a procedure is passed as a parameter in Pascal, then trampolines are most certainly used.
I was surprised to see trampolines in GCC code. To me they are something inbetween traditional C and C++ objects.
Not sure what this means
The main advantage I see of having nested functions & trampolines in C is that they will see more testing. I think it would be really tough for, say Ada, to rely on features in the backend that are not used at all by C/C++.
It has worked fine for 12 years, and seems to continue to work fine!