My favorites | Sign in
Project Logo
                
New issue | Search
for
| Advanced search | Search tips
Issue 14: Boolean array set/get code generation not optimal
1 person starred this issue and may be notified of changes. Back to list
Status:  Accepted
Owner:  aviad.in...@gmail.com
Type-Enhancement
Priority-Low
Performance


Sign in to add a comment
 
Reported by aviad.in...@gmail.com, Aug 08, 2009
Since the opcode for set/get value to/from a boolean array is the same as it is for the byte array 
(BASTORE/BALOAD), and since the boolean array is saved as a java.lang.Object slot, and since 
there is no real way to tell which array it is from the Opcode. 

So the origin code of:
// method vars:
boolean[] arr = ...;
int idx = ...;
// code:
stack <- arr[idx];

Results in code that does essentially this:
// vars are promoted to member slots:
Object arr = this.slot$1; 
int idx = this.slot$2;
boolean c;
// need to know the type of array:
if (arr.getClass().getComponentType().equals(Byte.TYPE)) {
  stack <- java.lang.reflect.Array.getByte(arr, idx);
else {
  stack <- java.lang.reflect.Array.getBoolean(arr, idx);
}


This could be improved by looking-ahead and checking is the type of the assigned variable, and 
then create the correct CHECKCAST bytecode (to [Z or [B), or by keeping metadata on the slots so 
that we could tell what was their original type, even after merger with other types, to better 
deduce bytecode creation.
Sign in to add a comment

Hosted by Google Code