Browse Prior Art Database

A method for eliminating an array creation Disclosure Number: IPCOM000019355D
Original Publication Date: 2003-Sep-12
Included in the Prior Art Database: 2003-Sep-12
Document File: 2 page(s) / 9K

Publishing Venue



Disclosed is a method for eliminating an instruction of array creation with variable length for a compiler optimization. Previous elimination techniques eliminated the instruction only if its destination operand was not used.

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 55% of the total text.

Page 1 of 2

A method for eliminating an array creation

  This disclosure consists of three steps to eliminate an instruction of array creation with variable length.

1. We convert the target program to an intermediate representation. We divide each instruction in the original program into several pseudo instructions to express the detailed operation semantics for each instruction explicitly. For example, in Java, we express the semantics (e.g. exception checks) of each bytecode using several pseudo instructions.

2. We check the following two conditions. These checks can be performed by using UD/DU-chain. (a) Uses of the destination operand of an array creation instruction N are either "getting the array's length" and "writing data into the array" instructions. (b) Definition corresponding to each use is single, that is, the instruction N.

3. If the two conditions of the step 2 are satisfied, we perform the following two operations.

(a) We replace the instruction of "getting the array's length" with the length parameter of the instruction N. (b) We eliminate the instructions "writing data into the array" and the instruction N itself.

Note that both method inlining and scalar replacement can improve the effectiveness of this technique. Therefore, we should perform these optimizations before the step 2.

Fig.1 shows an example program for explaining the above three steps.

for (Enumeration enumeration = rangeMoves.keys(); enumeration.hasMoreElements(); ) {

char ach[] = new char[newlen];

String string = (String)enumeration.nextElement();

System.arraycopy(string.value, 0, ach, 0, string.length());


: /* The variable "ach" is not used after this point */


Fig.1: Sample Java program

By using the step 1, the program can be converted as follows.

for (Enumeration enumeration = rangeMoves.keys(); enumeration.hasMoreElements(); ) {

if (newlen < 0) throw new Negativ...