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

Adding codegeneration step

Thread Next
From:
Gerard Goossen
Date:
December 30, 2010 14:09
Subject:
Adding codegeneration step
Message ID:
20101230220927.GC3391@ggoossen.net
I will send the patches afterthis, but the changes are in the codegen
branch at git://github.com/ggoossen/perl.git or to view the commits
https://github.com/ggoossen/perl/commits/codegen

* 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
gone.

* 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
backwards-compatible.

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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About