develooper Front page | perl.perl5.porters | Postings from December 2010

Adding codegeneration step

Thread Next
Gerard Goossen
December 30, 2010 14:09
Adding codegeneration step
Message ID:
I will send the patches afterthis, but the changes are in the codegen
branch at git:// or to view the commits

* Small summary:
Before executing a subroutine/optree, there is a codegeneration step
added where the optree is converted in an "instruction" list
(consisting of pp_* functions with arguments).  As a result the
optree does no longer function as an execution list, i.e op_next is

* Delayed constant folding.

Constants folding is now done at execution time instead of
compiletime.  Fixes bugs where constant folding interfered with the
semantic analysis, for example with a bareword in constant folded
expressions being interpreted as filehandle.  Also it allows warnings
about precedence involving constants.

* Details about the change

The peep hole hook is removed. There is the possibility to replace it
with Perl_finish_optree and Perl_finish_op, which perform a similar
function as the old peep, (at the end of making the otree they go
recursively through the optree, performing some final checks/changes).

All B modules work (although some things like the optree in execution
order are obviously removed), but the changes I made are not

Changes from API function as exported by embed.fnc: 
- op_linklist is removed, but could be added back as a no-op.
- debop replaced by debug_instruction. But "debop" could be kept. 
- Make OP* arguments const OP*, also requires PL_op to be a const OP*

Signature of pp_* function have changed.

Also the current code isn't really optimized, there are some obvious
optimizations, like changing some of the accessor functions to macros,
which are not yet done.

All tests pass on linux and windows (ignoring all previously failing tests
on windows).

Gerard Goossen

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About