Package daikon

Class DynamicConstants

  • All Implemented Interfaces:
    Serializable

    public class DynamicConstants
    extends Object
    implements Serializable
    Class that implements dynamic constants optimization. This optimization doesn't instantiate invariants over constant variables (i.e., that that have only seen one value). When the variable receives a second value, invariants are instantiated and are given the sample representing the previous constant value. Each DynamicConstants object is associated with a single program point, ppt.
    See Also:
    Serialized Form
    • Field Detail

      • dkconfig_use_dynamic_constant_optimization

        public static boolean dkconfig_use_dynamic_constant_optimization
        Whether to use the dynamic constants optimization. This optimization doesn't instantiate invariants over constant variables (i.e., that that have only seen one value). When the variable receives a second value, invariants are instantiated and are given the sample representing the previous constant value.
      • dkconfig_OneOf_only

        public static boolean dkconfig_OneOf_only
        Boolean. Controls which invariants are created for variables that are constant for the entire run. If true, create only OneOf invariants. If false, create all possible invariants.

        Note that setting this to true only fails to create invariants between constants. Invariants between constants and non-constants are created regardless.

        A problem occurs with merging when this is turned on. If a var_info is constant at one child slice, but not constant at the other child slice, interesting invariants may not be merged because they won't exist on the slice with the constant. This is thus currently defaulted to false.

      • debug

        public static final Logger debug
        Debug tracer.
    • Constructor Detail

      • DynamicConstants

        public DynamicConstants​(PptTopLevel ppt)
        Create an initial list of constants and missing variables for the specified ppt.
    • Method Detail

      • add

        public void add​(ValueTuple vt,
                        int count)
        Checks each current constant to see if it is still a constant. Constants must have the same value and cannot be missing. In the long run a better job of dealing with missing might be helpful. Also checks each variable that has always been missing to date to insure that it is still missing.

        Creates all new views required for the newly non constants (noncons) and the newly non-missing (non_missing).

      • is_constant

        @Pure
        public boolean is_constant​(VarInfo vi)
        Returns whether the specified variable is currently a constant.
      • is_prev_constant

        @Pure
        public boolean is_prev_constant​(VarInfo vi)
        Returns whether the specified variable is currently a constant OR was a constant at the beginning of constants processing.
      • constant_value

        public @Interned Object constant_value​(VarInfo vi)
        Returns the constant value of the specified variable, or null if the variable is not constant or prev_constant. But, it is apparently only called on constants with a value.
      • is_missing

        @Pure
        public boolean is_missing​(VarInfo vi)
        Returns whether the specified variable missing for all values so far.
      • is_prev_missing

        @Pure
        public boolean is_prev_missing​(VarInfo vi)
        Returns whether the specified variable is currently missing OR was missing at the beginning of constants processing.
      • constant_leader_cnt

        public int constant_leader_cnt()
        Returns the number of constants that are leaders.
      • post_process

        public void post_process()
        Create invariants for any remaining constants. Right now, this looks for invariants between all of the constants. It's not clear that invariants between constants are interesting, but to match previous behavior, this is what we will do for now.
      • create_constant_invs

        @RequiresNonNull("daikon.suppress.NIS.suppressor_proto_invs")
        public List<PptSlicecreate_constant_invs()
        Create unary and binary constant invariants. The slices and invariants are created and returned, but not added to the ppt. Note that when NIS.dkconfig_suppressor_list is turned on (default is on), only unary and binary invariants that can be suppressors in NIS suppressions are created.
      • merge

        public void merge()
        Merge dynamic constants from the children of this ppt. Only missing is merged since constants are not used after we are done processing samples.