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

extend.c:Parrot_call

6 views
Skip to first unread message

Leopold Toetsch

unread,
Oct 27, 2004, 6:43:51 AM10/27/04
to Perl 6 Internals
Parrot_call() runs a Parrot subroutine, but it takes PMC arguments only
and provides no return value.

If no one hollers, I'll replace this function with a more flexible set
of functions that are wrappers to the *runops* functions in src/inter_run.c:

void * Parrot_call_sub_(interp, sub, signature, ...) [1]
Parrot_Int Parrot_call_sub_ret_int
Parrot_Float Parrot_call_sub_ret_float

void * Parrot_call_meth(interp, sub, object, meth, sig, ...)
...

The signature of the current Parrot_call is "vPPP..."

[1] return values covered: void, Parrot_STRING, Parrot_PMC

leo

Jeff Horwitz

unread,
Oct 27, 2004, 10:48:15 AM10/27/04
to Leopold Toetsch, Perl 6 Internals
this would be great -- i'm currently pulling the return values of my
called subs directly out of I5, and it would be nice to have that bit
taken care of for me, especially if calling conventions change somewhere
down the line (but i certainly hope they don't). :)

-jeff

Leopold Toetsch

unread,
Oct 27, 2004, 12:21:53 PM10/27/04
to Jeff Horwitz, perl6-i...@perl.org
Jeff Horwitz <je...@sixgeeks.org> wrote:

[ Please don't top post ]

> this would be great -- i'm currently pulling the return values of my
> called subs directly out of I5, and it would be nice to have that bit
> taken care of for me, especially if calling conventions change somewhere
> down the line (but i certainly hope they don't). :)

Calling conventions don't change. But trying the get I5 or such from a
void function will not work anymore, because arguments and return values
are copied now.

E.g. when you have a sub that ends with:

set P5, 100 # ret value
set I0, 0 # non-prototyped
set I3, 0 # no return value
invoke P1 # return

then P5 will not be passed to the caller.

> -jeff

leo

Jeff Horwitz

unread,
Oct 27, 2004, 3:11:11 PM10/27/04
to Leopold Toetsch, perl6-i...@perl.org
On Wed, 27 Oct 2004, Leopold Toetsch wrote:

> E.g. when you have a sub that ends with:
>
> set P5, 100 # ret value
> set I0, 0 # non-prototyped
> set I3, 0 # no return value
> invoke P1 # return
>
> then P5 will not be passed to the caller.

right. but i'm explicitly using .pcc_begin_return/.return/.pcc_end_return
to return values from subs run with Parrot_call. my C code then
retrieves the return value from I5, which is where the return integer
value would be copied. your changes would save me from having to fetch
directly from I5, but until those changes are made, is this the "right
way" to be doing this?

-jeff

Leopold Toetsch

unread,
Oct 27, 2004, 3:57:06 PM10/27/04
to Jeff Horwitz, perl6-i...@perl.org

Yep that's ok. If the sub indicates an return value it is and will be
availabe, in your case as REG_INT(5) in C.

> -jeff

leo

Leopold Toetsch

unread,
Oct 28, 2004, 8:20:12 AM10/28/04
to Perl 6 Internals
Leopold Toetsch wrote:
> Parrot_call() runs a Parrot subroutine, but it takes PMC arguments only
> and provides no return value.
>
> If no one hollers, I'll replace this function with a more flexible set
> of functions that are wrappers to the *runops* functions in
> src/inter_run.c:
>
> void * Parrot_call_sub_(interp, sub, signature, ...) [1]
> Parrot_Int Parrot_call_sub_ret_int
> Parrot_Float Parrot_call_sub_ret_float
>
> void * Parrot_call_meth(interp, sub, object, meth, sig, ...)

Done that now. The latter is:

void * Parrot_call_method(interp, sub, object, meth, sig, ...)

and other 2 accordingly.

leo

0 new messages