Inferring object invariant method and system
First Claim
1. A computer implemented method for determining invariants within an object oriented program in a computer, comprising:
- at least partially running a local analysis of the program wherein the local analysis notes at least one local value of at least one object field of an object within the program at at least one program point wherein the state of the object is either mutable or valid;
at least partially running a global analysis of the program, wherein the global analysis stores invariants in a global analysis invariant storage which the at least one object field has held by the local analysis when the object is valid; and
combining the local analysis and the global analysis to infer at least one invariant that is not explicitly declared for the object within the program, wherein the combining comprises;
the local analysis reaching a program point marked by a pack statement where the object transitions from mutable to valid, the at least one local value of the at least one object field associated with the valid object being passed to the global analysis, and wherein if the at least one local value is not included within the current list of invariants in the global analysis invariant storage, the global analysis adds the at least one local value to the current list of invariants in the global analysis invariant storage for the object, and wherein the local analysis keeps track of the local values of the object encountered until the object transitions from mutable to valid;
and the local analysis reaching a program point marked by an unpack statement where the object transitions from valid to mutable, wherein the local values of the mutable object are recorded by the local analysis but the global analysis does not reflect the local values of the mutable object and the local values of the mutable object are not added to the current list of invariants in the global analysis invariant storage, and the global analysis passing information about the stored invariants for the object to the local analysis.
2 Assignments
0 Petitions
Accused Products
Abstract
A local analysis analyzes the values of objects paying attention to program flow and a global analysis analyses the object independent of the flow. The local and global analysis interact to infer the invariants of objects used within a computer program. The local analysis is given the known invariants of an object by the global analysis when the object transitions from a valid to a mutable state. It then keeps track of all of the values of objects encountered until the object transitions from mutable to a valid state, when the information known to the local analysis is passed to the global analysis, which may use the new object values to add to the current list of invariants for the given object.
40 Citations
15 Claims
-
1. A computer implemented method for determining invariants within an object oriented program in a computer, comprising:
-
at least partially running a local analysis of the program wherein the local analysis notes at least one local value of at least one object field of an object within the program at at least one program point wherein the state of the object is either mutable or valid; at least partially running a global analysis of the program, wherein the global analysis stores invariants in a global analysis invariant storage which the at least one object field has held by the local analysis when the object is valid; and combining the local analysis and the global analysis to infer at least one invariant that is not explicitly declared for the object within the program, wherein the combining comprises; the local analysis reaching a program point marked by a pack statement where the object transitions from mutable to valid, the at least one local value of the at least one object field associated with the valid object being passed to the global analysis, and wherein if the at least one local value is not included within the current list of invariants in the global analysis invariant storage, the global analysis adds the at least one local value to the current list of invariants in the global analysis invariant storage for the object, and wherein the local analysis keeps track of the local values of the object encountered until the object transitions from mutable to valid; and the local analysis reaching a program point marked by an unpack statement where the object transitions from valid to mutable, wherein the local values of the mutable object are recorded by the local analysis but the global analysis does not reflect the local values of the mutable object and the local values of the mutable object are not added to the current list of invariants in the global analysis invariant storage, and the global analysis passing information about the stored invariants for the object to the local analysis. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)
-
-
15. A computer system having a processor for determining invariants within an object oriented program, comprising:
-
a compiler to at least partially run a local analysis of the program wherein the local analysis notes at least one local value of at least one object field of an object within the program at at least one program point wherein the state of the object is either mutable or valid; the compiler to at least partially run a global analysis of the program, wherein the global analysis stores invariants in a global analysis invariant storage which the at least one object field has held by the local analysis when the object is valid; and the compiler to combine the local analysis and the global analysis to infer at least one invariant that is not explicitly declared for the object within the program, wherein the combining comprises; the local analysis reaching a program point marked by a pack statement where the object transitions from mutable to valid, the at least one local value of the at least one object field associated with the valid object being given to the global analysis, and wherein if the at least one local value is not included within the current list of invariants in the global analysis invariant storage, the global analysis adds the at least one local value to the current list of invariants in the global analysis invariant storage for the object, and wherein the local analysis keeps track of the local values of the object encountered until the object transitions from mutable to valid; and the local analysis reaching a program point marked by an unpack statement where the object transitions from valid to mutable, wherein the local values of the mutable object are recorded by the local analysis but the global analysis does not reflect the local values of the mutable object and the local values of the mutable object are not added to the current list of invariants in the global analysis invariant storage, and the global analysis passing information about the stored invariants for the object to the local analysis.
-
Specification