E-Book, Englisch, 269 Seiten, eBook
Craig Virtual Machines
1. Auflage 2010
ISBN: 978-1-84628-246-1
Verlag: Springer
Format: PDF
Kopierschutz: 1 - PDF Watermark
E-Book, Englisch, 269 Seiten, eBook
ISBN: 978-1-84628-246-1
Verlag: Springer
Format: PDF
Kopierschutz: 1 - PDF Watermark
I love virtual machines (VMs) and I have done for a long time.If that makes me "sad" or an "anorak", so be it. I love them because they are so much fun, as well as being so useful. They have an element of original sin (writing assembly programs and being in control of an entire machine), while still being able to claim that one is being a respectable member of the community (being structured, modular, high-level, object-oriented, and so on). They also allow one to design machines of one's own, unencumbered by the restrictions of a starts optimising it for some physical particular processor (at least, until one processor or other). I have been building virtual machines, on and off, since 1980 or there abouts. It has always been something of a hobby for me; it has also turned out to be a technique of great power and applicability. I hope to continue working on them, perhaps on some of the ideas outlined in the last chapter (I certainly want to do some more work with register-based VMs and concur rency). I originally wanted to write the book from a purely semantic viewpoint.
Zielgruppe
Research
Autoren/Hrsg.
Weitere Infos & Material
VMs for Portability: BCPL.- The Java Virtual Machine.- DIY VMs.- More Stack-Based VMs.- Case Study: An Event-Driven Language.- Register-Based Machines.- Implementation Techniques.- Open Issues.
"7 Register-Based Machines (S. 157-158)
7.1 Introduction
The virt ual machines described so far have all had th e same property: they use at least one stack and a collection of special-purpose regist ers. This has been taken as the way to const ruct virtu al machines. It is certainly a relatively quick and easy way to do it and it is a target machine for which it is particularly easy to generate code. There are, however, alternatives, the primary being that based on the Register- Transfer Model (RTM) . This is the model upon which most hardware processors are based.
There have been many machine simulato rs over the years and there are programming environments , particularly for real-time and embedded systems, that allow programs for one processor to be executed using a simulated processor. However, t he use of the RTM for virt ual machines is relat ively new; the largest implementation to date (2004) is the Parrot virt ual machine for Perl6. This chapte r is concerned with this alternative organisation for virt ual machines.
Section 7.2 is concerned with the arguments surrounding registerbased machines, both pro and con. Section 7.3 contains a description of one way to organise a regist er-based virt ual machine. Since the only really public register-based virtual machine of any st rength is t hat for Parrot , Section 7.4 is a description of Parrot s general organisation , while Section 7.5 contains a description of Parrots instruction set (the description is only partial because th e published documentation is, as yet , incomplete- th e best way to understand t he Parrot VM is to read its code). In Section 7.6, a DIY register machine is presented.
In Section 7.7, it is shown how the two-stack code for the simple ALEX programming language can be converte d (macro processed, in essence) into code for the DIY register-t ran sfer machine. The following section contains examples of such translat ions using a simple function. The correct ness of the translat ion from two-stack to register-machine code is the subject of Section 7.9 In Section 7.10 a more natural compilation of ALEX to register-machine code is presented. In the last section, Section 7.11 some extensions to the register machine are considered. 7.2 The Register-Transfer Model Almost all work on abstract machines has concentrated on stack-based architectures.
The SECD machine is the classic of this form, of course. The Pascal-S , Pascal P4, UCSD Pascal, Smalltalk and Java abstract machines are also stack-based. One good reason for constructing stack-based machines is that expressions can be directly evaluated on the stack . Stacks are also used to represent scope, thus making procedures and block structures easy to implement. Stacks are required to implement recursion , a feature of ISWIM, Algol60 and most modern programming languages . Stack-based architectures are good for compiler writers, therefore."