Class Frame


  • final class Frame
    extends java.lang.Object
    Information about the input and output stack map frames of a basic block.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) static int ARRAY_OF
      Constant to be added to a type to get a type with one more dimension.
      (package private) static int BASE
      Kind of the types that are not relative to an input stack map frame.
      (package private) static int BASE_KIND
      Mask to get the kind of base types.
      (package private) static int BASE_VALUE
      Mask to get the value of base types.
      (package private) static int BOOLEAN
      The BOOLEAN type.
      (package private) static int BYTE
      The BYTE type.
      (package private) static int CHAR
      The CHAR type.
      (package private) static int DIM
      Mask to get the dimension of a frame type.
      (package private) static int DOUBLE
      The DOUBLE type.
      (package private) static int ELEMENT_OF
      Constant to be added to a type to get a type with one less dimension.
      (package private) static int FLOAT
      The FLOAT type.
      private int initializationCount
      Number of types that are initialized in the basic block.
      private int[] initializations
      The types that are initialized in the basic block.
      (package private) int[] inputLocals
      The input stack map frame locals.
      (package private) int[] inputStack
      The input stack map frame stack.
      (package private) static int INTEGER
      The INTEGER type.
      (package private) static int KIND
      Mask to get the kind of a frame type.
      private static int LOCAL
      Kind of the types that are relative to the local variable types of an input stack map frame.
      (package private) static int LONG
      The LONG type.
      (package private) static int NULL
      The NULL type.
      (package private) static int OBJECT
      Base kind of the base reference types.
      private int[] outputLocals
      The output stack map frame locals.
      private int[] outputStack
      The output stack map frame stack.
      private int outputStackTop
      Relative size of the output stack.
      (package private) Label owner
      The label (i.e.
      (package private) static int SHORT
      The SHORT type.
      (package private) static int[] SIZE
      The stack size variation corresponding to each JVM instruction.
      private static int STACK
      Kind of the the types that are relative to the stack of an input stack map frame.
      (package private) static int TOP
      The TOP type.
      (package private) static int TOP_IF_LONG_OR_DOUBLE
      Flag used for LOCAL and STACK types.
      (package private) static int UNINITIALIZED
      Base kind of the uninitialized base types.
      (package private) static int UNINITIALIZED_THIS
      The UNINITIALIZED_THIS type.
      (package private) static int VALUE
      Mask to get the value of a frame type.
    • Constructor Summary

      Constructors 
      Constructor Description
      Frame()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (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 pop​(java.lang.String desc)
      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, java.lang.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, java.lang.String desc)
      Returns the int encoding of the given type.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DIM

        static final int DIM
        Mask to get the dimension of a frame type. This dimension is a signed integer between -8 and 7.
        See Also:
        Constant Field Values
      • ARRAY_OF

        static final int ARRAY_OF
        Constant to be added to a type to get a type with one more dimension.
        See Also:
        Constant Field Values
      • ELEMENT_OF

        static final int ELEMENT_OF
        Constant to be added to a type to get a type with one less dimension.
        See Also:
        Constant Field Values
      • TOP_IF_LONG_OR_DOUBLE

        static final int TOP_IF_LONG_OR_DOUBLE
        Flag 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:
        Constant Field Values
      • BASE_KIND

        static final int BASE_KIND
        Mask to get the kind of base types.
        See Also:
        Constant Field Values
      • BASE_VALUE

        static final int BASE_VALUE
        Mask to get the value of base types.
        See Also:
        Constant Field Values
      • BASE

        static final int BASE
        Kind of the types that are not relative to an input stack map frame.
        See Also:
        Constant Field Values
      • OBJECT

        static final int OBJECT
        Base kind of the base reference types. The BASE_VALUE of such types is an index into the type table.
        See Also:
        Constant Field Values
      • UNINITIALIZED

        static final int UNINITIALIZED
        Base 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:
        Constant Field Values
      • LOCAL

        private static final int LOCAL
        Kind 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:
        Constant Field Values
      • STACK

        private static final int STACK
        Kind 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:
        Constant Field Values
      • BOOLEAN

        static final int BOOLEAN
        The BOOLEAN type. This is a BASE type mainly used for array types.
        See Also:
        Constant Field Values
      • BYTE

        static final int BYTE
        The BYTE type. This is a BASE type mainly used for array types.
        See Also:
        Constant Field Values
      • CHAR

        static final int CHAR
        The CHAR type. This is a BASE type mainly used for array types.
        See Also:
        Constant Field Values
      • SHORT

        static final int SHORT
        The SHORT type. This is a BASE type mainly used for array types.
        See Also:
        Constant Field Values
      • INTEGER

        static final int INTEGER
        The INTEGER type. This is a BASE type.
        See Also:
        Constant Field Values
      • UNINITIALIZED_THIS

        static final int UNINITIALIZED_THIS
        The UNINITIALIZED_THIS type. This is a BASE type.
        See Also:
        Constant Field Values
      • SIZE

        static final int[] SIZE
        The 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 owner
        The label (i.e. basic block) to which these input and output stack map frames correspond.
      • inputLocals

        int[] inputLocals
        The input stack map frame locals.
      • inputStack

        int[] inputStack
        The input stack map frame stack.
      • outputLocals

        private int[] outputLocals
        The output stack map frame locals.
      • outputStack

        private int[] outputStack
        The output stack map frame stack.
      • outputStackTop

        private int outputStackTop
        Relative 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 in outputStack.
      • initializationCount

        private int initializationCount
        Number of types that are initialized in the basic block.
        See Also:
        initializations
      • initializations

        private int[] initializations
        The 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 Detail

      • Frame

        Frame()
    • Method Detail

      • 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

        private void push​(ClassWriter cw,
                          java.lang.String desc)
        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

        private static int type​(ClassWriter cw,
                                java.lang.String desc)
        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

        private void pop​(java.lang.String desc)
        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

        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.
        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

        void initInputFrame​(ClassWriter cw,
                            int access,
                            Type[] args,
                            int maxLocals)
        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

        void execute​(int opcode,
                     int arg,
                     ClassWriter cw,
                     Item item)
        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

        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. Returns true if the input frame of the given label has been changed by this operation.
        Parameters:
        cw - the ClassWriter to which this label belongs.
        frame - the basic block whose input frame must be updated.
        edge - the kind of the Edge between this label and 'label'. See Edge.info.
        Returns:
        true if the input frame of the given label has been changed by this operation.
      • merge

        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. 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.