encapsulate-main branch

Andrew Whitworth wknight8111 at gmail.com
Fri Dec 31 22:47:21 UTC 2010


The work in this branch is something that we do want. As a little bit
of background IMCC creates Sub PMCs from the .sub/.end directives that
it parses, and attaches flags to the Sub PMC. so :main adds a MAIN
flag to the sub, :init adds an INIT flag to the sub, etc. These
flagged Sub PMCs are stored in the constant table for the generated
Packfile.

At the end of compilation, this is where the real fun starts.
libparrot starts iterating over the entire constants table, *multiple
times*. It iterates over the list to find all the :immediate functions
and executes them, then it iterates over all constants to execute the
:init functions, and finally it iterates through until it finds the
first :main function or (if no :main is found) it executes the first
non-main function. This is all a huge performance drain, and we want
to avoid this.

This work that Peter is doing is the first step in ending some of this
madness. Instead of having to loop over the constants to find :main,
we cache it during compilation. Looking it up later goes from being
O(n) to O(1). We're going to want to repeat this work later to make
the situation more sane for :immediate, :load, and :init subs too. All
told, there are some interesting performance wins to be had here.

--Andrew Whitworth



On Fri, Dec 31, 2010 at 4:26 PM, Peter Lobsinger <plobsing at gmail.com> wrote:
> The encapsulate-main branch moves tracking of :main-tagged subs from
> the subs themselves to packfiles (which should really be taking care
> of this kind of thing). At the same time, it tackles TT #1704, which
> requires a :main sub (no more automagic
> first-encountered-sub-is-main).
>
> At this point, it passes most tests (a few examples need some work).
> Some HLLs pass (winxed, lua with :main tags added to PIR testsuite).
>
> NQP-rx needs some work to generate :main subs. I have some ideas about
> how to "fix" it, but they are hackish and of poor quality. If someone
> familiar with this language could make the appropriate changes, this
> would be much appreciated.
> _______________________________________________
> http://lists.parrot.org/mailman/listinfo/parrot-dev
>


More information about the parrot-dev mailing list