Re: Perl Compiler source file (fwd)

[email protected] (Nicholas Clark) Thu, 17 Mar 2005 16:27:11 +0000
Newsgroups perl.perl5.porters,perl.perl1.porters
Message-ID <[email protected]>
On Thu, Mar 17, 2005 at 09:30:54PM +0530, Sapna Jain wrote:
> 
> Hello,
> 
> I m working in optimizing compilers, So, i want to study the perl 
> compiler, how it compiles the program, and generate c code, and nay 
> opportunities to improve the compilation process.

You probably wanted to ask your question on the perl5-porters list, rather
than the perl1-porters list. The perl1 list is for things relating to keeping
the first version of perl compiling, mainly for curiosity.

The main perl interpreter doesn't generate C code. Instead it compiles down
to an internal tree of opcodes for the internal stack based virtual machine.
I believe that there were some experiments in outputting C code using the B
extension, but that work has been mostly abandoned now. You might want to
look in ext/B/B/C.pm and ext/B/B/CC.pm in the perl5 source distribution.

The documentation in CC.pm (search for =head1) suggests that it never did
any real optimisation, so even this is probably not of interest to you.

parrot, the virtual machine for Perl 6 currently under development, can
output native executables, but it does that using its JIT compiler
directly on its bytecode. I'm not sure if it has had a backend to output
C code. You could ask about parrot on [email protected].

Nicholas Clark