# HG changeset patch # User Josef Eisl # Date 1407514430 -7200 # Node ID 705cebda4776b0e6125ebe1b5d8e3dccdcf94553 # Parent bc1b601dabc91eeb91fb56307dba79a98ec3c5d9 Clone CompositeValue in LIRIntrospection.forEachComponent(). diff -r bc1b601dabc9 -r 705cebda4776 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRIntrospection.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRIntrospection.java Thu Aug 07 14:36:28 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRIntrospection.java Fri Aug 08 18:13:50 2014 +0200 @@ -153,6 +153,7 @@ protected static CompositeValue forEachComponent(LIRInstruction inst, CompositeValue obj, int directCount, long[] offsets, OperandMode mode, EnumSet[] flags, InstructionValueProcedure proc) { + CompositeValue newCompValue = null; for (int i = 0; i < offsets.length; i++) { assert LIRInstruction.ALLOWED_FLAGS.get(mode).containsAll(flags[i]); @@ -165,9 +166,16 @@ } else { newValue = proc.doValue(inst, value, mode, flags[i]); } - setValue(obj, offsets[i], newValue); + if (!value.identityEquals(newValue)) { + // lazy initialize + if (newCompValue == null) { + newCompValue = obj.clone(); + } + setValue(newCompValue, offsets[i], newValue); + } } else { Value[] values = getValueArray(obj, offsets[i]); + Value[] newValues = null; for (int j = 0; j < values.length; j++) { Value value = values[j]; Value newValue; @@ -177,11 +185,20 @@ } else { newValue = proc.doValue(inst, value, mode, flags[i]); } - values[j] = newValue; + if (!value.identityEquals(newValue)) { + // lazy initialize + if (newValues == null) { + if (newCompValue == null) { + newCompValue = obj.clone(); + } + newValues = getValueArray(newCompValue, offsets[i]); + } + newValues[j] = newValue; + } } } } - return obj; + return newCompValue != null ? newCompValue : obj; } protected static void forEach(LIRInstruction inst, Object obj, int directCount, long[] offsets, OperandMode mode, EnumSet[] flags, ValuePositionProcedure proc,