Next: Contents Up: bkuhn's Technical Writings Previous: bkuhn's Technical Writings

CONSIDERATIONS ON PORTING PERL
TO THE
JAVA VIRTUAL MACHINE


A thesis submitted to the
Division of Research and Advanced Studies
of the University of Cincinnati


in partial fulfillment of the requirements for the degree of


MASTER OF SCIENCE


in the Department of Electrical and Computer Engineering and
Computer Science
of the College of Engineering
2001
by

Bradley M. Kuhn
B.S., Loyola College In Maryland, 1995



Committee Chair: John Franco, PhD.


Committee Approval

Unveristy of Cincinnati

I, Bradley M. Kuhn, herby submit as part of the requirements of the degree of:

MASTER OF SCIENCE

in

The Department of Electrical and Computer Engineering and Computer Science

It is entitled:

Considerations on Porting Perl to the Java Virtual Machine

Approved by:
Fred Annexstein
John Franco
Larry Wall
Hongwei Xi


Abstract

The Java Virtual Machine (JVM) is perhaps the most interesting aspect of the Java programming environment. Much attention has been placed on porting non-Java languages to the JVM. Such ports are useful since JVMs are now embedded in hardware devices, as well as in software applications such as web browsers. In addition, well designed JVM ports can utilize the JVM as a common object model for multiple languages, allowing larger applications to easily be written in and scripted with multiple programming languages.

This thesis presents a survey of possible approaches for porting non-Java languages to the JVM. The advantages and disadvantages of each approach are considered. Examples of JVM ports of other programming languages, such as Python, Scheme, and Tcl are presented and considered.

The focus, however, is a port of Perl to the JVM. The internals of the existing Perl implementation are discussed at length with examples. The perl front-end parser, lexer and intermediate representation (IR) are described in detail. The default Perl compiler back-end, called the Perl Virtual Machine (PVM), is considered and described.

Two approaches for porting Perl to the JVM are presented. The first approach reuses the existing perl front-end via Perl's B module to compile directly to JVM assembler (using Jasmin syntax). This approach is described and examples are given. The problems of mapping the PVM onto the JVM, the lack of generalization of the existing perl IR, and complications caused by the JVM bytecode verifier are introduced and explained.

The second approach massages the existing perl IR into the Kawa system's more generalized IR. This approach is much more successful than direct compilation, and reasons are given to make that case. Kawa's IR is presented, and an example of a Perl program compiled to Kawa's IR is given.

Finally, conclusions and lessons learned from this work are presented. A framework for the future work required to complete a Perl port to the JVM (via Kawa) is given. A brief comparison between the Kawa/JVM infrastructure and Microsoft's .NET/C# system is presented.


Dedication

I dedicate this work to my fianc�e, Elizabeth A.�McKeever. She indeed knows how to love a hacker--which is certainly not an easy task. Thanks, keever, for always reminding me there is a world outside of computer science.


Acknowledgements

First, I thank the USENIX Association for a student scholarship and stipend during the early research of this work. In addition, the http://www.ececs.uc.eduDepartment of Electrical and Computer Engineering and Computer Science provided me with a University Graduate Scholarship for much longer than I would have thought possible, and for that I am very grateful.

I would like to thank my committee for taking the time to read my thesis and listen to my defense. I give special thanks to Larry Wall for traveling so far to serve on my committee.

Linda Gruber, the ECECS graduate program coordinator, deserves special mention. Her relentless work to ensure that graduate students have what they need is an asset to the department.

I would also like to thank the other Canonical Hackers for their continuous support of my work and my ideas, even when I doubted them myself.

I thank also the Perl community in particular and the free software community in general. Without the plethora of free software that is available for Perl and Java, this work would not have been possible.

Finally, I am grateful for the Cosource system, and those who helped fund my software development through that system.




Next: Contents Up: bkuhn's Technical Writings Previous: bkuhn's Technical Writings


Copyright � 2000, 2001 Bradley M.�Kuhn.

Verbatim copying and distribution of this entire thesis is permitted in any medium, provided this notice is preserved.