Fix default parameter remapping on inlining: support store instruction

#KT-7963 Fixed
This commit is contained in:
Michael Bogdanov
2015-06-08 14:33:28 +03:00
parent 7a1625fc9e
commit baa44e3d01
6 changed files with 35 additions and 1 deletions
@@ -443,4 +443,8 @@ public class InlineCodegenUtil {
public static int getLoadStoreArgSize(int opcode) {
return opcode == Opcodes.DSTORE || opcode == Opcodes.LSTORE || opcode == Opcodes.DLOAD || opcode == Opcodes.LLOAD ? 2 : 1;
}
public static boolean isStoreInstruction(int opcode) {
return opcode >= Opcodes.ISTORE && opcode <= Opcodes.ASTORE;
}
}
@@ -114,7 +114,11 @@ public class LocalVarRemapper {
StackValue value = remapInfo.value;
if (value instanceof StackValue.Local) {
if (remapInfo.parameterInfo != null) {
opcode = value.type.getOpcode(Opcodes.ILOAD);
//All remapped value parameters can't be rewritten except case of default ones.
//On remapping default parameter to actual value there is only one instruction that writes to it according to mask value
//but if such parameter remapped then it passed and this mask branch code never executed
//TODO add assertion about parameter default value: descriptor is required
opcode = value.type.getOpcode(InlineCodegenUtil.isStoreInstruction(opcode) ? Opcodes.ISTORE : Opcodes.ILOAD);
}
mv.visitVarInsn(opcode, ((StackValue.Local) value).index);
if (remapInfo.parameterInfo != null) {