Package org.eclipse.sisu.space.asm
Class Frame
java.lang.Object
org.eclipse.sisu.space.asm.Frame
Information about the input and output stack map frames of a basic block.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final int
Constant to be added to a type to get a type with one more dimension.(package private) static final int
Kind of the types that are not relative to an input stack map frame.(package private) static final int
Mask to get the kind of base types.(package private) static final int
Mask to get the value of base types.(package private) static final int
The BOOLEAN type.(package private) static final int
The BYTE type.(package private) static final int
The CHAR type.(package private) static final int
Mask to get the dimension of a frame type.(package private) static final int
The DOUBLE type.(package private) static final int
Constant to be added to a type to get a type with one less dimension.(package private) static final int
The FLOAT type.private int
Number of types that are initialized in the basic block.private int[]
The types that are initialized in the basic block.(package private) int[]
The input stack map frame locals.(package private) int[]
The input stack map frame stack.(package private) static final int
The INTEGER type.(package private) static final int
Mask to get the kind of a frame type.private static final int
Kind of the types that are relative to the local variable types of an input stack map frame.(package private) static final int
The LONG type.(package private) static final int
The NULL type.(package private) static final int
Base kind of the base reference types.private int[]
The output stack map frame locals.private int[]
The output stack map frame stack.private int
Relative size of the output stack.(package private) Label
The label (i.e.(package private) static final int
The SHORT type.(package private) static final int[]
The stack size variation corresponding to each JVM instruction.private static final int
Kind of the the types that are relative to the stack of an input stack map frame.(package private) static final int
The TOP type.(package private) static final int
Flag used for LOCAL and STACK types.(package private) static final int
Base kind of the uninitialized base types.(package private) static final int
The UNINITIALIZED_THIS type.(package private) static final int
Mask to get the value of a frame type. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
execute
(int opcode, int arg, ClassWriter cw, Item item) Simulates the action of the given instruction on the output stack frame.private int
get
(int local) Returns the output frame local variable type at the given index.private void
init
(int var) Adds a new type to the list of types on which a constructor is invoked in the basic block.private int
init
(ClassWriter cw, int t) Replaces the given type with the appropriate type if it is one of the types on which a constructor is invoked in the basic block.(package private) void
initInputFrame
(ClassWriter cw, int access, Type[] args, int maxLocals) Initializes the input frame of the first basic block from the method descriptor.private static boolean
merge
(ClassWriter cw, int t, int[] types, int index) Merges the type at the given index in the given type array with the given type.(package private) boolean
merge
(ClassWriter cw, Frame frame, int edge) Merges the input frame of the given basic block with the input and output frames of this basic block.private int
pop()
Pops a type from the output frame stack and returns its value.private void
pop
(int elements) Pops the given number of types from the output frame stack.private void
Pops a type from the output frame stack.private void
push
(int type) Pushes a new type onto the output frame stack.private void
push
(ClassWriter cw, String desc) Pushes a new type onto the output frame stack.private void
set
(int local, int type) Sets the output frame local variable type at the given index.private static int
type
(ClassWriter cw, String desc) Returns the int encoding of the given type.
-
Field Details
-
DIM
static final int DIMMask to get the dimension of a frame type. This dimension is a signed integer between -8 and 7.- See Also:
-
ARRAY_OF
static final int ARRAY_OFConstant to be added to a type to get a type with one more dimension.- See Also:
-
ELEMENT_OF
static final int ELEMENT_OFConstant to be added to a type to get a type with one less dimension.- See Also:
-
KIND
static final int KINDMask to get the kind of a frame type.- See Also:
-
TOP_IF_LONG_OR_DOUBLE
static final int TOP_IF_LONG_OR_DOUBLEFlag used for LOCAL and STACK types. Indicates that if this type happens to be a long or double type (during the computations of input frames), then it must be set to TOP because the second word of this value has been reused to store other data in the basic block. Hence the first word no longer stores a valid long or double value.- See Also:
-
VALUE
static final int VALUEMask to get the value of a frame type.- See Also:
-
BASE_KIND
static final int BASE_KINDMask to get the kind of base types.- See Also:
-
BASE_VALUE
static final int BASE_VALUEMask to get the value of base types.- See Also:
-
BASE
static final int BASEKind of the types that are not relative to an input stack map frame.- See Also:
-
OBJECT
static final int OBJECTBase kind of the base reference types. The BASE_VALUE of such types is an index into the type table.- See Also:
-
UNINITIALIZED
static final int UNINITIALIZEDBase kind of the uninitialized base types. The BASE_VALUE of such types in an index into the type table (the Item at that index contains both an instruction offset and an internal class name).- See Also:
-
LOCAL
private static final int LOCALKind of the types that are relative to the local variable types of an input stack map frame. The value of such types is a local variable index.- See Also:
-
STACK
private static final int STACKKind of the the types that are relative to the stack of an input stack map frame. The value of such types is a position relatively to the top of this stack.- See Also:
-
TOP
static final int TOPThe TOP type. This is a BASE type.- See Also:
-
BOOLEAN
static final int BOOLEANThe BOOLEAN type. This is a BASE type mainly used for array types.- See Also:
-
BYTE
static final int BYTEThe BYTE type. This is a BASE type mainly used for array types.- See Also:
-
CHAR
static final int CHARThe CHAR type. This is a BASE type mainly used for array types.- See Also:
-
SHORT
static final int SHORTThe SHORT type. This is a BASE type mainly used for array types.- See Also:
-
INTEGER
static final int INTEGERThe INTEGER type. This is a BASE type.- See Also:
-
FLOAT
static final int FLOATThe FLOAT type. This is a BASE type.- See Also:
-
DOUBLE
static final int DOUBLEThe DOUBLE type. This is a BASE type.- See Also:
-
LONG
static final int LONGThe LONG type. This is a BASE type.- See Also:
-
NULL
static final int NULLThe NULL type. This is a BASE type.- See Also:
-
UNINITIALIZED_THIS
static final int UNINITIALIZED_THISThe UNINITIALIZED_THIS type. This is a BASE type.- See Also:
-
SIZE
static final int[] SIZEThe stack size variation corresponding to each JVM instruction. This stack variation is equal to the size of the values produced by an instruction, minus the size of the values consumed by this instruction. -
owner
Label ownerThe label (i.e. basic block) to which these input and output stack map frames correspond. -
inputLocals
int[] inputLocalsThe input stack map frame locals. -
inputStack
int[] inputStackThe input stack map frame stack. -
outputLocals
private int[] outputLocalsThe output stack map frame locals. -
outputStack
private int[] outputStackThe output stack map frame stack. -
outputStackTop
private int outputStackTopRelative size of the output stack. The exact semantics of this field depends on the algorithm that is used. When only the maximum stack size is computed, this field is the size of the output stack relatively to the top of the input stack. When the stack map frames are completely computed, this field is the actual number of types inoutputStack
. -
initializationCount
private int initializationCountNumber of types that are initialized in the basic block.- See Also:
-
initializations
private int[] initializationsThe types that are initialized in the basic block. A constructor invocation on an UNINITIALIZED or UNINITIALIZED_THIS type must replace every occurence of this type in the local variables and in the operand stack. This cannot be done during the first phase of the algorithm since, during this phase, the local variables and the operand stack are not completely computed. It is therefore necessary to store the types on which constructors are invoked in the basic block, in order to do this replacement during the second phase of the algorithm, where the frames are fully computed. Note that this array can contain types that are relative to input locals or to the input stack (see below for the description of the algorithm).
-
-
Constructor Details
-
Frame
Frame()
-
-
Method Details
-
get
private int get(int local) Returns the output frame local variable type at the given index.- Parameters:
local
- the index of the local that must be returned.- Returns:
- the output frame local variable type at the given index.
-
set
private void set(int local, int type) Sets the output frame local variable type at the given index.- Parameters:
local
- the index of the local that must be set.type
- the value of the local that must be set.
-
push
private void push(int type) Pushes a new type onto the output frame stack.- Parameters:
type
- the type that must be pushed.
-
push
Pushes a new type onto the output frame stack.- Parameters:
cw
- the ClassWriter to which this label belongs.desc
- the descriptor of the type to be pushed. Can also be a method descriptor (in this case this method pushes its return type onto the output frame stack).
-
type
Returns the int encoding of the given type.- Parameters:
cw
- the ClassWriter to which this label belongs.desc
- a type descriptor.- Returns:
- the int encoding of the given type.
-
pop
private int pop()Pops a type from the output frame stack and returns its value.- Returns:
- the type that has been popped from the output frame stack.
-
pop
private void pop(int elements) Pops the given number of types from the output frame stack.- Parameters:
elements
- the number of types that must be popped.
-
pop
Pops a type from the output frame stack.- Parameters:
desc
- the descriptor of the type to be popped. Can also be a method descriptor (in this case this method pops the types corresponding to the method arguments).
-
init
private void init(int var) Adds a new type to the list of types on which a constructor is invoked in the basic block.- Parameters:
var
- a type on a which a constructor is invoked.
-
init
Replaces the given type with the appropriate type if it is one of the types on which a constructor is invoked in the basic block.- Parameters:
cw
- the ClassWriter to which this label belongs.t
- a type- Returns:
- t or, if t is one of the types on which a constructor is invoked in the basic block, the type corresponding to this constructor.
-
initInputFrame
Initializes the input frame of the first basic block from the method descriptor.- Parameters:
cw
- the ClassWriter to which this label belongs.access
- the access flags of the method to which this label belongs.args
- the formal parameter types of this method.maxLocals
- the maximum number of local variables of this method.
-
execute
Simulates the action of the given instruction on the output stack frame.- Parameters:
opcode
- the opcode of the instruction.arg
- the operand of the instruction, if any.cw
- the class writer to which this label belongs.item
- the operand of the instructions, if any.
-
merge
Merges the input frame of the given basic block with the input and output frames of this basic block. Returns true if the input frame of the given label has been changed by this operation. -
merge
Merges the type at the given index in the given type array with the given type. Returns true if the type array has been modified by this operation.- Parameters:
cw
- the ClassWriter to which this label belongs.t
- the type with which the type array element must be merged.types
- an array of types.index
- the index of the type that must be merged in 'types'.- Returns:
- true if the type array has been modified by this operation.
-