Class LoadedFieldSet

java.lang.Object
edu.umd.cs.findbugs.ba.vna.LoadedFieldSet

public class LoadedFieldSet extends Object
Object which stores which fields are loaded and stored by the instructions in a method (including through inner-class access methods), and also which fields are loaded/stored by the overall method. The main purpose is for doing redundant load elimination and forward substitution more efficiently, but it might be useful in other situations.
Author:
David Hovemeyer
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Count number of times a field is loaded and/or stored in the method.
  • Constructor Summary

    Constructors
    Constructor
    Description
    LoadedFieldSet(org.apache.bcel.generic.MethodGen methodGen)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addLoad(org.apache.bcel.generic.InstructionHandle handle, XField field)
    Add a load of given field at given instruction.
    void
    addStore(org.apache.bcel.generic.InstructionHandle handle, XField field)
    Add a store of given field at given instruction.
    getField(org.apache.bcel.generic.InstructionHandle handle)
    Get the field loaded or stored at given instruction, if any.
    Get the number of times given field is loaded and stored within the method.
    boolean
    instructionIsLoad(org.apache.bcel.generic.InstructionHandle handle)
    Return whether or not the given instruction is a load.
    boolean
    Return whether or not the given field is loaded by any instruction in the method.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LoadedFieldSet

      public LoadedFieldSet(org.apache.bcel.generic.MethodGen methodGen)
      Constructor. Constructs an empty object.
      Parameters:
      methodGen - the method being analyzed for loads/stores
  • Method Details

    • getLoadStoreCount

      public LoadedFieldSet.LoadStoreCount getLoadStoreCount(XField field)
      Get the number of times given field is loaded and stored within the method.
      Parameters:
      field - the field
      Returns:
      the load/store count object
    • addLoad

      public void addLoad(org.apache.bcel.generic.InstructionHandle handle, XField field)
      Add a load of given field at given instruction.
      Parameters:
      handle - the instruction
      field - the field
    • addStore

      public void addStore(org.apache.bcel.generic.InstructionHandle handle, XField field)
      Add a store of given field at given instruction.
      Parameters:
      handle - the instruction
      field - the field
    • getField

      public XField getField(org.apache.bcel.generic.InstructionHandle handle)
      Get the field loaded or stored at given instruction, if any.
      Parameters:
      handle - the instruction
      Returns:
      the field loaded or stored at the instruction, or null if the instruction is not a load or store
    • isLoaded

      public boolean isLoaded(XField field)
      Return whether or not the given field is loaded by any instruction in the method.
      Parameters:
      field - the field
      Returns:
      true if the field is loaded somewhere in the method, false if it is never loaded
    • instructionIsLoad

      public boolean instructionIsLoad(org.apache.bcel.generic.InstructionHandle handle)
      Return whether or not the given instruction is a load.
      Parameters:
      handle - the instruction
      Returns:
      true if the instruction is a load, false if not