home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / compiler / 1274 < prev    next >
Encoding:
Text File  |  1992-07-29  |  2.7 KB  |  64 lines

  1. Newsgroups: comp.compilers
  2. Path: sparky!uunet!gatech!news.byu.edu!eff!world!iecc!compilers-sender
  3. From: sewardj@cs.man.ac.uk (Julian Seward)
  4. Subject: Re: Pros and cons of high-level intermediate languages
  5. Reply-To: sewardj@cs.man.ac.uk (Julian Seward)
  6. Organization: Department of Computer Science, University of Manchester
  7. Date: Sun, 26 Jul 1992 11:30:52 GMT
  8. Approved: compilers@iecc.cambridge.ma.us
  9. Message-ID: <92-07-095@comp.compilers>
  10. Keywords: bibliography, translator
  11. References: <92-07-068@comp.compilers> <92-07-084@comp.compilers>
  12. Sender: compilers-sender@iecc.cambridge.ma.us
  13. Lines: 49
  14.  
  15. Graham Matthews writes:
  16.  
  17. | (Olivier Ridoux) writes:
  18. | >d) There is no first-class label data-type.  One can neither store and
  19. | >read labels, nor goto stored labels.  
  20. |
  21. | I think you will find that gcc 2.X allows you to have arrays of labels.
  22. | Any gcc experts out there to confirm this?
  23.  
  24. I am surprised no-one has picked up on this.  Sure, C doesn't allow labels
  25. as first class citizens, but procedure names *are*.  The Glasgow Haskell
  26. Compiler uses C as a back end.  Each basic block is compiled into a
  27. parameter-less C procedure.  When a basic block is done, it *returns* the
  28. address of the next block to be executed (which is some C procedure).  The
  29. whole system is driven by a magic 1-line "interpreter" like this:
  30.  
  31.    while (TRUE) { cont = (*cont)(); }
  32.  
  33. so that "cont" is the address of the next code block to be executed.  This
  34. works, is uses no non-standard extensions, but is somewhat inefficient.
  35. At the cost of portability, one can use non-standard extensions in GCC
  36. 1.XX and 2.X to genuinely to direct jumps from one code block to the next,
  37. and various other optimisations like suppressing register load/saves.
  38.  
  39. All this magic is described in Simon L Peyton Jones's paper.
  40.  
  41. It should be pointed out this is not a new idea.  Apparently Guy Steele
  42. used this in the Rabbit compiler for Scheme, and also for a SML compiler
  43. in the reference below.
  44.  
  45. Jules
  46.  
  47. -------------------
  48.  
  49. D Tarditi, A Acharya and P Lee [March 1991]. "No assembly required:
  50. compiling Standard ML to C", School of Computer Science, 
  51. Carnegie Mellon University.
  52.  
  53. Simon L Peyton Jones [1992].  "Implementing lazy functional languages on
  54. stock hardware: the Spineless Tagless G-machine".  Department of Computing
  55. Science, University of Glasgow, UK.  To appear in the Journal of
  56. Functional Programming, and available by anonymous FTP from
  57. ftp.dcs.glasgow.ac.uk:/pub/glasgow-fp/papers/spineless-tagless-gmachine.dvi
  58. [This is known as continuation passing form; Andrew Appel's book which was
  59. discussed here recently is all about how he built an ML compiler that works
  60. that way.  -John]
  61. -- 
  62. Send compilers articles to compilers@iecc.cambridge.ma.us or
  63. {ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.
  64.