IP Library › Granted Patent US 8,122,430
Granted Patent B2
US 8,122,430 · App. 11/926,287 · Granted Feb 21, 2012

Automatic customization of classes

Assignee: International Business Machines Corporation
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 8,122,430
App. No.
11/926,287
Filed
Oct 29, 2007
Granted
Feb 21, 2012
Kind
B2
Examiner
WEI, ZHENG
Art Unit
2192
USPC
717/154
Abstract

A method and computer readable medium for automatic replacement of object classes in a library with custom classes to improve program efficiency. The method begins with static analysis preformed on a program containing a plurality of objects in order to determine type-correctness constraints and to detect unused functionality in one or more of the objects to be replaced. The plurality of objects is instrumented to detect usage patterns of functionality in one or more objects. Customized classes are generated based upon the static analysis and usage patterns detected. Bytecode is rewritten which is used for generating classes. The present invention provides transparency in the replacement of the objects.

Claims (50)

1. A computer readable storage medium containing programming instructions for automatic replacement of object classes, the programming instructions comprising:

performing static analysis on a program containing a plurality of objects in order to determine constraints on transformations that can be applied and to detect unused functionality in one or more of the objects to be replaced;

analyzing the plurality of objects to detect usage patterns of functionality in the one or more objects replaced;

analyzing at least one execution of the program to collect profile information for the one or more objects; and

generating customized classes based upon the static analysis and the usage patterns detected and the profile information which has been collected;

wherein the generating customized classes based upon the usage patterns detected includes:

identifying a customizable container class C with superclass B;

creating a class CustomC which contains methods and fields that are identical to those in class C, wherein if B is not customizable, then CustomC's superclass is B, otherwise CustomC's superclass is CustomB;

introducing a type C T , and making both C and CustomC a subtype of C T and wherein type C T contains declarations of all methods in C that are not declared in any superclass of C; and

introducing a type C ⊥ , and making C ⊥ a subclass of both C and CustomC, wherein type C ⊥ contains no methods, and wherein C T and C ⊥ are intermediate types not provided as output during the generating of custom classes;

determining at least one equivalence class E of declaration elements and expressions that must have a same type.

2. The computer readable storage medium according to claim 1 , wherein the performing static analysis on a program containing a plurality of objects in order to determine constraints includes determining constraints which are type constraints.

3. The computer readable storage medium according to claim 1 , wherein the plurality of objects is a plurality of container objects.

4. The computer readable storage medium according to claim 1 , wherein the analyzing the plurality of objects includes instrumenting the plurality of objects to detect usage patterns of functionality in the one or more objects replaced.

5. The computer readable storage medium according to claim 1 , further comprising rewriting bytecode of an application to use the generated classes while providing transparency in the program during the replacement of the objects.

6. The computer readable storage medium according to claim 1 , wherein the performing static analysis further comprises performing static analysis to determine constraints by determining if a type of in one or more objects to be replaced is a supertype of a type referenced in a cast expression.

7. The computer readable storage medium according to claim 1 , wherein the performing static analysis further comprises performing static analysis to determine type-correctness constraints by determining if a type of in one or more objects to be replaced is a supertype of a type referenced in a cast expression.

8. The computer readable storage medium according to claim 1 , wherein the performing static analysis further comprises performing static analysis to determine interface-compatibility constraints in one or more of the objects to be replaced.

9. The computer readable storage medium according to claim 1 , wherein the performing static analysis further comprises performing static analysis to preserve run-time behavior for casts and instance of operations for one or more of the objects to be replaced.

10. The computer readable storage medium according to claim 1 , wherein the performing static analysis includes using points-to-analysis to determine where references to classes in allocation sites, declarations, casts and instanceof-expressions are modifiable to refer to one or more of the objects to be replaced.

11. The computer readable storage medium according to claim 1 , wherein the performing static analysis includes using points-to analysis to determine where references to container classes in allocation sites, declarations, casts and instanceof-expressions are modifiable to refer to one or more of the objects to be replaced.

12. The computer readable storage medium according to claim 1 , wherein the generating customized classes does not require a programmer to supply any additional types and additional external declarations for the customized classes.

13. The computer readable storage medium according to claim 1 , wherein the generating of customized classes based upon the usage patterns detected includes:

computing a set of possible types for equivalence class E using an optimistic algorithm, wherein this algorithm associates a set S E of types with equivalence class E, which is initialized as follows:

associating a set S E with the equivalence class E containing the types C and CustomC if E contains an allocation site expression new C; and

associating a set S E with the equivalence class E containing all types except auxiliary types C T and C ⊥ , wherein C T and C ⊥ are intermediate types not provided as output during the generation of custom classes if E does not contain any allocation site expressions.

14. The computer readable storage medium according to claim 13 , further comprising:

identifying sets S D and S E for each pair of equivalence classes D, E such that there exists a type constraint D≦E;

removing from set S D any type that is not a subtype of a type that occurs in S E ; and

removing from set S E any type that is not a supertype of a type that occurs in S D ,

wherein the removing of S D and S E is performed repeatedly until a fixed point is reached.

15. An information processing system with programming instructions for automatic replacement of object classes, comprising:

means for performing static analysis on a program containing a plurality of objects in order to determine constraints on transformations that can be applied and to detect unused functionality in one or more of the objects to be replaced;

means for analyzing the plurality of objects to detect usage patterns of functionality in the one or more objects replaced;

means for analyzing at least one execution of the program to collect profile information for the one or more objects; and

means for generating customized classes based upon the static analysis and the usage patterns detected and the profile information which has been collected;

wherein the means for generation of customized classes based upon the usage patterns detected includes:

means for identifying a customizable container class C with superclass B;

means for creating a class CustomC which contains methods and fields that are identical to those in class C, wherein if B is not customizable, then CustomC's superclass is B, otherwise CustomC's superclass is Custom B;

means for introducing a type C T , and making both C and CustomC a subtype of C T and wherein type C T contains declarations of all methods in C that are not declared in any superclass of C; and

means for introducing a type C ⊥ , and making C ⊥ a subclass of both C and CustomC , wherein type C ⊥ contains no methods, and wherein C T and C ⊥ are intermediate types not provided as output during the generating of custom classes; and

means for determining at least one equivalence class E of declaration elements and expressions that must have a same type.

16. The information processing system according to claim 15 , wherein the means for performing static analysis on a program containing a plurality of objects in order to determine constraints includes determining constraints which are type constraints.

17. The information processing system according to claim 15 , wherein the means the plurality of objects is a plurality of container objects.

18. The information processing system according to claim 15 , wherein the means for analyzing the plurality of objects includes instrumenting the plurality of objects to detect usage patterns of functionality in the one or more objects replaced.

19. The information processing system according to claim 15 , further comprising means for rewriting bytecode of an application to use the generated classes while providing transparency in the program during the replacement of the objects.

20. The information processing system according to claim 15 , wherein the means of generating of customized classes based upon the usage patterns detected includes:

means for computing a set of possible types for equivalence class E using an optimistic algorithm, wherein this algorithm associates a set S E of types with equivalence class E, which is initialized as follows:

means for associating a set S E with the equivalence class E containing types C and CustomC if E contains an allocation site expression new C; and

means for associating a set S E with the equivalence class E containing all types except auxiliary types C T and C ⊥ , wherein C T and C ⊥ are intermediate types not provided as output during the generation of custom classes if E does not contain any allocation site expressions.

Continuity (1)
Related Publication 20080082972A1 · Apr 3, 2008