Am 12.12.2023 um 17:51 schrieb Marco van de Voort via fpc-pascal:
Op 12-12-2023 om 17:48 schreef Anthony Walter via fpc-pascal:
Do any of the compiler devs know if Pascal programs for the x86
instruction set are using ENTER and its second argument to the best
possible effect? I am curious.
No, and if they do, they don't do in the way they are meant to. These
are very old instructions and the intended use has a nesting limit (of
32 levels iiirc). Because of that limit, modern compilers don't use
them.
32 static levels is MUCH, IMO.
I have an old compiler here (New Stanford Pascal, originating from
Pascal P4), which has only 9 static levels.
Dynamic nesting is unlimited, of course.
This was never a problem for me; every seperately compiled module starts
again at level 2.
The only program which comes close to the 9 level limit is the 26.000
lines compiler phase 1.
My compiler copies and restores the addresses of all 9 stack frame
levels, but only when passing procedure and function parameters;
otherwise the addresses of the stack frames are located at certain (well
known) places which can always be found,
and only individual stack frame addresses have to be set and restored
when entering or leaving a function.
I had the idea to extend the limit from 9 to 20, but there was no hard
requirement so far, so I left it at 9.
C, for example, and other "modern" languages, have a static limit of 1.
Kind regards
Bernd
Some forms of enter and leave are use as peephole optimizations.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal