Fix for KT-9897: Cannot pop operand off an empty stack" with -= on ArrayList element
#KT-9897 Fixed
This commit is contained in:
@@ -835,7 +835,10 @@ public class AsmUtil {
|
||||
}
|
||||
|
||||
public static void dup(@NotNull InstructionAdapter v, @NotNull Type type) {
|
||||
int size = type.getSize();
|
||||
dup(v, type.getSize());
|
||||
}
|
||||
|
||||
private static void dup(@NotNull InstructionAdapter v, int size) {
|
||||
if (size == 2) {
|
||||
v.dup2();
|
||||
}
|
||||
@@ -847,6 +850,36 @@ public class AsmUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void dup(@NotNull InstructionAdapter v, @NotNull Type topOfStack, @NotNull Type afterTop) {
|
||||
if (topOfStack.getSize() == 0 && afterTop.getSize() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (topOfStack.getSize() == 0) {
|
||||
dup(v, afterTop);
|
||||
}
|
||||
else if (afterTop.getSize() == 0) {
|
||||
dup(v, topOfStack);
|
||||
}
|
||||
else if (afterTop.getSize() == 1) {
|
||||
if (topOfStack.getSize() == 1) {
|
||||
dup(v, 2);
|
||||
}
|
||||
else {
|
||||
v.dup2X1();
|
||||
v.pop2();
|
||||
v.dupX2();
|
||||
v.dupX2();
|
||||
v.pop();
|
||||
v.dup2X1();
|
||||
}
|
||||
}
|
||||
else {
|
||||
//Note: it's possible to write dup3 and dup4
|
||||
throw new UnsupportedOperationException("Don't know how generate dup3/dup4 for: " + topOfStack + " and " + afterTop);
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeKotlinSyntheticClassAnnotation(@NotNull ClassBuilder v, @NotNull GenerationState state) {
|
||||
AnnotationVisitor av = v.newAnnotation(asmDescByFqNameWithoutInnerClasses(KOTLIN_SYNTHETIC_CLASS), true);
|
||||
JvmCodegenUtil.writeAbiVersion(av);
|
||||
|
||||
@@ -771,12 +771,12 @@ public abstract class StackValue {
|
||||
private final boolean isGetter;
|
||||
private final ExpressionCodegen codegen;
|
||||
private final ArgumentGenerator argumentGenerator;
|
||||
final List<ResolvedValueArgument> valueArguments;
|
||||
private final List<ResolvedValueArgument> valueArguments;
|
||||
private final FrameMap frame;
|
||||
private final StackValue receiver;
|
||||
private final ResolvedCall<FunctionDescriptor> resolvedGetCall;
|
||||
private final ResolvedCall<FunctionDescriptor> resolvedSetCall;
|
||||
DefaultCallMask mask;
|
||||
private DefaultCallMask mask;
|
||||
|
||||
public CollectionElementReceiver(
|
||||
@NotNull Callable callable,
|
||||
@@ -1424,6 +1424,11 @@ public abstract class StackValue {
|
||||
currentExtensionReceiver
|
||||
.moveToTopOfStack(hasExtensionReceiver ? type : currentExtensionReceiver.type, v, dispatchReceiver.type.getSize());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dup(@NotNull InstructionAdapter v, boolean withReceiver) {
|
||||
AsmUtil.dup(v, extensionReceiver.type, dispatchReceiver.type);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract static class StackValueWithSimpleReceiver extends StackValue {
|
||||
|
||||
Reference in New Issue
Block a user