[comp.lang.c] Return Graph varies from Call Graph?

reid@cpswh.cps.msu.edu (Dr Richard J. Reid) (06/05/90)

Do you have any suggestions about how to vary the
return graph of function invocation from the call graph?

This capability would seem to be highly implementation dependent;
however, any suggestions of more universal applicability
than permuting the invocation frames on the stack, would be
especially welcome.

Example:  (For a simple linear graph)

  Given the call sequence:     A -> B -> C -> D

  Can the return sequence be:  A <- C <- B <- D  ?

Thanks,

Dick

ark@alice.UUCP (Andrew Koenig) (06/06/90)

In article <1990Jun5.142836.9821@msuinfo.cl.msu.edu>, reid@cpswh.cps.msu.edu (Dr Richard J. Reid) writes:

> Do you have any suggestions about how to vary the
> return graph of function invocation from the call graph?

Before we think about `how,' perhaps you could give
us a few clues about `why.'
-- 
				--Andrew Koenig
				  ark@europa.att.com

jharkins@sagpd1.UUCP (Jim Harkins) (06/07/90)

In article <1990Jun5.142836.9821@msuinfo.cl.msu.edu> reid@cpswh.cps.msu.edu (Dr Richard J. Reid) writes:
>Do you have any suggestions about how to vary the
>return graph of function invocation from the call graph?

Lots of them, but this is a family newgroup :-)

>  Given the call sequence:     A -> B -> C -> D
>
>  Can the return sequence be:  A <- C <- B <- D  ?

I don't really see why you would want to do this.  If you did do it I think
that, once maintanance is factored in, you're much better off coming up with a
better algorithm for what you're trying to do.

A slightly more palatable thing to do would be to change the return sequence
to A <- B <- D (using your call sequence).  Then all you do is figure out how
many doo hickeys get put onto the stack when your C compiler does a function
call (can you say 'implementation dependent'.  I knew you could), then write
some in-line assembly to adjust the stack pointer.  Me?  If I ended up
maintaining code that did this sort of thing I'd look for a bucket of tar and
some feathers.

-- 
jim		jharkins@sagpd1

I hate to see you go, but I love to see you walk away.

reid@cpswh.uucp (Dr Richard J. Reid) (06/08/90)

In article <10904@alice.UUCP> ark@alice.UUCP (Andrew Koenig) writes:
>In article <1990Jun5.142836.9821@msuinfo.cl.msu.edu>, reid@cpswh.cps.msu.edu (Dr Richard J. Reid) writes:
>
>> Do you have any suggestions about how to vary the
>> return graph of function invocation from the call graph?
>
>Before we think about `how,' perhaps you could give
>us a few clues about `why.'
>-- 
>				--Andrew Koenig
>				  ark@europa.att.com

Why example:  Implementation of Co-routining.  See, for example,
AT&T tasking library for C++.

Dick

karl@haddock.ima.isc.com (Karl Heuer) (06/11/90)

In article <1990Jun8.121558.6976@msuinfo.cl.msu.edu> reid@cpswh.uucp (Dr Richard J. Reid) writes:
>>> Do you have any suggestions about how to vary the
>>> return graph of function invocation from the call graph?
>
>Why example:  Implementation of Co-routining.

I've written C code containing coroutines.  Rather than trying to muck around
with the stack, which is clearly unportable, I just maintained state
information in static variables and used goto.

Karl W. Z. Heuer (karl@ima.ima.isc.com or harvard!ima!karl), The Walking Lint