4 ms·
Some RISC architectures didn't have dedicated instructions/registers for the call stack either. That, in itself, isn't really an issue. The real issue is that
by skissane 6y ago
Some RISC architectures didn't have dedicated instructions/registers for the call stack either. That, in itself, isn't really an issue.
The real issue is that the original calling convention chosen by OS/360 / MVS / z/OS didn't feature a stack. It was based on the assumption that code would not be recursive/reentrant. Each routine would have a static memory block to save registers in. That was a software design issue (OS and compilers), not a CPU design issue. However, a lot of application code was written in COBOL and FORTRAN, which in their original versions didn't support recursion/reentrancy at all, and a top-down coding style discouraged recursion/reentrancy anyway, so this was less of an issue in practice than it might have been. And lots of other vendors in the 1960s (such as DEC and HP) made the same design decision.
Over time, the demand to support recursive/reentrant code became stronger. The first approach was to have each routine use GETMAIN (equivalent of malloc) to dynamically allocate a save area. This succeeded in providing recursion/reenterancy, but cost a lot in performance. Later they introduced the equivalent of a stack, called a "dynamic save area" (DSA) – rather than having each routine's prologue call GETMAIN to allocate a register save area, they'd just use a slice of that dynamic save area allocated once at the beginning of the program. Newer versions of z/OS introduce a new calling convention XPLINK, which is even closer to what other platforms do – it is more efficient, the stack grows in the normal way (top-down not bottom-up), and overflow is detected using a guard page instead of a manual check in every function prologue.
However, due to the demands of backward compatibility, z/OS has to support all three calling conventions – the original one without a stack, the legacy DSA calling convention, and the new XPLINK stack calling convention – complete with thunking macros to generate code so code using one can call code using the other. At least if you stick to C, the compiler handles all this for you, and you just have to declare which calling convention to use before you declare the function (via `#pragma linkage`). Rather similar to the situation with MS-DOS and 16-bit Windows, where each function had to declare which calling convention it wanted to use (cdecl, pascal, stdcall, fortran, etc)