[Frank Lhota wrote suggesting we allocate generator state from the block
region
instead of the C stack, and wondered if we could get rid of coswitch() if
we did.]
I believe that there is a substantial research opportunity for
reducing/simplifying simple
generators into non-generator format. Iconc does some of this for special
cases, but
does not do it aggressively. The suggestion of storing generator state in
the block
region is a nice one that would work well for simple generators.
More generally, generators store more than just local variables on the C
stack, they
store the program counter or control-context needed to continue execution of
the
generator forward from where it suspended; storing that in the block region
is possible but is
challenging when it is spread across several layers of C functions. Encoding
a chain of C
function calls and goto-locations within them where they should be resumed
would be messy.
Would this eliminate the need for coswitch? No, coswitch is not even used
in the
generator suspension and resumption mechanism, it is used in the
co-expression switch
mechanism. Fixing generators as you describe would improve our "spaghetti
stack"
execution model within a single co-expression, but is largely independent of
whether we
support multiple stacks for independent computations, which is what
co-expressions do.
If you want to eliminate coswitch, our last piece of assembler code, a
portable way to
do it would be to implement co-expression switch atop a standard such as
POSIX threads.
I believe in principle Wenyi Zhou did that for me several years back, and we
tested it and
it was much much slower than the native coexpression switch codes we use,
but it would
provide at least a measure of platform independence, for any platform that
supports POSIX
but for which we don't have a native coswitch.
Well, those are my two cents. I might be wrong and would welcome a
demonstration
to the contrary. I think you point out a tremendous
optimization opportunity for simple generators, that would be hard to do
for every generator and every evaluation context in the VM.
Cheers,
Clint
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Unicon-group mailing list
Unicon-group@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/unicon-group