Refine types returned by OptimizationBasicInterpreter.newValue

#KT-12958 Fixed
This commit is contained in:
Denis Zharkov
2016-07-04 15:03:22 +03:00
parent 17a41ecc79
commit df4bf61378
3 changed files with 48 additions and 4 deletions
@@ -50,6 +50,7 @@ public class OptimizationBasicInterpreter extends BasicInterpreter {
case Type.SHORT:
return SHORT_VALUE;
case Type.OBJECT:
case Type.ARRAY:
return new BasicValue(type);
default:
return super.newValue(type);
@@ -78,13 +79,10 @@ public class OptimizationBasicInterpreter extends BasicInterpreter {
}
// if merge of two references then `lub` is java/lang/Object
// arrays also are BasicValues with reference type's
if (v.getType().getSort() == Type.OBJECT && w.getType().getSort() == Type.OBJECT) {
if (isReference(v) && isReference(w)) {
return BasicValue.REFERENCE_VALUE;
}
assert v.getType().getSort() != Type.ARRAY && w.getType().getSort() != Type.ARRAY : "There should not be arrays";
// if merge of something can be stored in int var (int, char, boolean, byte, character)
if (v.getType().getOpcode(Opcodes.ISTORE) == Opcodes.ISTORE &&
w.getType().getOpcode(Opcodes.ISTORE) == Opcodes.ISTORE) {
@@ -93,4 +91,8 @@ public class OptimizationBasicInterpreter extends BasicInterpreter {
return BasicValue.UNINITIALIZED_VALUE;
}
private static boolean isReference(@NotNull BasicValue v) {
return v.getType().getSort() == Type.OBJECT || v.getType().getSort() == Type.ARRAY;
}
}