Removing useless variables in cost analysis of Java bytecode

Automatic cost analysis has interesting applications in the context of verification and certification of mobile code. For instance, the code receiver can use cost information in order to decide whether to reject mobile code which has too large cost requirements in terms of computing resources (in time and/or space) or billable events (SMSs sent, bandwidth required). Existing cost analyses for a variety of languages describe the resource consumption of programs by means of Cost Equation Systems (CESs), which are similar to, but more general than recurrence equations. CESs express the cost of a program in terms of the size of its input data. In a further step, a closed form (i.e., non-recursive) solution or upper bound can sometimes be found by using existing Computer Algebra Systems (CASs), such as Maple and Mathematica. In this work, we focus on cost analysis of Java bytecode, a language which is widely used in the context of mobile code and we study the problem of identifying variables which are useless in the sense that they do not affect the execution cost and therefore can be ignored by cost analysis. We identify two classes of useless variables and propose automatic analysis techniques to detect them. The first class corresponds to stack variables that can be replaced by program variables or constant values. The second class corresponds to variables whose value is cost-irrelevant, i.e., does not affect the cost of the program. We propose an algorithm, inspired in static slicing which safely identifies cost-irrelevant variables. The benefits of eliminating useless variables are two-fold: (1) cost analysis without useless variables can be more efficient and (2) resulting CESs are more likely to be solvable by existing CASs.

[1]  David W. Binkley,et al.  Program slicing , 2008, 2008 Frontiers of Software Maintenance.

[2]  Frank Tip,et al.  A survey of program slicing techniques , 1994, J. Program. Lang..

[3]  Alfred V. Aho,et al.  The Design and Analysis of Computer Algorithms , 1974 .

[4]  Jorge A. Navas,et al.  User-Definable Resource Bounds Analysis for Logic Programs , 2007, ICLP.

[5]  Stefano Secci,et al.  Pair-Sharing Analysis of Object-Oriented Programs , 2005, SAS.

[6]  Jan Maluszy¿ski,et al.  Lower Bound Cost Estimation for Logic Programs , 1997 .

[7]  Krzysztof R. Apt,et al.  Logic Programming , 1990, Handbook of Theoretical Computer Science, Volume B: Formal Models and Sematics.

[8]  Patrick Cousot,et al.  Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints , 1977, POPL.

[9]  Alfred V. Aho,et al.  Compilers: Principles, Techniques, and Tools , 1986, Addison-Wesley series in computer science / World student series edition.

[10]  Susan Horwitz,et al.  Slicing java programs that throw and catch exceptions , 2003, PEPM '03.

[11]  David Sands,et al.  A Naïve Time Analysis and its Theory of Cost Equivalence , 1995, J. Log. Comput..

[12]  G. Barthe,et al.  Mobile Resource Guarantees for Smart Devices , 2005 .

[13]  Tao Wang,et al.  Dynamic slicing on Java bytecode traces , 2008, TOPL.

[14]  Elvira Albert,et al.  Cost Analysis of Java Bytecode , 2007, ESOP.

[15]  Fausto Spoto,et al.  Information Flow Analysis for Java Bytecode , 2005, VMCAI.

[16]  Ralph Benzinger,et al.  Automated higher-order complexity analysis , 2004, Theor. Comput. Sci..

[17]  Manuel V. Hermenegildo,et al.  Abstraction-Carrying Code: a Model for Mobile Code Safety , 2008, New Generation Computing.

[18]  Elvira Albert,et al.  Heap space analysis for java bytecode , 2007, ISMM '07.

[19]  Manuel V. Hermenegildo,et al.  Abstraction carrying code and resource-awareness , 2005, PPDP.

[20]  Jean-Pierre Jouannaud,et al.  Automatic Complexity Analysis for Programs Extracted from Coq Proof , 2006, Electron. Notes Theor. Comput. Sci..

[21]  Saumya K. Debray,et al.  Cost analysis of logic programs , 1993, TOPL.

[22]  Karl Crary,et al.  Resource bound certification , 2000, POPL '00.

[23]  Mads Rosendahl,et al.  Automatic complexity analysis , 1989, FPCA.

[24]  Frank Yellin,et al.  The Java Virtual Machine Specification , 1996 .

[25]  Frances E. Allen,et al.  Control-flow analysis , 2022 .

[26]  Elvira Albert,et al.  Experiments in Cost Analysis of Java Bytecode , 2007, Electron. Notes Theor. Comput. Sci..

[27]  J. van Leeuwen,et al.  Logic Programming , 2002, Lecture Notes in Computer Science.

[28]  Yanhong A. Liu,et al.  Automatic time-bound analysis for a higher-order language , 2002, PEPM '02.

[29]  Stephen Gilmore,et al.  Mobile Resource Guarantees for Smart Devices , 2004, CASSIS.