[LLVMdev] Stack switching, Active Objects and LLVM
sabre at nondot.org
Sun Jan 14 13:29:59 CST 2007
On Mon, 8 Jan 2007, Sriram Srinivasan wrote:
> I wish to have lots of little stacks and be able to switch rapidly
> between them. I could do CPS transformation but don't like the overhead
> of creating gc'able continuation thunks and the copying from stack to
> I'd like to explore a no-copy approach by "merely" switching a few
> registers, perhaps as an equivalent of the C-- "jump" instruction (as
> opposed to call). In other words, if a function calls "pause()", I'd
> like to freeze the stack and be able to resume the thread at some time,
> like green threads but faster (one shouldn't have to save all registers
> blindly). I would appreciate some pointers on what it take to do this in
This sounds quite doable. There are two ways you can approach this.
If you don't care about portability, you can use standard inline asm to
achieve this. This works if your front-end is willing to handle knowing
what to generate for each target.
If you don't like this approach, you can add an llvm intrinsics, which is
expanded by the code generator to the right code for the current target.
More information about the LLVMdev