I just did a bunch of commits, people might need a fresh checkout. Its a start for subroutines and co-routines. The keyword is 'start', not final product. The ops are call/callco, but these will become vtable entries for the 4 aforementioned sub types by Dan. David has some pending patches for PMC so I didn't want to get into any conflicts with that, so I'm waiting until he's done with the PMC cleanup.
I committed 2 examples to the examples/assembly directory, and I'll patch them inline here at the bottom. Warning: This is not the final convention, it is still up in the air. Dan has spec'd some of it out, but for now, we can work with this. The support isn't complete, for example, co-routines, etc. need to swap in their own context, which right now they don't do. Also we'll have to do fun stuff like copy return values off of the co's local stack onto the returnee's stack, unless someone has suggestion. I know JVM does something like this. However, you can write resumeable routines with the support that is there now. Have fun! -Melvin # Sample sub-routines in Parrot # # Create 2 subroutines # set_addr I0, SUB new P0, .ParrotSub, I0 save P0 new P0, .ParrotSub, I0 # Calling convention says P0 will contain the sub call restore P0 # Call second one call end # A subroutine address SUB: print "Hello subroutine\n" ################################ # Sample co-routines in Parrot # # Create 2 coroutines # set_addr I0, MYCOROUTINE new P0, .ParrotCoroutine, I0 save P0 new P0, .ParrotCoroutine, I0 # Calling convention says P0 will contain the sub so.. print "Calling 1st co-routine\n" callco callco callco restore P0 print "Calling 2nd co-routine\n" callco callco callco end # A coroutine MYCOROUTINE: print "Entry\n" yield print "Resumed\n" yield print "Done\n" ret