Browse Prior Art Database

A method for eliminating object initialization using memory copy

IP.com Disclosure Number: IPCOM000012687D
Original Publication Date: 2003-May-21
Included in the Prior Art Database: 2003-May-21
Document File: 1 page(s) / 35K

Publishing Venue

IBM

Abstract

Disclosed is a method for eliminating object initializations using a memory copy on compilers. Previous approaches of eliminating object initialization have been limited to those objects that are allocated with both fixed and small size. The purpose of this disclosure is to improve performance by eliminating redundant object initializations for those array creations that are allocated even with either variable or big size.

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

Page 1 of 1

A method for eliminating object initialization using memory copy

This optimization consists of the following four steps:
1. A compiler analyzes that a use of the destination operand of an array creation A is the destination operand of a memory copy operation B.
2. If the first analysis is satisfied, the compiler analyzes that a definition of the destination of B is only one (that is, the destination operand of A).
3. If the second analysis is satisfied, the compiler analyzes that to delay the object initialization from A to B does not violate the language specification.
4. If the third analysis is satisfied, the compiler eliminates the object initialization in A and generates the object initialization code after B for the regions where B does not modify.

Figure 1 shows an example of this optimization. This example comes from the java.lang.StringBuffer.expandCapacity method.

private void expandCapacity(int minimumCapacity) {

int newCapacity = (value.length + 1) * 2; - (1)

if (minimumCapacity > newCapacity) {

newCapacity = minimumCapacity;

}

char newValue[] = new char[newCapacity]; - (2)

System.arraycopy(value, 0, newValue, 0, count); - (3)

value = newValue;

shared = false;

}

Fig. 1. Example of the method java.lang.StringBuffer.expandCapacity

This example allocates an array object at (2) with the variable size "newCapacity" computed at (1). Without this optimization, object initialization is performed for whole area of the size "newCapacity" at (2). By this optimizatio...