de.grogra.xl.vmx
public final class VMXState extends java.lang.Object
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 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.
| Modifier and Type | Class and Description |
|---|---|
static class |
VMXState.Local
This class represents a local variable.
|
class |
VMXState.MatchConsumerInFrame |
| Modifier and Type | Field and Description |
|---|---|
static int[] |
INT_0 |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
aget(VMXState.Local local,
Authorization auth)
Returns the value of the stack element corresponding
to
local. |
static java.lang.Object |
aget(VMXState vmx,
int nesting,
int index,
Authorization auth)
Returns the value of the stack element
index
of the nesting-th statically containing frame. |
java.lang.Object |
agetj(int index,
Authorization auth)
Returns the value of the stack element
index
of the current Java frame. |
java.lang.Object |
apeek()
Returns the topmost value from the stack without popping if
off the stack.
|
java.lang.Object |
apeek(int index)
Returns the
index-th value from the top of the stack,
i.e., the value with absolute address sp - index. |
java.lang.Object |
apop()
Pops the topmost value from the stack.
|
void |
apush(java.lang.Object value)
Pushs the given
value on top of the stack. |
AbruptCompletion.Return |
areturn(java.lang.Object value)
Returns an instance of
AbruptCompletion.Return. |
static void |
aset(java.lang.Object value,
VMXState vmx,
int nesting,
int index,
Authorization auth)
Sets the stack element
index of the
nesting-th statically containing frame to value. |
void |
aset(VMXState.Local local,
java.lang.Object value,
Authorization auth)
Sets the stack element corresponding to
local
to value. |
void |
asetj(int index,
java.lang.Object value,
Authorization auth)
Sets the stack element
index of the
current Java frame to value. |
RoutineDescriptor |
createDescriptor(Routine routine,
int nesting,
Authorization auth)
Returns a descriptor for a routine invocation.
|
static VMXState |
current()
Returns the VMXState for the current thread.
|
double |
dget(VMXState.Local local,
Authorization auth)
Returns the value of the stack element corresponding
to
local. |
static double |
dget(VMXState vmx,
int nesting,
int index,
Authorization auth)
Returns the value of the stack element
index
of the nesting-th statically containing frame. |
double |
dgetj(int index,
Authorization auth)
Returns the value of the stack element
index
of the current Java frame. |
double |
dpeek()
Returns the topmost value from the stack without popping if
off the stack.
|
double |
dpeek(int index)
Returns the
index-th value from the top of the stack,
i.e., the value with absolute address sp - index. |
double |
dpop()
Pops the topmost value from the stack.
|
void |
dpush(double value)
Pushs the given
value on top of the stack. |
AbruptCompletion.Return |
dreturn(double value)
Returns an instance of
AbruptCompletion.Return. |
static void |
dset(double value,
VMXState vmx,
int nesting,
int index,
Authorization auth)
Sets the stack element
index of the
nesting-th statically containing frame to value. |
void |
dset(VMXState.Local local,
double value,
Authorization auth)
Sets the stack element corresponding to
local
to value. |
void |
dsetj(int index,
double value,
Authorization auth)
Sets the stack element
index of the
current Java frame to value. |
void |
enter(int frameSize,
Authorization auth) |
float |
fget(VMXState.Local local,
Authorization auth)
Returns the value of the stack element corresponding
to
local. |
static float |
fget(VMXState vmx,
int nesting,
int index,
Authorization auth)
Returns the value of the stack element
index
of the nesting-th statically containing frame. |
float |
fgetj(int index,
Authorization auth)
Returns the value of the stack element
index
of the current Java frame. |
float |
fpeek()
Returns the topmost value from the stack without popping if
off the stack.
|
float |
fpeek(int index)
Returns the
index-th value from the top of the stack,
i.e., the value with absolute address sp - index. |
float |
fpop()
Pops the topmost value from the stack.
|
void |
fpush(float value)
Pushs the given
value on top of the stack. |
AbruptCompletion.Return |
freturn(float value)
Returns an instance of
AbruptCompletion.Return. |
static void |
fset(float value,
VMXState vmx,
int nesting,
int index,
Authorization auth)
Sets the stack element
index of the
nesting-th statically containing frame to value. |
void |
fset(VMXState.Local local,
float value,
Authorization auth)
Sets the stack element corresponding to
local
to value. |
void |
fsetj(int index,
float value,
Authorization auth)
Sets the stack element
index of the
current Java frame to value. |
Frame |
getFrame(Authorization auth)
Returns the current stack pointer for the static-link stack.
|
int |
getId()
Returns a unique id for this VMXState.
|
int |
iget(VMXState.Local local,
Authorization auth)
Returns the value of the stack element corresponding
to
local. |
static int |
iget(VMXState vmx,
int nesting,
int index,
Authorization auth)
Returns the value of the stack element
index
of the nesting-th statically containing frame. |
int |
igetj(int index,
Authorization auth)
Returns the value of the stack element
index
of the current Java frame. |
AbruptCompletion.Return |
invoke(Method method)
Invokes the given
method using parameters popped
from the stack. |
AbruptCompletion.Return |
invoke(Routine routine,
int nesting,
Authorization auth)
Creates a new stack frame and invokes the given
routine. |
VMXState.MatchConsumerInFrame |
invokeInFrame(MatchConsumer consumer,
Frame frame) |
int |
ipeek()
Returns the topmost value from the stack without popping if
off the stack.
|
int |
ipeek(int index)
Returns the
index-th value from the top of the stack,
i.e., the value with absolute address sp - index. |
int |
ipop()
Pops the topmost value from the stack.
|
void |
ipush(int value)
Pushs the given
value on top of the stack. |
AbruptCompletion.Return |
ireturn(int value)
Returns an instance of
AbruptCompletion.Return. |
static void |
iset(int value,
VMXState vmx,
int nesting,
int index,
Authorization auth)
Sets the stack element
index of the
nesting-th statically containing frame to value. |
void |
iset(VMXState.Local local,
int value,
Authorization auth)
Sets the stack element corresponding to
local
to value. |
void |
isetj(int index,
int value,
Authorization auth)
Sets the stack element
index of the
current Java frame to value. |
void |
leave(Authorization auth) |
long |
lget(VMXState.Local local,
Authorization auth)
Returns the value of the stack element corresponding
to
local. |
static long |
lget(VMXState vmx,
int nesting,
int index,
Authorization auth)
Returns the value of the stack element
index
of the nesting-th statically containing frame. |
long |
lgetj(int index,
Authorization auth)
Returns the value of the stack element
index
of the current Java frame. |
long |
lpeek()
Returns the topmost value from the stack without popping if
off the stack.
|
long |
lpeek(int index)
Returns the
index-th value from the top of the stack,
i.e., the value with absolute address sp - index. |
long |
lpop()
Pops the topmost value from the stack.
|
void |
lpush(long value)
Pushs the given
value on top of the stack. |
AbruptCompletion.Return |
lreturn(long value)
Returns an instance of
AbruptCompletion.Return. |
static void |
lset(long value,
VMXState vmx,
int nesting,
int index,
Authorization auth)
Sets the stack element
index of the
nesting-th statically containing frame to value. |
void |
lset(VMXState.Local local,
long value,
Authorization auth)
Sets the stack element corresponding to
local
to value. |
void |
lsetj(int index,
long value,
Authorization auth)
Sets the stack element
index of the
current Java frame to value. |
AbruptCompletion.Break |
newBreak(int label)
Returns an instance of
AbruptCompletion.Break. |
AbruptCompletion.Nonlocal |
newNonlocal(int nesting,
AbruptCompletion reason,
Authorization auth)
Returns an instance of
AbruptCompletion.Nonlocal. |
AbruptCompletion.Return |
newReturn()
Returns an instance of
AbruptCompletion.Return. |
AbruptCompletion.Throw |
newThrow(java.lang.Throwable cause)
Returns an instance of
AbruptCompletion.Throw. |
int[] |
peekIntArray(int length) |
void |
pop(int size)
Pops and discards
size elements from the stack. |
int[] |
popIntArray(int length)
Pops
length values of type int from the
stack and returns them as an array. |
AbruptCompletion.Return |
vreturn()
Returns an instance of
AbruptCompletion.Return. |
public java.lang.Object aget(VMXState.Local local, Authorization auth)
local.localpublic static java.lang.Object aget(VMXState vmx, int nesting, int index, Authorization auth)
index
of the nesting-th statically containing frame.indexpublic java.lang.Object agetj(int index,
Authorization auth)
index
of the current Java frame.indexpublic java.lang.Object apeek()
public java.lang.Object apeek(int index)
index-th value from the top of the stack,
i.e., the value with absolute address sp - index.index-th value from the top of the stackpublic java.lang.Object apop()
public void apush(java.lang.Object value)
value on top of the stack.public AbruptCompletion.Return areturn(java.lang.Object value)
AbruptCompletion.Return. This instance can be used
until its dispose-method is invoked, which marks
the instance as available for later re-use. The value of the
instance is set to the given value.value - the returned valueAbruptCompletion.Return with the given valuepublic static void aset(java.lang.Object value,
VMXState vmx,
int nesting,
int index,
Authorization auth)
index of the
nesting-th statically containing frame to value.public void aset(VMXState.Local local, java.lang.Object value, Authorization auth)
local
to value.public void asetj(int index,
java.lang.Object value,
Authorization auth)
index of the
current Java frame to value.public RoutineDescriptor createDescriptor(Routine routine, int nesting, Authorization auth)
routine. The parameters have to be set as in
invoke(Routine, int, Authorization), however, the routine
is not invoked immediately, but later on by methods declared
in RoutineDescriptor. This later invocation happens in
an equal frame context as for the immediate invocation by
invoke(Routine, int, Authorization).routine - the routine to be invoked later onnesting - the nesting of the invoking routine within the invoked routinepublic static VMXState current()
public double dget(VMXState.Local local, Authorization auth)
local.localpublic static double dget(VMXState vmx, int nesting, int index, Authorization auth)
index
of the nesting-th statically containing frame.indexpublic double dgetj(int index,
Authorization auth)
index
of the current Java frame.indexpublic double dpeek()
public double dpeek(int index)
index-th value from the top of the stack,
i.e., the value with absolute address sp - index.index-th value from the top of the stackpublic double dpop()
public void dpush(double value)
value on top of the stack.public AbruptCompletion.Return dreturn(double value)
AbruptCompletion.Return. This instance can be used
until its dispose-method is invoked, which marks
the instance as available for later re-use. The value of the
instance is set to the given value.value - the returned valueAbruptCompletion.Return with the given valuepublic static void dset(double value,
VMXState vmx,
int nesting,
int index,
Authorization auth)
index of the
nesting-th statically containing frame to value.public void dset(VMXState.Local local, double value, Authorization auth)
local
to value.public void dsetj(int index,
double value,
Authorization auth)
index of the
current Java frame to value.public void enter(int frameSize,
Authorization auth)
public float fget(VMXState.Local local, Authorization auth)
local.localpublic static float fget(VMXState vmx, int nesting, int index, Authorization auth)
index
of the nesting-th statically containing frame.indexpublic float fgetj(int index,
Authorization auth)
index
of the current Java frame.indexpublic float fpeek()
public float fpeek(int index)
index-th value from the top of the stack,
i.e., the value with absolute address sp - index.index-th value from the top of the stackpublic float fpop()
public void fpush(float value)
value on top of the stack.public AbruptCompletion.Return freturn(float value)
AbruptCompletion.Return. This instance can be used
until its dispose-method is invoked, which marks
the instance as available for later re-use. The value of the
instance is set to the given value.value - the returned valueAbruptCompletion.Return with the given valuepublic static void fset(float value,
VMXState vmx,
int nesting,
int index,
Authorization auth)
index of the
nesting-th statically containing frame to value.public void fset(VMXState.Local local, float value, Authorization auth)
local
to value.public void fsetj(int index,
float value,
Authorization auth)
index of the
current Java frame to value.public Frame getFrame(Authorization auth)
public int getId()
public int iget(VMXState.Local local, Authorization auth)
local.localpublic static int iget(VMXState vmx, int nesting, int index, Authorization auth)
index
of the nesting-th statically containing frame.indexpublic int igetj(int index,
Authorization auth)
index
of the current Java frame.indexpublic AbruptCompletion.Return invoke(Method method)
method using parameters popped
from the stack. The returned value is wrapped in an instance of
AbruptCompletion.Return. Checked exceptions are wrapped
in an instance of AbruptCompletion.Throw which is then thrown.method - the method to invokepublic AbruptCompletion.Return invoke(Routine routine, int nesting, Authorization auth)
routine.
This method proceeds as follows:
routine.getParameterSize()
stack elements have been pushed on the stack. These are used
as the parameters for the routine invocation.
routine.hasJavaParameters() returns
true, 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
of routine.getJavaFrameSize()). The stack pointer
is set to point behind the frame (which has a total size
of routine.getFrameSize()). Otherwise, if
routine.hasJavaParameters() returns false,
the pointers are modified correspondingly, with the roles of the
frame and the Java frame exchanged.
nesting is used in this step. Its value has to be
routine
are statically contained in the same routine (i.e., their
immediately enclosing routine is the same),
routine is the n-th
statically containing routine of the invoking routine,
routine.execute is invoked.
routine - the routine to be invokednesting - the nesting of the invoking routine within the invoked routineroutine.executepublic VMXState.MatchConsumerInFrame invokeInFrame(MatchConsumer consumer, Frame frame)
public int ipeek()
public int ipeek(int index)
index-th value from the top of the stack,
i.e., the value with absolute address sp - index.index-th value from the top of the stackpublic int ipop()
public void ipush(int value)
value on top of the stack.public AbruptCompletion.Return ireturn(int value)
AbruptCompletion.Return. This instance can be used
until its dispose-method is invoked, which marks
the instance as available for later re-use. The value of the
instance is set to the given value.value - the returned valueAbruptCompletion.Return with the given valuepublic static void iset(int value,
VMXState vmx,
int nesting,
int index,
Authorization auth)
index of the
nesting-th statically containing frame to value.public void iset(VMXState.Local local, int value, Authorization auth)
local
to value.public void isetj(int index,
int value,
Authorization auth)
index of the
current Java frame to value.public void leave(Authorization auth)
public long lget(VMXState.Local local, Authorization auth)
local.localpublic static long lget(VMXState vmx, int nesting, int index, Authorization auth)
index
of the nesting-th statically containing frame.indexpublic long lgetj(int index,
Authorization auth)
index
of the current Java frame.indexpublic long lpeek()
public long lpeek(int index)
index-th value from the top of the stack,
i.e., the value with absolute address sp - index.index-th value from the top of the stackpublic long lpop()
public void lpush(long value)
value on top of the stack.public AbruptCompletion.Return lreturn(long value)
AbruptCompletion.Return. This instance can be used
until its dispose-method is invoked, which marks
the instance as available for later re-use. The value of the
instance is set to the given value.value - the returned valueAbruptCompletion.Return with the given valuepublic static void lset(long value,
VMXState vmx,
int nesting,
int index,
Authorization auth)
index of the
nesting-th statically containing frame to value.public void lset(VMXState.Local local, long value, Authorization auth)
local
to value.public void lsetj(int index,
long value,
Authorization auth)
index of the
current Java frame to value.public AbruptCompletion.Break newBreak(int label)
AbruptCompletion.Break. This instance can be used
until its dispose-method is invoked, which marks
the instance as available for later re-use.label - the break labelAbruptCompletion.Breakpublic AbruptCompletion.Nonlocal newNonlocal(int nesting, AbruptCompletion reason, Authorization auth)
AbruptCompletion.Nonlocal. This instance can be used
until its dispose-method is invoked, which marks
the instance as available for later re-use.nesting - the nesting of the target routine within the invoked routinereason - the reason of the nonlocal abrupt completionAbruptCompletion.Nonlocalpublic AbruptCompletion.Return newReturn()
AbruptCompletion.Return. This instance can be used
until its dispose-method is invoked, which marks
the instance as available for later re-use.AbruptCompletion.Returnpublic AbruptCompletion.Throw newThrow(java.lang.Throwable cause)
AbruptCompletion.Throw. This instance can be used
until its dispose-method is invoked, which marks
the instance as available for later re-use.cause - the causeAbruptCompletion.Throwpublic int[] peekIntArray(int length)
public void pop(int size)
size elements from the stack.size - the number of elements to poppublic int[] popIntArray(int length)
length values of type int from 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 same VMXState.length - the number of values to be poppedlength popped valuespublic AbruptCompletion.Return vreturn()
AbruptCompletion.Return. This instance can be used
until its dispose-method is invoked, which marks
the instance as available for later re-use.AbruptCompletion.Return with a void return value