-------- Original Message --------
Subject: call opcodes cleanup
Date: Thu, 21 Jul 2005 09:52:07 +0200
From: Leopold Toetsch <l...@toetsch.at>
To: Perl 6 Internals <perl6-i...@perl.org>
There are still some leftovers of the old calling scheme, which I'd like
to get rid of (1,2) or change slightly (3):
1) bare invoke
This opcode assumes P0 = Sub, P1 = Continuation
2) bare invokecc
This opcode assumes P0 = Sub
3) invoke Px
This opcode assumes P1 = Continuation, but it has a double usage: call a
coroutine (not the first time) and yield from a coroutine with this code
sequence:
interpinfo Px, .INTERPINFO_CURRENT_SUB
invoke Px
Instead I'd like to have distinct opcodes, that carry the effects on
operands clearly in their signature. The replacement for above would be:
1) invoke PSub, PCont # call sub with given continuation
2) invokecc PSub # call sub, create continuation - exists
3a) invoke PCoro # call sub, leave continuation as is
3b) yield # yield results from a coroutine
3a) exists too, but it currently picks up a continuation in P1.
Rational: the register allocator has to track the usage of all symbols.
For all the implicit register usage, extra code is needed that tracks
register usage. See trunk imcc/cfg.c for details.
-------------
Method call opcodes
We currently have these opcodes:
4a) callmethod
Implicit registers used: S0 = method, P1 = continuation, P2 =
invocant/object
4b) callmethod Smeth
5a) callmethodcc
5b) callmethodcc Smeth
We probably need just one opcode:
5) callmethodcc Pinvocant, Smeth
(maybe callmethod Pinvocant, Smeth, Pcont)
The invocant is used for method lookup, the object is passed as first
argument to methods and is usually the same.
The tailcall-variants of all calls follow the same scheme, except that
these just reuse the current continuation.
Comments welcome,
leo
I like this, especially the motivation.
> -------------
>
> Method call opcodes
>
> We currently have these opcodes:
>
> 4a) callmethod
>
> Implicit registers used: S0 = method, P1 = continuation, P2 =
> invocant/object
>
> 4b) callmethod Smeth
>
> 5a) callmethodcc
> 5b) callmethodcc Smeth
>
> We probably need just one opcode:
>
> 5) callmethodcc Pinvocant, Smeth
> (maybe callmethod Pinvocant, Smeth, Pcont)
I think that we should have the second option (as that is an easy way
to have tailmethods). We might also want a C< callmethod Pinvocant,
Pmeth, Pcont > if we allow methods that are pmcs. (This might allow
hoisting the string lookup outside a loop or something).
Matt
--
"Computer Science is merely the post-Turing Decline of Formal Systems Theory."
-Stan Kelly-Bootle, The Devil's DP Dictionary
Just to register an opinion -- I don't think the proposed
changes cause me any grief, so they're fine with me.
Pm