2 ms·
One thing that this article doesn’t mention is that compilers could and typically would reuse the memory of all those “secret global variables”. As an easy exa
by Someone 3y ago
One thing that this article doesn’t mention is that compilers could and typically would reuse the memory of all those “secret global variables”.
As an easy example, leaf functions can reuse memory addresses that other leaf functions use for arguments, local variables and return addresses.
It goes much further, though. Reuse can happen as soon as you can prove foo doesn’t call bar directly or indirectly and vice versa.
Software libraries wasn’t really invented yet, other than as stacks of punch cards containing source code or simulated stacks of punch cards, so compilers knew the call graph of the entire program and could optimize this as hard as they could.
Dynamic code loading could, of course, break that, but that wasn’t really a thing, either, in languages such as Fortran and Cobol..
- pklausler 3y agoSEGLDR worked great on the Cray-1.
- Someone 3y agoCray-1 is from 1975. That’s long after the call stack and recursion became well-known, which was at least as early as with ALGOL (Dijkstra’s “Recursive Programming” (https://ics.uci.edu/~jajones/INF102-S18/readings/07_dijkstra.pdf https://ics.uci.edu/~jajones/INF102-S18/readings/07_dijkstra...) is from 1960.) and almost universally supported (even the Intel 4004 had a call stack)
- pklausler 3y agoSEGLDR did dynamic code loading.