Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does Perl store its intermediate byte code?

Tags:

perl

After going through couple of linksI came to know that Perl does the compilation and create an intermediate byte code and then interpret that byte code. My question is where does that byte code reside?

Like in other language like java, c we can see the machine executable object code after compilation. Though Perl doesn't create machine executable code, but there should be some location where it stores the byte code temporarily.

like image 222
Joe Avatar asked Oct 01 '10 12:10

Joe


2 Answers

The result of the compilation is stored in memory as a tree of opcodes, or optree for short. This structure is being walked by perl's runtime to execute your program.

You will probably find the "Compiled Code" section of perlguts interesting. It explains many of the details of building an executing a perl optree.

It's also sort of possible to write that optree out to disk and load it again into another perl process, using the B::C distribution and the ByteLoader module contained in it. However, this technique doesn't work all that well on many programs, so it's not recommended in any way.

like image 159
rafl Avatar answered Oct 20 '22 00:10

rafl


It stores it in memory as an AST.

like image 43
Chas. Owens Avatar answered Oct 20 '22 01:10

Chas. Owens