Get rid of store
This commit is contained in:
@@ -656,7 +656,7 @@ public class AsmUtil {
|
||||
return new StackValue.StackValueWithoutReceiver(stackValue.type) {
|
||||
|
||||
@Override
|
||||
public void put(Type type, InstructionAdapter v) {
|
||||
public void put(@NotNull Type type, @NotNull InstructionAdapter v) {
|
||||
stackValue.put(type, v);
|
||||
if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) {
|
||||
v.dup();
|
||||
|
||||
@@ -3140,7 +3140,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
if (Boolean.TRUE.equals(bindingContext.get(VARIABLE_REASSIGNMENT, expression))) {
|
||||
if (callable instanceof IntrinsicMethod) {
|
||||
StackValue value = gen(lhs); // receiver
|
||||
value = StackValue.complexReceiver(value, StackValue.RECEIVER_WRITE, StackValue.RECEIVER_READ);
|
||||
value = StackValue.complexWriteReadReceiver(value);
|
||||
|
||||
value.put(lhsType, v); // receiver lhs
|
||||
Type returnType = typeMapper.mapType(descriptor);
|
||||
@@ -3171,7 +3171,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
) {
|
||||
StackValue value = gen(expression.getLeft());
|
||||
if (keepReturnValue) {
|
||||
value = StackValue.complexReceiver(value, StackValue.RECEIVER_WRITE, StackValue.RECEIVER_READ);
|
||||
value = StackValue.complexWriteReadReceiver(value);
|
||||
//value.putWriteReadReceiver(v);
|
||||
}
|
||||
value.put(lhsType, v);
|
||||
@@ -3180,7 +3180,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
invokeMethodWithArguments(callable, resolvedCall, receiver);
|
||||
|
||||
if (keepReturnValue) {
|
||||
value.store(callable.getReturnType(), v);
|
||||
value.store(StackValue.onStack(callable.getReturnType()), v, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3307,12 +3307,12 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
@Override
|
||||
public Unit invoke(InstructionAdapter adapter) {
|
||||
StackValue value = gen(expression.getBaseExpression());
|
||||
value = StackValue.complexReceiver(value, StackValue.RECEIVER_WRITE, StackValue.RECEIVER_READ);
|
||||
value = StackValue.complexWriteReadReceiver(value);
|
||||
|
||||
Type type = expressionType(expression.getBaseExpression());
|
||||
value.put(type, v); // old value
|
||||
|
||||
pushReceiverAndValueViaDup(value, type); // receiver and new value
|
||||
value.dup(v, true);
|
||||
|
||||
Type storeType;
|
||||
if (isPrimitiveNumberClassDescriptor && AsmUtil.isPrimitive(asmBaseType)) {
|
||||
@@ -3325,16 +3325,12 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
storeType = result.type;
|
||||
}
|
||||
|
||||
value.store(storeType, v);
|
||||
value.store(StackValue.onStack(storeType), v, true);
|
||||
return Unit.INSTANCE$;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void pushReceiverAndValueViaDup(StackValue value, Type type) {
|
||||
value.dup(v, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StackValue visitProperty(@NotNull JetProperty property, StackValue receiver) {
|
||||
final JetExpression initializer = property.getInitializer();
|
||||
|
||||
@@ -917,7 +917,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
property.put(property.type, iv);
|
||||
}
|
||||
else {
|
||||
property.store(property.type, iv);
|
||||
property.store(StackValue.onStack(property.type), iv, true);
|
||||
}
|
||||
|
||||
iv.areturn(signature.getReturnType());
|
||||
@@ -1072,7 +1072,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
ExpressionCodegen codegen = createOrGetClInitCodegen();
|
||||
FunctionDescriptor constructor = codegen.accessibleFunctionDescriptor(KotlinPackage.single(classObject.getConstructors()));
|
||||
generateMethodCallTo(constructor, codegen.v);
|
||||
StackValue.singleton(classObject, typeMapper).store(typeMapper.mapClass(classObject), codegen.v);
|
||||
StackValue.singleton(classObject, typeMapper).store(StackValue.onStack(typeMapper.mapClass(classObject)), codegen.v, true);
|
||||
}
|
||||
|
||||
private void generatePrimaryConstructor(final DelegationFieldsInfo delegationFieldsInfo) {
|
||||
|
||||
@@ -433,7 +433,7 @@ public abstract class StackValue implements StackValueI {
|
||||
|
||||
public static Field singleton(ClassDescriptor classDescriptor, JetTypeMapper typeMapper) {
|
||||
FieldInfo info = FieldInfo.createForSingleton(classDescriptor, typeMapper);
|
||||
return field(info.getFieldType(), Type.getObjectType(info.getOwnerInternalName()), info.getFieldName(), true, StackValue.none());
|
||||
return field(info.getFieldType(), Type.getObjectType(info.getOwnerInternalName()), info.getFieldName(), true, none());
|
||||
}
|
||||
|
||||
public static StackValue operation(Type type, Function1<InstructionAdapter, Unit> lambda) {
|
||||
@@ -552,7 +552,7 @@ public abstract class StackValue implements StackValueI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void condJump(Label label, boolean jumpIfFalse, InstructionAdapter v) {
|
||||
public void condJump(@NotNull Label label, boolean jumpIfFalse, @NotNull InstructionAdapter v) {
|
||||
if (value instanceof Boolean) {
|
||||
boolean boolValue = (Boolean) value;
|
||||
if (boolValue ^ jumpIfFalse) {
|
||||
@@ -586,7 +586,7 @@ public abstract class StackValue implements StackValueI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void condJump(Label label, boolean jumpIfFalse, InstructionAdapter v) {
|
||||
public void condJump(@NotNull Label label, boolean jumpIfFalse, @NotNull InstructionAdapter v) {
|
||||
left.put(this.operandType, v);
|
||||
right.put(this.operandType, v);
|
||||
int opcode;
|
||||
@@ -635,7 +635,7 @@ public abstract class StackValue implements StackValueI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void condJump(Label label, boolean jumpIfFalse, InstructionAdapter v) {
|
||||
public void condJump(@NotNull Label label, boolean jumpIfFalse, @NotNull InstructionAdapter v) {
|
||||
left.put(this.operandType, v);
|
||||
right.put(this.operandType, v);
|
||||
int opcode;
|
||||
@@ -670,7 +670,7 @@ public abstract class StackValue implements StackValueI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void condJump(Label label, boolean jumpIfFalse, InstructionAdapter v) {
|
||||
public void condJump(@NotNull Label label, boolean jumpIfFalse, @NotNull InstructionAdapter v) {
|
||||
myOperand.condJump(label, !jumpIfFalse, v);
|
||||
}
|
||||
}
|
||||
@@ -1278,9 +1278,9 @@ public abstract class StackValue implements StackValueI {
|
||||
|
||||
private static class PrefixIncrement extends StackValueWithoutReceiver {
|
||||
private final int delta;
|
||||
private Callable callable;
|
||||
private ResolvedCall resolvedCall;
|
||||
private ExpressionCodegen codegen;
|
||||
private final Callable callable;
|
||||
private final ResolvedCall resolvedCall;
|
||||
private final ExpressionCodegen codegen;
|
||||
private StackValue value;
|
||||
|
||||
public PrefixIncrement(
|
||||
@@ -1309,10 +1309,10 @@ public abstract class StackValue implements StackValueI {
|
||||
}
|
||||
else {
|
||||
genIncrement(this.type, delta, v);
|
||||
value.store(this.type, v);
|
||||
value.store(StackValue.onStack(this.type), v, true);
|
||||
}
|
||||
|
||||
StackValue.putNoReceiver(value, this.type, v);
|
||||
putNoReceiver(value, this.type, v);
|
||||
coerceTo(type, v);
|
||||
}
|
||||
}
|
||||
@@ -1460,6 +1460,7 @@ public abstract class StackValue implements StackValueI {
|
||||
@Override
|
||||
public abstract void putNoReceiver(@NotNull Type type, @NotNull InstructionAdapter v);
|
||||
|
||||
@Override
|
||||
public void putReceiver(@NotNull InstructionAdapter v, boolean isRead) {
|
||||
if (hasReceiver(isRead)) {
|
||||
receiver.put(receiver.type, v);
|
||||
@@ -1498,7 +1499,7 @@ public abstract class StackValue implements StackValueI {
|
||||
@Override
|
||||
public void dup(@NotNull InstructionAdapter v, boolean withReceiver) {
|
||||
if (!withReceiver) {
|
||||
super.dup(v, withReceiver);
|
||||
super.dup(v, false);
|
||||
} else {
|
||||
int receiverSize = hasReceiver(false) && hasReceiver(true) ? receiverSize() : 0;
|
||||
switch (receiverSize) {
|
||||
@@ -1646,7 +1647,11 @@ public abstract class StackValue implements StackValueI {
|
||||
}
|
||||
}
|
||||
|
||||
public static StackValue complexReceiver(StackValue stackValue, int ... operations) {
|
||||
public static StackValue complexWriteReadReceiver(StackValue stackValue) {
|
||||
return complexReceiver(stackValue, RECEIVER_WRITE, RECEIVER_READ);
|
||||
}
|
||||
|
||||
private static StackValue complexReceiver(StackValue stackValue, int ... operations) {
|
||||
if (stackValue instanceof StackValueWithoutReceiver) {
|
||||
return stackValue;
|
||||
} else {
|
||||
@@ -1659,7 +1664,7 @@ public abstract class StackValue implements StackValueI {
|
||||
}
|
||||
}
|
||||
|
||||
public static void putNoReceiver(StackValue value, Type type, InstructionAdapter iv) {
|
||||
private static void putNoReceiver(StackValue value, Type type, InstructionAdapter iv) {
|
||||
if (value instanceof StackValueWithSimpleReceiver) {
|
||||
((StackValueWithSimpleReceiver) value).putNoReceiver(type, iv);
|
||||
} else {
|
||||
|
||||
@@ -77,7 +77,7 @@ public class TailRecursionCodegen {
|
||||
if (callable.getReceiverClass() != null) {
|
||||
if (resolvedCall.getExtensionReceiver() != fd.getExtensionReceiverParameter().getValue()) {
|
||||
StackValue expression = context.getReceiverExpression(codegen.typeMapper);
|
||||
expression.store(callable.getReceiverClass(), v);
|
||||
expression.store(StackValue.onStack(callable.getReceiverClass()), v, true);
|
||||
}
|
||||
else {
|
||||
AsmUtil.pop(v, callable.getReceiverClass());
|
||||
|
||||
Reference in New Issue
Block a user