[LLVMdev] Researching alternative for home-grown VM

Chris Lattner sabre at nondot.org
Wed Mar 8 22:42:06 PST 2006

On Tue, 7 Mar 2006 renny.koshy at rubixinfotech.com wrote:
> I'm researching an alternative to our home-grown VM that is used for a
> telecomm system.  LLVM sounds like it fits the bill... however, one of the
> primary reasons for developing our home-grown VM was the concept of
> continuation.


> Basically, the code that folks write can call certain built-in functions of
> our "language".  These functions cause the VM to stop execution and save a
> "context".  Later on an event arriving at the VM and pick up the context,
> and continue execution of the code.


> => Is there a way to do this LLVM (i.e has anyone done this or something
> similar)?

Nope, not that I know of.

> => If not, can I implement it as a new op-code?  We basically have
> implemented a "WAIT" opcode in our VM, which tells it to stop execution of
> this code, and wait for external events.

How would this be implemented?  Could you just insert a call to wait() and 
have the implementation do the right thing?

> Let met give a more concrete example:
> The code may say:
>      status = sql_exec("Server1", Timeout, "select subscriberid from
> tblSubscriber where ANI='"+ani+"';", subscriberid);
> In this case, the sql_exec() is a built-in function of our language which
> sends a DB query, and then issues a "WAIT".  This allows the VM to then
> process another event which may execute some completely un-related code.
> Then when a db-response event arrives, since there is a mapping for that
> event, it will then startup processing of the sql_exect() at the point
> where it had issued the WAIT.

Sure, this seems straight-forward.  I would suggest just using an external 
function call to do this.



More information about the llvm-dev mailing list