VMXState is associated with a single
Thread. It provides a stack (consisting of frames) and some other features to be used
exclusively within the context of this thread.
A VMXState can be seen as an extension of the per-thread state
that a Java virtual machine maintains. This per-thread state contains
a stack. However, this stack can only be accessed by instructions
for the Java virtual machine, not by method invocations, and it
is a purely local stack without the possibility to access stack frames
of other method invocations than the current one.
Some features of the XL programming language, e.g., invocations
of generator methods, require nested routines and a stack with
support for access of stack frame of statically containing routine
invocations. The stack
of a VMXState provides such support; implementations of
these features of the XL programming language can make use of the
stack of the current thread's VMXState.
A VMXState has a stack pointer
sp, a "Java frame pointer" jfp, and
a frame for the current routine invocation getFrame(Authorization).
Each frame has a VMXState.VMXFrame.staticLink to the frame
of statically containing routine invocation.
The stack frame of the statically containing routine invocation
is the stack frame belonging to the nearest invocation of the
containing (i.e., the textually enclosing) routine of the current routine.
As for the Java virtual machine, values of the types long
and double occupy two consecutive elements of the stack,
values of the other types occupy a single element.
- Author:
- Ole Kniemeyer
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classThis class represents a local variable.final class -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionaget(VMXState.Local local, Authorization auth) Returns the value of the stack element corresponding tolocal.static Objectaget(VMXState vmx, int nesting, int index, Authorization auth) Returns the value of the stack elementindexof thenesting-th statically containing frame.agetj(int index, Authorization auth) Returns the value of the stack elementindexof the current Java frame.apeek()Returns the topmost value from the stack without popping if off the stack.apeek(int index) Returns theindex-th value from the top of the stack, i.e., the value with absolute addresssp - index.apop()Pops the topmost value from the stack.voidPushs the givenvalueon top of the stack.Returns an instance ofAbruptCompletion.Return.voidaset(VMXState.Local local, Object value, Authorization auth) Sets the stack element corresponding tolocaltovalue.static voidaset(Object value, VMXState vmx, int nesting, int index, Authorization auth) Sets the stack elementindexof thenesting-th statically containing frame tovalue.voidasetj(int index, Object value, Authorization auth) Sets the stack elementindexof the current Java frame tovalue.createDescriptor(Routine routine, int nesting, Authorization auth) Returns a descriptor for a routine invocation.static VMXStatecurrent()Returns the VMXState for the current thread.doubledget(VMXState.Local local, Authorization auth) Returns the value of the stack element corresponding tolocal.static doubledget(VMXState vmx, int nesting, int index, Authorization auth) Returns the value of the stack elementindexof thenesting-th statically containing frame.doubledgetj(int index, Authorization auth) Returns the value of the stack elementindexof the current Java frame.doubledpeek()Returns the topmost value from the stack without popping if off the stack.doubledpeek(int index) Returns theindex-th value from the top of the stack, i.e., the value with absolute addresssp - index.doubledpop()Pops the topmost value from the stack.voiddpush(double value) Pushs the givenvalueon top of the stack.dreturn(double value) Returns an instance ofAbruptCompletion.Return.static voiddset(double value, VMXState vmx, int nesting, int index, Authorization auth) Sets the stack elementindexof thenesting-th statically containing frame tovalue.voiddset(VMXState.Local local, double value, Authorization auth) Sets the stack element corresponding tolocaltovalue.voiddsetj(int index, double value, Authorization auth) Sets the stack elementindexof the current Java frame tovalue.voidenter(int frameSize, Authorization auth) floatfget(VMXState.Local local, Authorization auth) Returns the value of the stack element corresponding tolocal.static floatfget(VMXState vmx, int nesting, int index, Authorization auth) Returns the value of the stack elementindexof thenesting-th statically containing frame.floatfgetj(int index, Authorization auth) Returns the value of the stack elementindexof the current Java frame.floatfpeek()Returns the topmost value from the stack without popping if off the stack.floatfpeek(int index) Returns theindex-th value from the top of the stack, i.e., the value with absolute addresssp - index.floatfpop()Pops the topmost value from the stack.voidfpush(float value) Pushs the givenvalueon top of the stack.freturn(float value) Returns an instance ofAbruptCompletion.Return.static voidfset(float value, VMXState vmx, int nesting, int index, Authorization auth) Sets the stack elementindexof thenesting-th statically containing frame tovalue.voidfset(VMXState.Local local, float value, Authorization auth) Sets the stack element corresponding tolocaltovalue.voidfsetj(int index, float value, Authorization auth) Sets the stack elementindexof the current Java frame tovalue.getFrame(Authorization auth) Returns the current stack pointer for the static-link stack.intgetId()Returns a unique id for this VMXState.intiget(VMXState.Local local, Authorization auth) Returns the value of the stack element corresponding tolocal.static intiget(VMXState vmx, int nesting, int index, Authorization auth) Returns the value of the stack elementindexof thenesting-th statically containing frame.intigetj(int index, Authorization auth) Returns the value of the stack elementindexof the current Java frame.Invokes the givenmethodusing parameters popped from the stack.invoke(Routine routine, int nesting, Authorization auth) Creates a new stack frame and invokes the givenroutine.invokeInFrame(MatchConsumer consumer, Frame frame) intipeek()Returns the topmost value from the stack without popping if off the stack.intipeek(int index) Returns theindex-th value from the top of the stack, i.e., the value with absolute addresssp - index.intipop()Pops the topmost value from the stack.voidipush(int value) Pushs the givenvalueon top of the stack.ireturn(int value) Returns an instance ofAbruptCompletion.Return.static voidiset(int value, VMXState vmx, int nesting, int index, Authorization auth) Sets the stack elementindexof thenesting-th statically containing frame tovalue.voidiset(VMXState.Local local, int value, Authorization auth) Sets the stack element corresponding tolocaltovalue.voidisetj(int index, int value, Authorization auth) Sets the stack elementindexof the current Java frame tovalue.voidleave(Authorization auth) longlget(VMXState.Local local, Authorization auth) Returns the value of the stack element corresponding tolocal.static longlget(VMXState vmx, int nesting, int index, Authorization auth) Returns the value of the stack elementindexof thenesting-th statically containing frame.longlgetj(int index, Authorization auth) Returns the value of the stack elementindexof the current Java frame.longlpeek()Returns the topmost value from the stack without popping if off the stack.longlpeek(int index) Returns theindex-th value from the top of the stack, i.e., the value with absolute addresssp - index.longlpop()Pops the topmost value from the stack.voidlpush(long value) Pushs the givenvalueon top of the stack.lreturn(long value) Returns an instance ofAbruptCompletion.Return.static voidlset(long value, VMXState vmx, int nesting, int index, Authorization auth) Sets the stack elementindexof thenesting-th statically containing frame tovalue.voidlset(VMXState.Local local, long value, Authorization auth) Sets the stack element corresponding tolocaltovalue.voidlsetj(int index, long value, Authorization auth) Sets the stack elementindexof the current Java frame tovalue.newBreak(int label) Returns an instance ofAbruptCompletion.Break.newNonlocal(int nesting, AbruptCompletion reason, Authorization auth) Returns an instance ofAbruptCompletion.Nonlocal.Returns an instance ofAbruptCompletion.Return.Returns an instance ofAbruptCompletion.Throw.int[]peekIntArray(int length) voidpop(int size) Pops and discardssizeelements from the stack.int[]popIntArray(int length) Popslengthvalues of typeintfrom the stack and returns them as an array.vreturn()Returns an instance ofAbruptCompletion.Return.
-
Field Details
-
INT_0
public static final int[] INT_0
-
-
Method Details
-
enter
-
leave
-
getId
public int getId()Returns a unique id for this VMXState. The id is unique within the scope of the current Java virtual machine.- Returns:
- a unique id
-
current
Returns the VMXState for the current thread.- Returns:
- the current VMXState
-
getFrame
Returns the current stack pointer for the static-link stack.- Returns:
- current static-link stack pointer
-
invoke
Creates a new stack frame and invokes the givenroutine. This method proceeds as follows:-
It is assumed that
routine.getParameterSize()stack elements have been pushed on the stack. These are used as the parameters for the routine invocation. -
If
routine.hasJavaParameters()returnstrue, the Java frame pointer is set to point to the stack element of the first parameter. The frame pointer is set to point behind the Java frame (which has a total size ofroutine.getJavaFrameSize()). The stack pointer is set to point behind the frame (which has a total size ofroutine.getFrameSize()). Otherwise, ifroutine.hasJavaParameters()returnsfalse, the pointers are modified correspondingly, with the roles of the frame and the Java frame exchanged. -
A new element is pushed on the static-link stack.
nestingis used in this step. Its value has to be-
0 if the invoking routine and the invoked
routineare statically contained in the same routine (i.e., their immediately enclosing routine is the same), -
n if the invoked
routineis the n-th statically containing routine of the invoking routine, - -1 otherwise.
-
0 if the invoking routine and the invoked
-
The method
routine.executeis invoked. - All modifications to the stack pointers are undone, the routine parameters are popped from the stack. This step happens even in the case of an exception.
- Parameters:
routine- the routine to be invokednesting- the nesting of the invoking routine within the invoked routine- Returns:
- the returned value of
routine.execute
-
It is assumed that
-
isetj
Sets the stack elementindexof the current Java frame tovalue. -
igetj
Returns the value of the stack elementindexof the current Java frame.- Returns:
- stack element at
index
-
iset
Sets the stack elementindexof thenesting-th statically containing frame tovalue. -
iget
Returns the value of the stack elementindexof thenesting-th statically containing frame.- Returns:
- stack element at
index
-
iset
Sets the stack element corresponding tolocaltovalue. -
iget
Returns the value of the stack element corresponding tolocal.- Returns:
- stack element for
local
-
ipush
public void ipush(int value) Pushs the givenvalueon top of the stack. -
ipop
public int ipop()Pops the topmost value from the stack.- Returns:
- the popped stack element
-
ipeek
public int ipeek()Returns the topmost value from the stack without popping if off the stack.- Returns:
- the topmost stack element
-
ipeek
public int ipeek(int index) Returns theindex-th value from the top of the stack, i.e., the value with absolute addresssp - index.- Returns:
- the
index-th value from the top of the stack
-
lsetj
Sets the stack elementindexof the current Java frame tovalue. -
lgetj
Returns the value of the stack elementindexof the current Java frame.- Returns:
- stack element at
index
-
lset
Sets the stack elementindexof thenesting-th statically containing frame tovalue. -
lget
Returns the value of the stack elementindexof thenesting-th statically containing frame.- Returns:
- stack element at
index
-
lset
Sets the stack element corresponding tolocaltovalue. -
lget
Returns the value of the stack element corresponding tolocal.- Returns:
- stack element for
local
-
lpush
public void lpush(long value) Pushs the givenvalueon top of the stack. -
lpop
public long lpop()Pops the topmost value from the stack.- Returns:
- the popped stack element
-
lpeek
public long lpeek()Returns the topmost value from the stack without popping if off the stack.- Returns:
- the topmost stack element
-
lpeek
public long lpeek(int index) Returns theindex-th value from the top of the stack, i.e., the value with absolute addresssp - index.- Returns:
- the
index-th value from the top of the stack
-
fsetj
Sets the stack elementindexof the current Java frame tovalue. -
fgetj
Returns the value of the stack elementindexof the current Java frame.- Returns:
- stack element at
index
-
fset
Sets the stack elementindexof thenesting-th statically containing frame tovalue. -
fget
Returns the value of the stack elementindexof thenesting-th statically containing frame.- Returns:
- stack element at
index
-
fset
Sets the stack element corresponding tolocaltovalue. -
fget
Returns the value of the stack element corresponding tolocal.- Returns:
- stack element for
local
-
fpush
public void fpush(float value) Pushs the givenvalueon top of the stack. -
fpop
public float fpop()Pops the topmost value from the stack.- Returns:
- the popped stack element
-
fpeek
public float fpeek()Returns the topmost value from the stack without popping if off the stack.- Returns:
- the topmost stack element
-
fpeek
public float fpeek(int index) Returns theindex-th value from the top of the stack, i.e., the value with absolute addresssp - index.- Returns:
- the
index-th value from the top of the stack
-
dsetj
Sets the stack elementindexof the current Java frame tovalue. -
dgetj
Returns the value of the stack elementindexof the current Java frame.- Returns:
- stack element at
index
-
dset
Sets the stack elementindexof thenesting-th statically containing frame tovalue. -
dget
Returns the value of the stack elementindexof thenesting-th statically containing frame.- Returns:
- stack element at
index
-
dset
Sets the stack element corresponding tolocaltovalue. -
dget
Returns the value of the stack element corresponding tolocal.- Returns:
- stack element for
local
-
dpush
public void dpush(double value) Pushs the givenvalueon top of the stack. -
dpop
public double dpop()Pops the topmost value from the stack.- Returns:
- the popped stack element
-
dpeek
public double dpeek()Returns the topmost value from the stack without popping if off the stack.- Returns:
- the topmost stack element
-
dpeek
public double dpeek(int index) Returns theindex-th value from the top of the stack, i.e., the value with absolute addresssp - index.- Returns:
- the
index-th value from the top of the stack
-
asetj
Sets the stack elementindexof the current Java frame tovalue. -
agetj
Returns the value of the stack elementindexof the current Java frame.- Returns:
- stack element at
index
-
aset
Sets the stack elementindexof thenesting-th statically containing frame tovalue. -
aget
Returns the value of the stack elementindexof thenesting-th statically containing frame.- Returns:
- stack element at
index
-
aset
Sets the stack element corresponding tolocaltovalue. -
aget
Returns the value of the stack element corresponding tolocal.- Returns:
- stack element for
local
-
apush
Pushs the givenvalueon top of the stack. -
apop
Pops the topmost value from the stack.- Returns:
- the popped stack element
-
apeek
Returns the topmost value from the stack without popping if off the stack.- Returns:
- the topmost stack element
-
apeek
Returns theindex-th value from the top of the stack, i.e., the value with absolute addresssp - index.- Returns:
- the
index-th value from the top of the stack
-
pop
public void pop(int size) Pops and discardssizeelements from the stack.- Parameters:
size- the number of elements to pop
-
invokeInFrame
-
newReturn
Returns an instance ofAbruptCompletion.Return. This instance can be used until itsdispose-method is invoked, which marks the instance as available for later re-use.- Returns:
- an instance of
AbruptCompletion.Return
-
newBreak
Returns an instance ofAbruptCompletion.Break. This instance can be used until itsdispose-method is invoked, which marks the instance as available for later re-use.- Parameters:
label- the break label- Returns:
- an instance of
AbruptCompletion.Break
-
newThrow
Returns an instance ofAbruptCompletion.Throw. This instance can be used until itsdispose-method is invoked, which marks the instance as available for later re-use.- Parameters:
cause- the cause- Returns:
- an instance of
AbruptCompletion.Throw
-
ireturn
Returns an instance ofAbruptCompletion.Return. This instance can be used until itsdispose-method is invoked, which marks the instance as available for later re-use. The value of the instance is set to the givenvalue.- Parameters:
value- the returned value- Returns:
- an instance of
AbruptCompletion.Returnwith the givenvalue
-
lreturn
Returns an instance ofAbruptCompletion.Return. This instance can be used until itsdispose-method is invoked, which marks the instance as available for later re-use. The value of the instance is set to the givenvalue.- Parameters:
value- the returned value- Returns:
- an instance of
AbruptCompletion.Returnwith the givenvalue
-
freturn
Returns an instance ofAbruptCompletion.Return. This instance can be used until itsdispose-method is invoked, which marks the instance as available for later re-use. The value of the instance is set to the givenvalue.- Parameters:
value- the returned value- Returns:
- an instance of
AbruptCompletion.Returnwith the givenvalue
-
dreturn
Returns an instance ofAbruptCompletion.Return. This instance can be used until itsdispose-method is invoked, which marks the instance as available for later re-use. The value of the instance is set to the givenvalue.- Parameters:
value- the returned value- Returns:
- an instance of
AbruptCompletion.Returnwith the givenvalue
-
areturn
Returns an instance ofAbruptCompletion.Return. This instance can be used until itsdispose-method is invoked, which marks the instance as available for later re-use. The value of the instance is set to the givenvalue.- Parameters:
value- the returned value- Returns:
- an instance of
AbruptCompletion.Returnwith the givenvalue
-
newNonlocal
public AbruptCompletion.Nonlocal newNonlocal(int nesting, AbruptCompletion reason, Authorization auth) Returns an instance ofAbruptCompletion.Nonlocal. This instance can be used until itsdispose-method is invoked, which marks the instance as available for later re-use.- Parameters:
nesting- the nesting of the target routine within the invoked routinereason- the reason of the nonlocal abrupt completion- Returns:
- an instance of
AbruptCompletion.Nonlocal
-
vreturn
Returns an instance ofAbruptCompletion.Return. This instance can be used until itsdispose-method is invoked, which marks the instance as available for later re-use.- Returns:
- an instance of
AbruptCompletion.Returnwith avoidreturn value
-
popIntArray
public int[] popIntArray(int length) Popslengthvalues of typeintfrom the stack and returns them as an array. The first popped element is placed in the last component of the array and so on. The returned array can only be used safely until the next invocation of this method on the sameVMXState.- Parameters:
length- the number of values to be popped- Returns:
- an array containing the
lengthpopped values
-
peekIntArray
public int[] peekIntArray(int length) -
invoke
Invokes the givenmethodusing parameters popped from the stack. The returned value is wrapped in an instance ofAbruptCompletion.Return. Checked exceptions are wrapped in an instance ofAbruptCompletion.Throwwhich is then thrown.- Parameters:
method- the method to invoke- Returns:
- the method's return value
-
createDescriptor
Returns a descriptor for a routine invocation. This method returns a descriptor for the later invocation of the givenroutine. The parameters have to be set as ininvoke(Routine, int, Authorization), however, theroutineis not invoked immediately, but later on by methods declared inRoutineDescriptor. This later invocation happens in an equal frame context as for the immediate invocation byinvoke(Routine, int, Authorization).- Parameters:
routine- the routine to be invoked later onnesting- the nesting of the invoking routine within the invoked routine- Returns:
- a descriptor for the specified routine incarnation
-