Chapter 4. Extended State of the Virtual Machine

The implementation of some features of the XL programming language makes uses of an extended state of the virtual machine. This extended state is represented by an instance of de.grogra.xl.runtime.VMXState and exists for every thread of the current Java virtual machine. It can be obtained by the method invocation VMXState.current().

The extended state provides a stack similar to the stack of the Java virtual machine. Stack frames provide storage locations for local variables, which are represented by instances of the class VMXState.Local. The stack has the possibility of accessing enclosing stack frames which is needed, for example, by nested routines (and is not possible with the stack of the Java virtual machine). Though nested routines are not specified by the XL programming language explicitly, they are needed implicitly for the implementation of non-local generator invocations, namely generator method invocations and query invocations.

It is not mandatory that a compiler for the XL programming language generates code which makes use of the stack of the extended state for these language extensions, with two exceptions:

  1. Property variables (Section 7.1, “Property Variables”) are read and written in the context of the current extended state.

  2. As it will be discussed in Chapter 17, Queries, query variables (see Section 17.1, “Query Variables”) have to be represented by instances of VMXState.Local. Thus, they have to be stored on the stack of the extended state.