Patch name: continuation.patch
This experimental implementation of continuation is an extension to the old version of callcc.patch (http://hg.openjdk.java.net/mlvm/mlvm/hotspot/rev/99e6c3830f6d). It is not based on the latest version of callcc.patch.
- implements a delimited continuation
- supports save/restore of compiled frames
- supports inter-thread save/restore
- is currently Linux/x86 and Linux/amd64 only
- is reasonably stable
This implementation was used in the work described by the JVM Language Summit 2010 talk titled "Continuation In Servers" (http://wiki.jvmlangsummit.com/Continuations_in_Servers) where the continuation feature is applied to increase the scalability of a synchronous I/O-based servers.
The current API looks like the following Javadoc style documentation.
There are the three following methods in the Continuation API.
It executes a given Runnable. This marks the entry of a scope. In other words, a enter call indicates the bottom of a scope. A scope (of stack frames) is the unit of stack frames that the save method saves and that the resume method resumes. The two methods must be called inside a scope.
Calling this method causes the stack frames in the current scope to be copied off of the current thread into a continuation object. At the same time, the current thread returns out of the scope (the enter call) without returning from the rest of the call chains in the scope.
Calling this method with a continuation object causes the current thread to abandon the call chains in the current scope and overwrite them with the ones from the saved scope. The current thread then resumes the execution of the saved call chains (scope) as if it is right after the save call at the time the scope was saved. A continuation is resumable only once.
An example of saving a continuation looks like the following:
The above program does not do much. It does not print the string in line 6. It only saves the continuation.
An example of resuming a continuation looks like the following:
A basic example of saving and resuming a continuation looks like the following:
See the continuation test files bundled with the patch. Or, go to http://cr.openjdk.java.net/~hiroshi/webrevs/continuation-jdk/.
It does not support monitors held or native stack frames inside a continuation scope at the time of a save call (if there is one, an exception will be thrown). It does not currently work with compressed oops in the 64 bit build.
|Work in progress|