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