February 21st, 2007, 01:22 AM
February 23rd, 2007, 07:20 PM
More on this particular FORTRAN compiler...
I've been looking at the OBJ's it emits and another trick they used has become apparent.
It emits small blobs of code (LEDATA records) and it defers resolution of certain things (ex. forward jump offsets and stack depth allocation for autovars) until after an LEDATA record has been written out.
Once it knows the final values of those things, it emits other small 1 and 2 byte long LEDATA's that essentially "backpatch" and override some of the prior contents of the earlier LEDATA records.
Fortran allows for implied declaration of variables, so a Fortran compiler won't know up front the size of local vars until its hit the last line in a function. So they emit the code for the body of the function before knowing what the final amount they needed to sub from SP was and backpatch it later on.
This backpatching scheme clearly helped the compiler work better on low memory machines since it didn't need to keep all the code it was emitting around, just info about back patches.
Essentially, it pushes some of what would normally be considered code generation off onto the linker for resolution.
In the versions of this compiler that came out a few of years later, most (not all though) of this backpatch dance seems to have been eliminated...and its memory requirements on the packaging went up dramatically as well
Last edited by Purple Avenger; February 23rd, 2007 at 07:23 PM.