Software Portability by Virtual Machine Emulation – My Thesis
May 1, 1989
I completed my Master of Mathematics degree in Computer Science at the University of Waterloo in 1989, under the supervision of Dr. Gaston Gonnet (now at ETH Zurich). The topic of software portability arose out of my work in 1987 porting the Maple computer algebra system from the 32- and 36-bit mainframes and minicomputers it had been developed on, to the then-new 16-bit IBM Personal Computer family.
Much has changed in the computer world since then. All personal computers now have at least a 32-bit bus width, with most new ones being 64-bits wide. The typical amount of memory available has increased two-thousand-fold from the typical megabyte found in an 80286-based PC of the late 80s. Applications that are now much larger and more complex than the mainframe applications of the late 20th century now comfortably fit on a PC.
On the other hand, some things have remained the same. There are still multiple system architectures to which software must be portable (primarily Windows, Linux, and Macintosh). For many applications, a virtual machine approach somewhat like the one described in my thesis is being used (JVM, the Java virtual machine). However, computers have become fast enough that a one-size-fits-all VM will do, instead of the application-tailored VM I described and implemented.
I’ve put this work on-line in the hopes that someone may find it useful or interesting. When I did my background research for this thesis, I spent a lot of time searching the University’s archives in paper and microfilm form to find earlier related works. I wrote to authors whose papers were no longer in print, and many graciously sent me photocopies. If the WWW had existed at that time, I would have had an easier time of it.
I scanned the thesis from the master printed copy that I originally submitted to the University. The pages in the PDF file are all images, not text, so unfortunately it is not searchable. I still have the original source files in troff format on a 5¼” floppy disk, but I no longer have access to troff to format it, nor do I have a working 5¼” drive.
So, without further ado, here it is…
The proliferation of diverse computer architectures has resulted in an increased need for portable software, but many portability techniques incur a performance penalty. This penalty can be reduced by restricting the range of architectures to which a program must be portable, at the risk of limiting portability to new hardware as it becomes available.
In this thesis, we will examine a technique for making a program portable to architectures for which it was not intended, without affecting its performance on other architectures. The technique used is virtual machine emulation, whereby an ideal (for the program) architecture is emulated by another program on an incompatible system. By designing the virtual machine carefully, performance loss due to emulation can be minimized, and the program to be ported can be recompiled for the virtual machine without modification.
What Has Happened Since Then?
Although the project that started this thesis was to port Maple to the IBM Personal Computer (specifically, the 80286-based PC-AT) during my employment at the University of Waterloo’s Symbolic Computation Group, we ran out of time for that. By the time I finished the thesis and graduated, a virtual machine had been implemented for both the VAX-11/785 (which already supported Maple natively), and for the Oberon operating system on the Ceres workstation, but not for the PC-AT.
After graduating, I became one of the first two employees of Waterloo Maple Software (now Maplesoft). One of my projects there in 1990 was to complete the port to the 80286-based PC, since that was all that most students had at that time. To do this, I reimplemented the virtual machine in a mix of assembly language (for the core interpreter) and Turbo Pascal (to implement the standard library functions). This was extended by writing a driver for Maple’s
plot command, also as a built-in of the VM (thus from the compiled binary’s point of view, the machine had a PLOT instruction).
The good news is that this version worked perfectly, but it was found to be too slow for practical use. Since 80386 and 80386SX-based machines were starting to become common, we abandoned the 16-bit project, and instead ported Maple directly to the newer hardware (using the Phar Lap DOS extender and Metaware 32-bit C compiler).
As an interesting experiment at that time, I tried running the Maple port on my ancient IBM PCjr, a 4.77MHz 8088-based PC with 512Kb RAM and two 360Kb floppy disk drives. It did run, but it took three minutes to start up!
One by-product of this project that did survive to the present day is Maple’s library format. Before the port to Oberon, Maple stored every single library procedure in a separate internal-format file, organized into directories. Unfortunately, the Oberon file system wasn’t able to handle that many separate files, so I implemented an archive format. At that time, this was hidden from the Maple executable by the virtual machine (i.e. Maple still thought it was reading individual files), but later the idea was incorporated into Maple itself. Today’s Maple Library Archive (
.mla) is the much improved descendant of that original implementation.
I still have a copy of both the Maple binary compiled for my virtual machine, and a PC implementation of the VM. It still works of course, and actually runs faster on a modern PC than a natively-compiled version of Maple did back in 1989. Every now and then I entertain thoughts of porting it to some relatively small (by today’s standards) platform, such as my Palm Tungsten E2. Maybe some day…
Buy Stefan a coffee! If you've found this article
useful, consider leaving a donation to help support
Disclaimer: Although every effort has been made to ensure accuracy and reliability, the information on this web page is presented without warranty of any kind, and Stefan Vorkoetter assumes no liability for direct or consequential damages caused by its use. It is up to you, the reader, to determine the suitability of, and assume responsibility for, the use of this information. Links to Amazon.com merchandise are provided in association with Amazon.com. Links to eBay searches are provided in association with the eBay partner network.
Copyright: All materials on this web site, including the text, images, and mark-up, are Copyright © 2013 by Stefan Vorkoetter unless otherwise noted. All rights reserved. Unauthorized duplication prohibited. You may link to this site or pages within it, but you may not link directly to images on this site, and you may not copy any material from this site to another web site or other publication without express written permission. You may make copies for your own personal use.