From mboxrd@z Thu Jan 1 00:00:00 1970 From: scj@yaccman.com (scj@yaccman.com) Date: Sun, 3 Jan 2016 16:42:45 -0800 Subject: [TUHS] Early Unix function calls: expensive? In-Reply-To: <20160103233543.GA10102@minnie.tuhs.org> References: <20160103233543.GA10102@minnie.tuhs.org> Message-ID: Well, I certainly said this on several occasions, and the fact that it is recorded more or less exactly as I remember saying it suggests that I may have even written it somewhere, but if so, I don't recall where... As part of the PCC work, I wrote a technical report on how to design a C calling sequence, but that was before the VAX. Early calling sequences had both a stack pointer and a frame pointer, but for most machines it was possible to get by with just one, so calling sequences got better as time went on. Also, RISC machines with many more registers than the PDP-11 also led to more efficient calls by putting some arguments in registers. Later standardizations like varargs were painful on some architectures (especially those which had different registers for pointers and integers). The CALLS instruction was indeed a pig -- a space-time tradeoff in the wrong direction! For languages like FORTRAN it might have been justified, but for C it was awful. It is my memory too that CALLS was abandoned, perhaps first at UCB. But I actually had little hands-on experience with the VAX C compiler... Steve > I just re-found a quote about Unix processes that I'd "lost". It's by > Steve Johnson: > > Dennis Ritchie encouraged modularity by telling all and sundry that > function calls were really, really cheap in C. Everybody started > writing small functions and modularizing. Years later we found out > that function calls were still expensive on the PDP-11, and VAX code > was often spending 50% of its time in the CALLS instruction. Dennis > had lied to us! But it was too late; we were all hooked... > http://www.catb.org/esr/writings/taoup/html/modularitychapter.html > > Steve, can you recollect when you said this, was it just a quote for > Eric's book or did it come from elsewhere? > > Does anybodu have a measure of the expense of function calls under Unix > on either platform? > > Cheers, Warren >