David Ross writes:
> How much of the overhead for method dispatch/return is or can be
> incurred at compile time? If call and return signatures are defined at
> compile time is it possible to eliminate switch code and/or jump
> tables as an optimumization?

We hope so, in the absence of a pragma telling us not to.

In fact, the direction the grammar engine is going seems to be a very
good one.  Basically we do all the work we possibly can in "compiler"
modules, and then generate the code we end up running.  This can  be
done at every stage of the game for Perl 6.
> 
> From what I have learned attributes (handlers) and
> BEGIN/CHECK/AUTOLOAD blocks are part of the answer. They provide for
> building and manipulating the symbol table. What I have been searching
> for is a way of triming the control flow graph.

Hmm... are you still asking about Perl 6?  Because I can tell you about
that, since it doesn't exist and I can make up whatever :-).  If you're
asking about Perl 5, then go to the "applied programming" department,
perl5-porters.  :-)

In Perl 6, we can't trim the control flow graph after it's been built.
The graph determines what register numbers are used, etc., and it can't
be retroactively changed.  But we can trim before we generate the code.
In fact, constant folding does that.

Perl 6 will have to be much more liberal than Perl 5 in optimizations.
Perl 6 has hooks *everywhere*, and checking for all of them all the time
would slow execution to a crawl.  Fortunately, a lot of the hooks are
lexical, so we can tell when we have them and when we don't. 

Better yet, module implementors can use these hooks because of macros
and compile-time evaluation (as you mention, BEGIN blocks are very
important).  So a module can tell the compiler that this hook is really
here, even though it doesn't look like it, and the correct code can be
generated.

> Sorry if this is off topic or dated. I have recently return to
> developing in PERL struggling to catch up. The conceptual and concrete
> progress is awesome.

Thanks.  Sorry if my answer didn't answer your question.  I get the
feeling I took your words and made my own question out of them, and
then answered it...

Luke

Reply via email to