Re: [Sablevm-developer] Continuations
Brought to you by:
egagnon
From: Etienne M. G. <eg...@j-...> - 2000-07-20 05:23:58
|
Hi Brent. > I was thinking that it would probably be possible to simulate > continuations at the JVM level by using the same mechanisms that > are used for the exception handling. I'm not sure if this is an > efficient way to go about this, but in theory it should work. I doubt this would work. Reasons: 1- At the bytecode level, exception handling is expressed quite differently from Java source. 2- If I remember my high level programming languages course correctly, the whole point of a continuation is to capture a snapshot of the "current" stack, so that you can later execute code in this same context, even if the current stack is unwinded. In ML (or some dialect?) that allowed implementing "static binding" instead of "dynamic binding" a la LISP. The consequence is that the method in which the "create snapshot" occurs might return before you "resume" and execute the continuation. In which case your scheme wouldn't work, unfortunately. Please let me know if I am completely off track. (Quite possible!) In fact, can you write for me a simple example that requires continuation? See below for additional questions. > 3. JVM creates an exception that holds the current state of > this routine (i.e., must make a copy of the current variables) What is in the "saved" state? - current stack frame? - stack (all frames) of current thread? - global variables (e.g. static fields)? - other stacks (stack of other threads)? - heap state (object instances? - other vm internal state (locks, ...)? Etienne -- ---------------------------------------------------------------------- Etienne M. Gagnon, M.Sc. e-mail: eg...@j-... Author of SableVM: http://www.sablevm.org/ ---------------------------------------------------------------------- |