Craig A. Berry wrote:
At 12:19 AM -0400 6/7/04, John Malmberg wrote:

Craig A. Berry wrote:

To compile Perl directly, you need to interface to a back end code
generator.

True, but we need to define "code" here. For Perl, it generally means bytecode that is run on the Perl bytecode engine, which is roughly equivalent to what Java folks call a virtual machine. I say "roughly" because Perl is a dynamically typed language (unlike Java or C#). In Perl, "8.341" may just be a string right up until the point you do arithmetic on it, at which point it becomes a number.

Several other compilers know how to deal with that. All variables are passed by descriptor to most routines. Others can be handled by the optimizer.


An example in the C compiler is the handling of printf, sprintf, fprintf.

If the optimizer can resolve the format string at compile time, it breaks up the call into more specific formatting routines.

The Gnat ADA project uses the code generator in GCC for this, and
if the other Perl compilers use this, then there may be a way to
get this done on OpenVMS.


Good point. If someone were to target the GCC code generator, and if
this code generator were sufficiently smart enough to generate the right instructions on Alpha and Itanium (no small task), then there's
no particular reason this wouldn't work as well on VMS as elsewhere.

GCC has code generates for almost every processor, including VAX, Alpha, and IA64.


As far as your other points, I am totally ignorant of Perl and what the compiler efforts are doing.

Generally the way that a code generator works is that it provides an API to describe the instruction set to the front end of the compiler so that the front end can emit the proper code stream.

Logically if an open source project like Perl is going to have a version that can be compiled to an executable, it would either have a custom code generator that will only support a few targets, or it would use the GCC code generator.

Using the GCC code generator is not a trivial project. The GCC documentation appears to be several generations behind the current code base.

-John
[EMAIL PROTECTED]
Personal Opinion Only



Reply via email to