A Parallel Virtual Machine for E Cient Scheme Compilation
Total Page:16
File Type:pdf, Size:1020Kb
A Parallel Virtual Machine for Ecient Scheme Compilation Marc Feeley and James S Miller Brandeis University Waltham MA Architecture HPPA MIPS R Motorola K Abstract BBN Monarch For our purp oses it was imp ortant Programs compiled by Gambit our Scheme compiler achieve that retargetting the compiler b e simple and yet still p erformance as much as twice that of the fastest available yield a high p erformance system We rejected exist Scheme compilers Gambit is easily p orted while retaining ing compilerbased Scheme systems T with Orbit its high p erformance through the use of a simple virtual CScheme with Liar mainly b ecause of the di machine PVM PVM allows a wide variety of machine culty of retargetting and mo difying the compilation indep endent optimizations and it supp orts parallel computa strategy of these large systems tion based on the future construct PVM conveys highlevel High p erformance of output programs We are not information bidirectional l y b etween the machineindepen concerned with program development features For ex dent front end of the compiler and the machinedependent ample we do not allow the user to interrupt execution back end making it easy to implement a number of common of a program other than by ab orting it back end optimizations that are dicult to achieve for other virtual machines Supp ort for task creation and synchronization through PVM is similar to many real computer architectures and implici t data op erations p ossibly augmented by con has an option to eciently gather dynamic measurements of trol constructs The future construct provides these virtual machine usage These measurements can b e used in features compatibly with most other features of the p erformance prediction for p orts to other architectures as Scheme language and was therefore our initial fo cus well as design decisions related to prop osed optimizations We are also interested in exploring other parallel con and ob ject representations trol and data constructs Intro duction While the rst and second goals are somewhat at o dds with one another we b elieve that architectural comparisons Our primary interest is in ecient mechanisms for imple and architecture indep endent implementation techniques will menting futurebased symbolic computation on currently b e among the imp ortant results from our research We have available MIMD machines Having already done work in this therefore chosen to build a compiler based on an easily re area using the Scheme language augmented with the future targetted virtual machine even though it may result in less mechanism we are now extending our interpreter ecient compiled co de Fortunately our exp erience with based results into the realm of compiled Scheme co de For Gambit indicates that a well chosen virtual machine do es this purp ose we underto ok the implementation of a new not result in any noticeable p erformance p enalties Scheme compiler Gambit with the intention of creating a simple environment for exp eriments across a wide range PVM A Parallel Virtual Machine of hardware platforms and over a range of implementation techniques The ma jor design goals for Gambit from the In designing our virtual machine we tried to avoid a pair of outset were twin hazards that we have seen in other virtual machines used for compilation On the one hand there are virtual Co de generation for multiple target machines span machines like MITs scode or the co de ob jects of UMB ning b oth common CISC computers DEC Vax Mo Scheme that are so close to the source language that the torola MC and RISC computers HP Precision machine indep endent front end of the compiler is unable to express imp ortant optimizations in the virtual machines in This research was supp orted in part by the Op en Software Foun dation the HewlettPackard Corp oration and NSF equipment grant struction set This places a ma jor burden on the back end CDA Marc Feeley is on study leave from the Universitede which b ecomes resp onsible for analysis of the virtual ma Montreal chine co de a task very nearly as dicult as the original compilation task On the other hand there are virtual ma chines like Multilisps mcode or Scheme s byte co de that match neither the actual target machine nor the source language The result is either a complex back end that again attempts to recover data and control ow information from the virtual machine or a simple back end that pro duces Op erand Meaning p o or co de regn General purp ose register n Our Parallel Virtual Machine or PVM is intended to fall in b etween these kinds of machines We allow each back th stkn N slot of the current stack frame end to sp ecify a wide range of architectural details of the globname Global variable virtual machine includin g a description of primitive pro ce membase oset Indexed reference base is an dures available on the target machine and the number of op erand oset is a constant general purp ose registers As a result we can think of PVM objobject Constant as a set of virtual machines dep ending on the back end de lbln Program lab el scription that is used Each sp ecic virtual machine is close loc Parallelism supp ort see Section to its target machine yet the common abstraction hides the precise details from the front end PVM also remains close to the source language since its small instruction set closely Figure PVM Op erands matches the Scheme language itself PVM can b e viewed as a bidirectional communication medium b etween the front and back ends of the compiler The traditional role of a virtual machine of course is to con we leave other data structure accesses to the more general vey information from the front end to the back end PVM APPLY instruction As a result the ability to nest other however conveys information in the reverse direction as well op erands within mem is not actually in use although the back ends supp ort it The number of general registers Finally we note that all op erands can b e used as the The pro cedure calling convention source of values However values cannot b e stored into obj The format of closures lbl or op erands Enumeration and description of primitive pro cedures Machinespecic declarations Instructions for Sequential Computation We view this bidirection al communication as an imp or The PVM instruction set provides a small set of general tant comp onent of Gambits organization The communica instructions to eciently enco de the op eration of Scheme tion is supp orted by a language for describing implementa programs Like many compilers Gambit represents the pro tionlevel ob jects which is the basis of the PVM abstraction gram as a set of basic blo cks This representation is ap Four types of ob jects are manipulated using this language parent in the PVM co de Each basic blo ck is headed by a primitive pro cedures data ob jects stack frames and argu co de lab el followed by the co de for the data op erations in mentparameter blo cks Corresp onding to each of these is the blo ck and ends with a branch instruction Our current a means of reference the name of the primitive pro cedure instruction set for sequential computation consists of four slots within a data structure slots within a stack frame kinds of co de lab els three data manipulatin g instructions and argumentparameter number This particular level of and three branch instructions abstraction is convenient for b oth the front and back ends An imp ortant part of Gambits communication mecha For example b oth the back and front ends agree to discuss nism is the description of a set of pro cedures known as prim stack slots as p ositive integers in units of Scheme ob jects itives that are supp orted by the back end All primitives increasing as ob jects are pushed on the stack This is clearly are available through the general pro cedure call mechanism convenient for the front end and the back end can easily but some can also b e op en co ded by the APPLY and COND translate this into appropriate osets from a base register instructions The front end requires the back end to supply taking into account the number of bytes p er argument the a sp ecic minimal set of ab out primitive op erations direction of stack growth and the choice of stack discipli ne but the back end can in fact sp ecify any pro cedure as a on the target machine primitive The description of each primitive indicates its ar ity and strictness It also indicates whether it can b e op en Op erands co ded and whether it can return a placeholder as a value Thus list has unbounded arity is not strict in any argu PVM has seven classes of op erands as shown in Figure ment and never returns a placeholder while setcar has which naturally divide storage into disjoint areas registers arity two is strict in its rst argument but not its second current stack frame global variables heap storage constant and never returns a placeholder area and co de area This makes it easy to track values and PVMs handling of stack frames is unusual and is de with the exception of mem op erands removes the traditional scrib ed in Section The siz e parameter to the lab el and aliasing problem branch instructions is used to supp ort this mechanism and Neither the stack nor the heap p ointer is directly visible is describ ed in detail in that section Instead the stack is accessible by indexing o of a virtual The description of the sequential PMV instructions fol frame base p ointer that is mo died as part of the pro ce lows Figure shows a simple program iterative factorial dure call mechanism The heap is accessed implicitly when along