Perl virtual machine: Difference between revisions

Content deleted Content added
wikifying
Updated links from CPAN to MetaCPAN
Line 9:
Perl's opcodes interpreter is implemented as a tree walker which travels by opcode tree in execute order from start node, following the ''next'' or ''other'' pointers. Each opcode has a function pointer to a pp_''opname'' function, i.e. ''say'' opcode calls ''pp_say'' function of internal Perl API.
 
The phase of compiling the Perl program is hidden for the end user, but it can be exposed with B Perl module<ref name="B">{{cite web | url=httphttps://search.cpanmetacpan.org/perldoc?module/B | title=B - The Perl Compiler Backend}}</ref> or other specialized modules like B::Concise Perl module.<ref>{{cite web | url=http://perldoc.perl.org/B/Concise.html | title=B::Concise - Walk Perl syntax tree, printing concise info about ops}}</ref>
 
An example of compiled simple [[Hello world]] program with a help of B::Concise Perl module, dumped in execute order:
Line 37:
Perl VM data structures are represented internally by [[typedef]]s.
 
The internal data structures can be examined with B Perl module<ref name="B" /> or other specialized tools like Devel::Peek Perl module.<ref>{{cite web | url=httphttps://search.cpanmetacpan.org/perldoc?module/Devel::Peek | title=Devel::Peek - A data debugging tool for the XS programmer}}</ref>
 
====data types====
Line 70:
There is no standarization for Perl language and Perl virtual machine. The internal API should be considered as non-stable and changes from version to version. The Perl virtual machine is tied closely to compiler. These things make very hard to reimplement Perl virtual machine.
 
The most known and most stable implementation is a B::C Perl module<ref>{{cite web | url=httphttps://search.cpanmetacpan.org/perldoc?module/B::C | title=B::C - Perl compiler's C backend}}</ref> which translates opcodes tree to representation in C language and adds own tree walker.
 
Another implementation is an Acme::Perl::VM Perl module<ref>{{cite web | url=httphttps://search.cpanmetacpan.org/perldoc?module/Acme::Perl::VM | title=Acme::Perl::VM - A Perl5 Virtual Machine in Pure Perl (APVM)}}</ref> which is an implementation coded in Perl language only but it is still tied with original Perl virtual machine via B:: modules.
 
==See also==
Line 83:
*[http://perldoc.perl.org/perlhack.html#Running The Perl internals: running stage]
*[http://perldoc.perl.org/perlguts.html Introduction to the Perl API]
*[httphttps://search.cpanmetacpan.org/perldoc?module/RURBAN/B-C-1.42/perloptree.pod The "B" op tree.]
 
{{Perl}}