Re: Native Code Generation from Abstract Stack Machine

Eliot Miranda <eliotm@pacbell.net>
11 Mar 2004 12:57:38 -0500

          From comp.compilers

Related articles
Native Code Generation from Abstract Stack Machine kevin@albrecht.net (Kevin Albrecht) (2004-02-27)
Re: Native Code Generation from Abstract Stack Machine alex_mcd@btopenworld.com (Alex McDonald) (2004-03-02)
Re: Native Code Generation from Abstract Stack Machine m.dentico@no-spam.it (Massimo Dentico) (2004-03-02)
Re: Native Code Generation from Abstract Stack Machine bill@qswtools.com (Bill Cox) (2004-03-06)
Re: Native Code Generation from Abstract Stack Machine peter@javamonkey.com (Peter Seibel) (2004-03-06)
Re: Native Code Generation from Abstract Stack Machine peter@javamonkey.com (Peter Seibel) (2004-03-11)
Re: Native Code Generation from Abstract Stack Machine samiam@moorecad.com (Scott Moore) (2004-03-11)
Re: Native Code Generation from Abstract Stack Machine eliotm@pacbell.net (Eliot Miranda) (2004-03-11)
Re: Native Code Generation from Abstract Stack Machine bonzini@gnu.org (2004-03-19)
| List of all articles for this month |
From: Eliot Miranda <eliotm@pacbell.net>
Newsgroups: comp.compilers
Date: 11 Mar 2004 12:57:38 -0500
Organization: SBC http://yahoo.sbc.com
References: 04-02-179
Keywords: code, architecture
Posted-Date: 11 Mar 2004 12:57:37 EST

Kevin Albrecht wrote:
> I am looking for research or implementations on how to generate
> efficient machine code from abstract stack machines. It seems like
> most resources on machine code generation from intermediate languages
> focuses on translation from register-based intermediate languages.
>
> -- Kevin
> [I suspect the advice is turn it into abstract register code, then
> optimize. Optimizing stack code is a pain because of all of the
> bookkeeping you have to do for common subexpressions. -John]




One technique is described in


          Ali-Reza Adl-Tabatabai, Michael Cierniak, Guei-Yuan Lueh,
          Vishesh M. Parikh, James M. Stichnoth,
          "Fast, Effective Code Generation in a Just-In-Time Java Compiler",
          In Proceedings of the SIGPLAN `98 Conference on Programming Language
          Design and Implementation, p. 280-290.
          Published as SIGPLAN Notices 33(5), May 1998.


The idea is to make a single pass over the abstract stack code for a
single function, deferring code generation until encountering an
operator. When the abstract stack code references an operand, a
descriptor of the operand is pushed on an operand stack that mimics
the abstract stack during the compile pass. When an operator is
encountered code is generated by examining the relevant stacked
operand descriptors, and those operands are then replaced by a
descriptor describing the result.


One can generate acceptable register-based code this way. For
example, a typical operator might be implemented as a function call
and the result descriptor might reference a specific register holding
the result.


This is actually not a new technique. Peter Deutsch used it in the
ParcPlace Smalltalk virtual machines, inventing it in about 1986/87,
but he didn't publish because he considered it worth keeping secret.
We still use the same framework in the current VisualWorks Smalltalk
VMs.


Independently, and without knowledge of Peter Deutsch's scheme, Ian
Piumarta did a native code compiler for Smalltalk that he wrote up in
his thesis at Manchester University, which is called something like
"Deferred Code generation in a Smalltalk-80 Compiler". Its a very
similar idea.
--
_______________,,,^..^,,,____________________________
Eliot Miranda Smalltalk - Scene not herd


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.