Skip to content

Call/cc branch merge + integration with CallContext#runUntilDone

I merged previous top level loop into the CallContext#runUntilDone loop, without changing too much logic. For the moment basic Procedure instances are passed into CallContext#setupApply, ie without overriding default MethodHandle applyToConsumer; I haven't investigated what that more efficient override should be. As far as I understand, exceptions still must be used -- even with TCO trampoline, there is still a stack of non-tail calls and therefore multiple instances (at different stack levels) of runUntilDone method running. Invoking continuation should return to the first / lowest instance of runUntilDone, which I've achieved by retaining exception logic, and tracking runUntilDone indexing (using depth field).

One unsolved issue, is that when declaring a class, init-form keyword for field doesn't work, for whatever reason (jvm throws java.lang.VerifyError: Bad type on operand stack in putfield). Workaround is to initialize field inside init.

I uploaded small benchmark at https://gitlab.com/nma.arvydas.silanskas/kawa-callcc-benchmark , including all jars I used for benchmarking as well as benchmarking results (.log files). Running with new version without --full-continuations flag (callcc_none.log) produces same timing as running old version on master branch (master.log). Running with the flag (callcc_full.log) gives ~3-5 time slowdown. Using reentrant continuations to model a generator (ie what was impossible before) is about ~30 times slower than using simple function with closed over state.

Edited by Arvydas Silanskas

Merge request reports