Remove "operation" method from StackValue.kt;
Compilation fix: remove static import to kotlin from AsmUtil
This commit is contained in:
@@ -38,6 +38,7 @@ import org.jetbrains.jet.lang.resolve.annotations.AnnotationsPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.java.*;
|
||||
import org.jetbrains.jet.lang.resolve.java.descriptor.JavaCallableMemberDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.java.diagnostics.JvmDeclarationOrigin;
|
||||
import org.jetbrains.jet.lang.resolve.kotlin.PackagePartClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.types.Approximation;
|
||||
@@ -60,7 +61,6 @@ import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.JAVA_STRING_T
|
||||
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.getType;
|
||||
import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.ABI_VERSION_FIELD_NAME;
|
||||
import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.KotlinSyntheticClass;
|
||||
import static org.jetbrains.jet.lang.resolve.java.diagnostics.JvmDeclarationOrigin.NO_ORIGIN;
|
||||
import static org.jetbrains.jet.lang.resolve.java.mapping.PrimitiveTypesUtil.asmTypeForPrimitive;
|
||||
import static org.jetbrains.jet.lang.types.TypeUtils.isNullableType;
|
||||
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
|
||||
@@ -400,7 +400,7 @@ public class AsmUtil {
|
||||
//noinspection PointlessBitwiseExpression
|
||||
int access = NO_FLAG_PACKAGE_PRIVATE | ACC_SYNTHETIC | ACC_FINAL;
|
||||
for (Pair<String, Type> field : allFields) {
|
||||
builder.newField(NO_ORIGIN, access, field.first, field.second.getDescriptor(), null, null);
|
||||
builder.newField(JvmDeclarationOrigin.NO_ORIGIN, access, field.first, field.second.getDescriptor(), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -544,12 +544,6 @@ public class AsmUtil {
|
||||
v.add(expectedType);
|
||||
}
|
||||
|
||||
public static Type genNegate(Type expectedType, InstructionAdapter v) {
|
||||
expectedType = numberFunctionOperandType(expectedType);
|
||||
v.neg(expectedType);
|
||||
return expectedType;
|
||||
}
|
||||
|
||||
public static void swap(InstructionAdapter v, Type stackTop, Type afterTop) {
|
||||
if (stackTop.getSize() == 1) {
|
||||
if (afterTop.getSize() == 1) {
|
||||
|
||||
@@ -69,10 +69,6 @@ public class StackValueWithLeaveTask(
|
||||
}
|
||||
}
|
||||
|
||||
fun operation(resultType: Type, lambda: (v: InstructionAdapter) -> Unit): StackValue {
|
||||
return OperationStackValue(resultType, lambda)
|
||||
}
|
||||
|
||||
open class OperationStackValue(val resultType: Type, val lambda: (v: InstructionAdapter) -> Unit) : StackValue(resultType) {
|
||||
|
||||
override fun putSelector(type: Type, v: InstructionAdapter) {
|
||||
|
||||
@@ -18,11 +18,9 @@ package org.jetbrains.jet.codegen.intrinsics
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen
|
||||
import org.jetbrains.jet.codegen.StackValue
|
||||
import org.jetbrains.jet.lang.psi.JetExpression
|
||||
import org.jetbrains.jet.codegen.operation
|
||||
|
||||
public class ArraySize : LazyIntrinsicMethod() {
|
||||
override fun generateImpl(
|
||||
@@ -32,7 +30,7 @@ public class ArraySize : LazyIntrinsicMethod() {
|
||||
arguments: List<JetExpression>,
|
||||
receiver: StackValue
|
||||
): StackValue {
|
||||
return operation(Type.INT_TYPE) {
|
||||
return StackValue.operation(Type.INT_TYPE) {
|
||||
receiver.put(receiver.type, it)
|
||||
it.arraylength()
|
||||
}
|
||||
|
||||
@@ -19,12 +19,10 @@ package org.jetbrains.jet.codegen.intrinsics
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen
|
||||
import org.jetbrains.jet.codegen.StackValue
|
||||
import org.jetbrains.jet.lang.psi.JetExpression
|
||||
import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants
|
||||
import org.jetbrains.jet.codegen.operation
|
||||
|
||||
public class HashCode : LazyIntrinsicMethod() {
|
||||
override fun generateImpl(codegen: ExpressionCodegen,
|
||||
@@ -33,7 +31,7 @@ public class HashCode : LazyIntrinsicMethod() {
|
||||
arguments: List<JetExpression>,
|
||||
receiver: StackValue): StackValue {
|
||||
|
||||
return operation(Type.INT_TYPE) {
|
||||
return StackValue.operation(Type.INT_TYPE) {
|
||||
receiver.put(AsmTypeConstants.OBJECT_TYPE, it)
|
||||
it.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Object", "hashCode", "()I", false)
|
||||
}
|
||||
|
||||
@@ -20,17 +20,10 @@ import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen
|
||||
import org.jetbrains.jet.codegen.StackValue
|
||||
import org.jetbrains.jet.lang.psi.JetExpression
|
||||
import org.jetbrains.jet.lang.psi.JetPsiUtil
|
||||
import org.jetbrains.jet.lang.psi.JetReferenceExpression
|
||||
import org.jetbrains.jet.lang.types.JetType
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
|
||||
import org.jetbrains.jet.codegen.AsmUtil.genIncrement
|
||||
import org.jetbrains.jet.codegen.AsmUtil.isPrimitive
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext.EXPRESSION_TYPE
|
||||
import org.jetbrains.jet.codegen.operation
|
||||
|
||||
public class Increment(private val myDelta: Int) : LazyIntrinsicMethod() {
|
||||
|
||||
@@ -48,7 +41,7 @@ public class Increment(private val myDelta: Int) : LazyIntrinsicMethod() {
|
||||
}
|
||||
}
|
||||
else {
|
||||
return operation(returnType) {
|
||||
return StackValue.operation(returnType) {
|
||||
receiver.put(returnType, it)
|
||||
genIncrement(returnType, myDelta, it)
|
||||
}
|
||||
|
||||
@@ -18,11 +18,9 @@ package org.jetbrains.jet.codegen.intrinsics
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen
|
||||
import org.jetbrains.jet.codegen.StackValue
|
||||
import org.jetbrains.jet.lang.psi.JetExpression
|
||||
import org.jetbrains.jet.codegen.operation
|
||||
|
||||
public class StringGetChar : LazyIntrinsicMethod() {
|
||||
override fun generateImpl(codegen: ExpressionCodegen,
|
||||
@@ -31,7 +29,7 @@ public class StringGetChar : LazyIntrinsicMethod() {
|
||||
arguments: List<JetExpression>,
|
||||
receiver: StackValue): StackValue {
|
||||
|
||||
return operation(Type.CHAR_TYPE) {
|
||||
return StackValue.operation(Type.CHAR_TYPE) {
|
||||
if (receiver != StackValue.none()) {
|
||||
receiver.put(receiver.type, it)
|
||||
}
|
||||
|
||||
@@ -18,11 +18,9 @@ package org.jetbrains.jet.codegen.intrinsics
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen
|
||||
import org.jetbrains.jet.codegen.StackValue
|
||||
import org.jetbrains.jet.lang.psi.JetExpression
|
||||
import org.jetbrains.jet.codegen.operation
|
||||
|
||||
public class StringLength : LazyIntrinsicMethod() {
|
||||
override fun generateImpl(
|
||||
@@ -32,7 +30,7 @@ public class StringLength : LazyIntrinsicMethod() {
|
||||
arguments: List<JetExpression>,
|
||||
receiver: StackValue
|
||||
): StackValue {
|
||||
return operation(Type.INT_TYPE) {
|
||||
return StackValue.operation(Type.INT_TYPE) {
|
||||
receiver.put(receiver.type, it)
|
||||
it.invokeinterface("java/lang/CharSequence", "length", "()I")
|
||||
}
|
||||
|
||||
@@ -21,11 +21,9 @@ import org.jetbrains.jet.codegen.ExpressionCodegen
|
||||
import org.jetbrains.jet.codegen.StackValue
|
||||
import org.jetbrains.jet.lang.psi.JetExpression
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
|
||||
import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.JAVA_STRING_TYPE
|
||||
import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.OBJECT_TYPE
|
||||
import org.jetbrains.jet.codegen.operation
|
||||
|
||||
public class StringPlus : LazyIntrinsicMethod() {
|
||||
override fun generateImpl(
|
||||
@@ -35,7 +33,7 @@ public class StringPlus : LazyIntrinsicMethod() {
|
||||
arguments: List<JetExpression>,
|
||||
receiver: StackValue
|
||||
): StackValue {
|
||||
return operation(JAVA_STRING_TYPE) {
|
||||
return StackValue.operation(JAVA_STRING_TYPE) {
|
||||
if (receiver == StackValue.none()) {
|
||||
codegen.gen(arguments.get(0)).put(JAVA_STRING_TYPE, it)
|
||||
codegen.gen(arguments.get(1)).put(OBJECT_TYPE, it)
|
||||
|
||||
@@ -18,13 +18,11 @@ package org.jetbrains.jet.codegen.intrinsics
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen
|
||||
import org.jetbrains.jet.codegen.StackValue
|
||||
import org.jetbrains.jet.lang.psi.JetExpression
|
||||
|
||||
import org.jetbrains.jet.codegen.AsmUtil.*
|
||||
import org.jetbrains.jet.codegen.operation
|
||||
|
||||
public class UnaryMinus : LazyIntrinsicMethod() {
|
||||
|
||||
@@ -39,9 +37,9 @@ public class UnaryMinus : LazyIntrinsicMethod() {
|
||||
|
||||
val newreceiver = if (arguments.size() == 1) codegen.gen(arguments.get(0)) else receiver
|
||||
|
||||
return operation(operandType) {
|
||||
return StackValue.operation(operandType) {
|
||||
newreceiver.put(operandType, it)
|
||||
genNegate(operandType, it)
|
||||
it.neg(operandType)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
class A
|
||||
class B
|
||||
|
||||
var holder = 0
|
||||
|
||||
fun A.not(): A {
|
||||
holder++
|
||||
return this;
|
||||
}
|
||||
|
||||
fun B.not(): Boolean {
|
||||
holder++
|
||||
return false;
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
!!!!!A()
|
||||
if (holder != 5) return "fail 1"
|
||||
|
||||
holder = 0;
|
||||
if (!!!B() || holder != 1) return "fail 2"
|
||||
|
||||
if (!B() != false) return "fail 3"
|
||||
|
||||
if (!!B() != true) return "fail 4"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+6
@@ -1582,6 +1582,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/lazyCodegen/optimizations/negateTrueVar.kt");
|
||||
doTestWithStdlib(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("noOptimization.kt")
|
||||
public void testNoOptimization() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/lazyCodegen/optimizations/noOptimization.kt");
|
||||
doTestWithStdlib(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user