StackReifier

class StackReifier(    actuallyReify: Boolean,     reificationStatistic: Statistic,     val postReificationAction: () -> Unit)

The level two execution machinery allows limited use of the Java stack during ordinary execution, but when exceptional conditions arise, the Java stack is unwound with a StackReifier and converted into level one continuations. This happens when the stack gets too deep, when tricky code like exceptions and backtracking happen, or when running a suspending primitive, including to add or remove methods.

Author

Mark van Gulik

Parameters

actuallyReify

Whether to reify the Java frames (rather than simply drop them).

reificationStatistic

The Statistic under which to record this reification once it completes. The timing of this event spans from this creation until just before the postReificationAction action runs.

postReificationAction

The action to perform after the Java stack has been fully reified.

Constructors

Link copied to clipboard
fun StackReifier(    actuallyReify: Boolean,     reificationStatistic: Statistic,     postReificationAction: () -> Unit)

Construct a new StackReifier.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun actuallyReify(): Boolean

Answer whether this StackReifier should cause reification (rather than just clearing the Java stack).

Link copied to clipboard
fun pushAction(action: (Interpreter) -> Unit)

Push an action on the actionStack. These will be executed in reverse order, after the Java call stack has been emptied.

Link copied to clipboard
fun pushContinuationAction(dummyContinuation: AvailObject): StackReifier

Push an action on the reifier's stack of actions. The action should run after previously run (but subsequently pushed) actions have had a chance to set up a caller's reified state. Take the supplied dummy continuation and push it on the reified stack, then run it. The run must complete normally – i.e., it must not trigger more reifications, or try to fall back to the default chunk.

Link copied to clipboard
fun recordCompletedReification(interpreterIndex: Int)

Record the fact that a reification has completed. The specific Statistic under which to record it was provided to the constructor.

Link copied to clipboard
fun runActions(interpreter: Interpreter)

Run the actions in reverse order to populate the Interpreter.getReifiedContinuation stack.

Properties

Link copied to clipboard
val postReificationAction: () -> Unit

A lambda that should be executed once the Interpreter's stack has been fully reified. For example, this might set up a function/chunk/offset in the interpreter. The interpreter will then determine if it should continue running.

Link copied to clipboard
val startNanos: Long

The System.nanoTime when this stack reifier was created.