Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Exception handlers and calling conventions

0 views
Skip to first unread message

Leopold Toetsch

unread,
Jul 11, 2005, 7:39:08 AM7/11/05
to Perl 6 Internals
In the old calling scheme the exception object arrived as P5 in the
handler. This doesn't really fit into the new scheme.

I can see two ways to go:

Store the exception (or an array of unhandled exceptions) in the
interpreter and make exceptions available as:

a) e = interpinfo .INTERPINFO_EXCEPTION

b) via the get_params opcode

The latter would reflect the exception call being an internal
continuation invocation:

push_eh handler
# throw
handler: # handler:
get_params "(0)", e # .param pmc e

(Except that .param isn't allowed in arbitrary position currently)

Proposals welcome,
leo

Autrijus Tang

unread,
Jul 11, 2005, 9:59:49 AM7/11/05
to Leopold Toetsch, Perl 6 Internals
On Mon, Jul 11, 2005 at 01:39:08PM +0200, Leopold Toetsch wrote:
> I can see two ways to go:
>
> a) e = interpinfo .INTERPINFO_EXCEPTION
>
> b) via the get_params opcode
>
> The latter would reflect the exception call being an internal
> continuation invocation:
>
> push_eh handler
> # throw
> handler: # handler:
> get_params "(0)", e # .param pmc e
>
> (Except that .param isn't allowed in arbitrary position currently)

If arbitary-position .param for inner subroutines can be made to work,
b) is by far more straightforward. This also plays well P6's notion
that all non-local exits, including return(), are conceptually
exceptions, so it makes sense to use the same pairs of calling
convention opcodes.

Thanks,
/Autrijus/

Roger Browne

unread,
Oct 3, 2005, 9:46:54 AM10/3/05
to Perl 6 Internals
On 11 July, Leopold Toetsch wrote:
> In the old calling scheme the exception object arrived as P5 in the
> handler. This doesn't really fit into the new scheme.

Leo, did you change the handling of P5? I have some PIR code that works
differently under 0.2.3 and 0.3.0:

.sub "main" @MAIN
push_eh MAIN_HANDLER
foo()
clear_eh
end
MAIN_HANDLER:
print "in main handler\n"
rethrow P5
.end

.sub "foo"
push_eh FOO_HANDLER
new $P1, .Exception
$P1["_message"] = "my_error_message"
throw $P1
clear_eh
.return()
FOO_HANDLER:
print "in foo handler\n"
rethrow P5
.end

Under 0.2.3 it prints

in foo handler
in main handler

before failing, which in my opinion is the expected behaviour. Under
0.3.0 it prints this before failing:

in foo handler
in main handler
in main handler

If you agree that the 0.3.0 behaviour is wrong, I'll file a bug report.

Regards,
Roger Browne

Leopold Toetsch

unread,
Oct 3, 2005, 10:48:45 AM10/3/05
to Roger Browne, Perl 6 Internals
Roger Browne wrote:

> Leo, did you change the handling of P5? I have some PIR code that works
> differently under 0.2.3 and 0.3.0:

The exception object iss still P5 in the handler, no changes here yet.

> If you agree that the 0.3.0 behaviour is wrong, I'll file a bug report.

But the MAIN_HANDLER is catching twice, which looks like a bug to me.

> Regards,
> Roger Browne

leo

Leopold Toetsch

unread,
Oct 3, 2005, 11:08:20 AM10/3/05
to Roger Browne, Perl 6 Internals
Roger Browne wrote:

> in foo handler
> in main handler
> in main handler

Fixed. Now the main handler catches just once.

> Regards,
> Roger Browne

Thanks for testing,
leo

0 new messages