home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / acorn / tech / 56 < prev    next >
Encoding:
Internet Message Format  |  1992-08-17  |  2.8 KB

  1. Path: sparky!uunet!mcsun!sunic!dkuug!diku!torbenm
  2. From: torbenm@diku.dk (Torben AEgidius Mogensen)
  3. Newsgroups: comp.sys.acorn.tech
  4. Subject: Re: New Language/Compiler (ideas wanted)
  5. Message-ID: <1992Aug17.115838.26941@odin.diku.dk>
  6. Date: 17 Aug 92 11:58:38 GMT
  7. References: <1195@grun.is> <1992Aug13.130618.18871@odin.diku.dk> <1992Aug13.205528.15434@cs.aukuni.ac.nz> <KERS.92Aug14085518@cdollin.hpl.hp.com>
  8. Sender: torbenm@gere.diku.dk
  9. Organization: Department of Computer Science, U of Copenhagen
  10. Lines: 48
  11.  
  12. kers@hplb.hpl.hp.com (Chris Dollin) writes:
  13.  
  14. >In article ... jwil1@cs.aukuni.ac.nz (TMOTA) writes:
  15.  
  16. >   torbenm@diku.dk (Torben AEgidius Mogensen) writes:
  17.  
  18. >   >Afeature I have sorely missed in compilers for C etc. is a cheap
  19. >   >tail-call: if the last thing you do in a procedure or function is to
  20. >   >call a procedure or function, this can be implemented as a goto rather
  21. >   >than a general procedure/function call. Also, the local variables of
  22.  
  23. >   What do you mean? What if the tail-called function then tries to call
  24. >   another function or (even worse) recurses? This could only work if
  25. >   the tail-called function expected to recieve *exactly* the stack frame
  26. >   that the tail-caller has had set up when it was called.
  27.  
  28. >Urk? You clean up the stack before you call the tail-called function, of
  29. >course. It's a standard optimisation, at least in the Lisp world. [The only
  30. >objection to it is that it can make debugging harder -- you lose the functions
  31. >that tail-called when you get the stack backtrace.]
  32.  
  33. >   And remember that Acorn's C compiler (the ARM proc. call std.?) is clever
  34. >   enough to notice when you call a function that does not call another (a
  35. >   leaf function), and does not bother with most of the context-storing
  36. >   operations involved in normal function calls.
  37.  
  38. >I'm not sure you said what you meant. There's no cleverness involved in calling
  39. >a leaf function (after all, who's to know that it *is* a leaf function?), it's
  40. >just that leaf functions don't need to carry all the baggage of a full function
  41. >call -- it's the code of the leaf that ``does not bother with most of the
  42. >context-storing operations''. [They don't carry the baggage because there's
  43. >very little that can go wrong inside them, so they don't need to record who
  44. >they are in case something does.]
  45.  
  46. This is basically the old caller-saves/callee-saves controversy:
  47. caller-saves makes tail-call optimization easy, callee-saves makes
  48. leaf-call optimizations easy.
  49.  
  50. The reason callee-saves is bad for tail calls, is that it can't see if
  51. it is called from a tail position (unless a separate entry point or
  52. parameter specifies this). The reason caller saves is bad for leaf
  53. call optimization is that things are already saved, so you can't avoid
  54. doing so.
  55.  
  56. Both of these problems can be partially solved by using a mixture of
  57. caller saves and callee saves strategies.
  58.  
  59.     Torben Mogensen (torbenm@diku.dk)
  60.