From 0a10cec579c4398426e0e5869508f048b41d8ad0 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 2 Sep 2021 02:23:01 +0200 Subject: [PATCH] Remove obsolete -X compiler arguments for JVM backend -Xno-exception-on-explicit-equals-for-boxed-null -Xstrict-java-nullability-assertions -Xuse-old-spilled-var-type-analysis -Xpolymorphic-signature --- .../codegen/coroutines/CoroutineCodegen.kt | 2 - .../CoroutineTransformerMethodVisitor.kt | 6 +- .../SuspendFunctionGenerationStrategy.kt | 2 - .../coroutines/refinedIntTypesAnalysis.kt | 221 ------------------ .../inline/coroutines/CoroutineTransformer.kt | 3 - .../kotlin/codegen/intrinsics/Equals.kt | 13 -- .../codegen/intrinsics/IntrinsicMethods.java | 17 +- .../kotlin/codegen/state/GenerationState.kt | 6 +- .../arguments/CommonCompilerArguments.kt | 10 - .../arguments/K2JVMCompilerArguments.kt | 18 -- .../jetbrains/kotlin/cli/jvm/jvmArguments.kt | 5 - .../kotlin/config/JVMConfigurationKeys.java | 5 - .../backend/jvm/codegen/CoroutineCodegen.kt | 2 - compiler/testData/cli/js/jsExtraHelp.out | 1 - compiler/testData/cli/jvm/extraHelp.out | 7 - 15 files changed, 6 insertions(+), 312 deletions(-) delete mode 100644 compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/refinedIntTypesAnalysis.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineCodegen.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineCodegen.kt index a5e0849ae01..a037b099a5f 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineCodegen.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineCodegen.kt @@ -17,7 +17,6 @@ import org.jetbrains.kotlin.codegen.context.MethodContext import org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings.METHOD_FOR_FUNCTION import org.jetbrains.kotlin.codegen.serialization.JvmSerializerExtension import org.jetbrains.kotlin.codegen.state.GenerationState -import org.jetbrains.kotlin.config.JVMConfigurationKeys import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor @@ -526,7 +525,6 @@ class CoroutineCodegenForLambda private constructor( reportSuspensionPointInsideMonitor = { reportSuspensionPointInsideMonitor(element, state, it) }, lineNumber = CodegenUtil.getLineNumberForElement(element, false) ?: 0, sourceFile = element.containingKtFile.name, - useOldSpilledVarTypeAnalysis = state.configuration.getBoolean(JVMConfigurationKeys.USE_OLD_SPILLED_VAR_TYPE_ANALYSIS), initialVarsCountByType = varsCountByType ) val maybeWithForInline = if (forInline) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformerMethodVisitor.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformerMethodVisitor.kt index be420cae41f..9aab6637fe4 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformerMethodVisitor.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformerMethodVisitor.kt @@ -59,8 +59,6 @@ class CoroutineTransformerMethodVisitor( private val internalNameForDispatchReceiver: String? = null, // JVM_IR backend generates $completion, while old backend does not private val putContinuationParameterToLvt: Boolean = true, - // New SourceInterpreter-less analyser can be somewhat unstable, disable it - private val useOldSpilledVarTypeAnalysis: Boolean = false, // Parameters of suspend lambda are put to the same fields as spilled variables private val initialVarsCountByType: Map = emptyMap() ) : TransformationMethodVisitor(delegate, access, name, desc, signature, exceptions) { @@ -583,9 +581,7 @@ class CoroutineTransformerMethodVisitor( private fun spillVariables(suspensionPoints: List, methodNode: MethodNode): List> { val instructions = methodNode.instructions - val frames = - if (useOldSpilledVarTypeAnalysis) performRefinedTypeAnalysis(methodNode, containingClassInternalName) - else performSpilledVariableFieldTypesAnalysis(methodNode, containingClassInternalName) + val frames = performSpilledVariableFieldTypesAnalysis(methodNode, containingClassInternalName) fun AbstractInsnNode.index() = instructions.indexOf(this) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/SuspendFunctionGenerationStrategy.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/SuspendFunctionGenerationStrategy.kt index 62eff70be58..bde418acfb0 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/SuspendFunctionGenerationStrategy.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/SuspendFunctionGenerationStrategy.kt @@ -12,7 +12,6 @@ import org.jetbrains.kotlin.codegen.inline.addFakeContinuationConstructorCallMar import org.jetbrains.kotlin.codegen.inline.coroutines.FOR_INLINE_SUFFIX import org.jetbrains.kotlin.codegen.inline.preprocessSuspendMarkers import org.jetbrains.kotlin.codegen.state.GenerationState -import org.jetbrains.kotlin.config.JVMConfigurationKeys import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.config.languageVersionSettings import org.jetbrains.kotlin.descriptors.ClassDescriptor @@ -96,7 +95,6 @@ class SuspendFunctionGenerationStrategy( internalNameForDispatchReceiver = (originalSuspendDescriptor.containingDeclaration as? ClassDescriptor)?.let { if (it.isInlineClass()) state.typeMapper.mapType(it).internalName else null } ?: containingClassInternalNameOrNull(), - useOldSpilledVarTypeAnalysis = state.configuration.getBoolean(JVMConfigurationKeys.USE_OLD_SPILLED_VAR_TYPE_ANALYSIS) ) } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/refinedIntTypesAnalysis.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/refinedIntTypesAnalysis.kt deleted file mode 100644 index 5295b3ea431..00000000000 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/refinedIntTypesAnalysis.kt +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.codegen.coroutines - -import org.jetbrains.kotlin.codegen.optimization.common.* -import org.jetbrains.kotlin.codegen.optimization.fixStack.peek -import org.jetbrains.kotlin.codegen.optimization.fixStack.top -import org.jetbrains.kotlin.codegen.optimization.transformer.MethodTransformer -import org.jetbrains.org.objectweb.asm.Opcodes -import org.jetbrains.org.objectweb.asm.Type -import org.jetbrains.org.objectweb.asm.tree.* -import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue -import org.jetbrains.org.objectweb.asm.tree.analysis.Frame -import org.jetbrains.org.objectweb.asm.tree.analysis.SourceInterpreter -import org.jetbrains.org.objectweb.asm.tree.analysis.SourceValue -import java.util.* - -// BasicValue interpreter from ASM does not distinct 'int' types from other int-like types like 'byte' or 'boolean', -// neither do HotSpot and JVM spec. -// But it seems like Dalvik does not follow it, and spilling boolean value into an 'int' field fails with VerifyError on Android 4, -// so this function calculates refined frames' markup. -// Note that type of some values is only possible to determine by their usages (e.g. ICONST_1, BALOAD both may push boolean or byte on stack) -internal fun performRefinedTypeAnalysis(methodNode: MethodNode, thisName: String): Array?> { - val insnList = methodNode.instructions - val basicFrames = MethodTransformer.analyze(thisName, methodNode, OptimizationBasicInterpreter()) - val sourceValueFrames = MethodTransformer.analyze(thisName, methodNode, MySourceInterpreter()) - - val expectedTypeAndSourcesByInsnIndex: Array>?> = arrayOfNulls(insnList.size()) - - fun AbstractInsnNode.index() = insnList.indexOf(this) - - fun saveExpectedType(value: SourceValue?, expectedType: Type) { - if (value == null) return - if (expectedType.sort !in REFINED_INT_SORTS) return - - for (insn in value.insns) { - // If source is something like ICONST_0, ignore it - if (!insn.isIntLoad()) continue - val index = insnList.indexOf(insn) - - checkUpdatedExpectedType(expectedTypeAndSourcesByInsnIndex[index]?.first, expectedType) - - expectedTypeAndSourcesByInsnIndex[index] = - Pair(expectedType, - expectedTypeAndSourcesByInsnIndex[index]?.second.orEmpty() + value) - } - } - - fun saveExpectedTypeForArrayStore(insn: AbstractInsnNode, sourceValueFrame: Frame) { - val arrayStoreType = - when (insn.opcode) { - Opcodes.BASTORE -> Type.BYTE_TYPE - Opcodes.CASTORE -> Type.CHAR_TYPE - Opcodes.SASTORE -> Type.SHORT_TYPE - else -> return - } - - val insnIndex = insnList.indexOf(insn) - - val arrayArg = basicFrames[insnIndex].peek(2) - // may be different from 'arrayStoreType' in case of boolean arrays (BASTORE opcode is also used for them) - val expectedType = - if (arrayArg?.type?.sort == Type.ARRAY) - arrayArg.type.elementType - else - arrayStoreType - - saveExpectedType(sourceValueFrame.top(), expectedType) - } - - fun saveExpectedTypeForFieldOrMethod(insn: AbstractInsnNode, sourceValueFrame: Frame) { - when (insn.opcode) { - Opcodes.PUTFIELD, Opcodes.PUTSTATIC -> - saveExpectedType(sourceValueFrame.top(), Type.getType((insn as FieldInsnNode).desc)) - - Opcodes.INVOKESTATIC, Opcodes.INVOKEVIRTUAL, Opcodes.INVOKEINTERFACE, Opcodes.INVOKESPECIAL -> { - val argumentTypes = Type.getArgumentTypes((insn as MethodInsnNode).desc) - argumentTypes.withIndex().forEach { - val (argIndex, type) = it - saveExpectedType(sourceValueFrame.peek(argumentTypes.size - argIndex - 1), type) - } - } - } - } - - fun saveExpectedTypeForVarStore(insn: AbstractInsnNode, sourceValueFrame: Frame) { - if (insn.isIntStore()) { - val varIndex = (insn as VarInsnNode).`var` - // Considering next insn is important because variable initializer is emitted just before - // the beginning of variable - val nextInsn = InsnSequence(insn.next, insnList.last).firstOrNull(AbstractInsnNode::isMeaningful) - - val variableNode = - methodNode.findContainingVariableFromTable(insn, varIndex) - ?: methodNode.findContainingVariableFromTable(nextInsn ?: return, varIndex) - ?: return - - saveExpectedType(sourceValueFrame.top(), Type.getType(variableNode.desc)) - } - } - - for ((insnIndex, insn) in insnList.toArray().withIndex()) { - assert(insn.opcode != Opcodes.IRETURN) { - "Coroutine body must not contain IRETURN instructions because 'doResume' is always void" - } - - val sourceValueFrame = sourceValueFrames[insnIndex] ?: continue - - saveExpectedTypeForArrayStore(insn, sourceValueFrame) - saveExpectedTypeForFieldOrMethod(insn, sourceValueFrame) - saveExpectedTypeForVarStore(insn, sourceValueFrame) - } - - val refinedVarFrames = analyze(methodNode, object : BackwardAnalysisInterpreter { - override fun newFrame(maxLocals: Int): VarExpectedTypeFrame = VarExpectedTypeFrame(maxLocals) - - override fun def(frame: VarExpectedTypeFrame, insn: AbstractInsnNode) { - if (insn.isIntStore()) { - frame.expectedTypeByVarIndex[(insn as VarInsnNode).`var`] = null - } - } - - override fun use(frame: VarExpectedTypeFrame, insn: AbstractInsnNode) { - val (expectedType, sources) = expectedTypeAndSourcesByInsnIndex[insn.index()] ?: return - - sources.flatMap(SourceValue::insns).forEach { insnNode -> - if (insnNode.isIntLoad()) { - frame.updateExpectedType((insnNode as VarInsnNode).`var`, expectedType) - } - } - } - }) - - return Array(basicFrames.size) { - insnIndex -> - val current = Frame(basicFrames[insnIndex] ?: return@Array null) - - refinedVarFrames[insnIndex].expectedTypeByVarIndex.withIndex().filter { it.value != null }.forEach { - assert(current.getLocal(it.index)?.type?.sort in ALL_INT_SORTS) { - "int type expected, but ${current.getLocal(it.index)?.type} was found in basic frames" - } - - current.setLocal(it.index, StrictBasicValue(it.value)) - } - - current - } -} - -private fun AbstractInsnNode.isIntLoad() = opcode == Opcodes.ILOAD -private fun AbstractInsnNode.isIntStore() = opcode == Opcodes.ISTORE - -private fun checkUpdatedExpectedType(was: Type?, new: Type) { - assert(was == null || was == new) { - "Conflicting expected types: $was/$new" - } -} - -private class MySourceInterpreter : SourceInterpreter(Opcodes.API_VERSION) { - override fun copyOperation(insn: AbstractInsnNode, value: SourceValue) = - when { - insn.isStoreOperation() || insn.isLoadOperation() -> SourceValue(value.size, insn) - // For DUP* instructions return the same value (effectively ignore DUP's) - else -> value - } -} - -private val REFINED_INT_SORTS = setOf(Type.BOOLEAN, Type.CHAR, Type.BYTE, Type.SHORT) -private val ALL_INT_SORTS = REFINED_INT_SORTS + Type.INT - -private fun MethodNode.findContainingVariableFromTable(insn: AbstractInsnNode, varIndex: Int): LocalVariableNode? { - val insnIndex = instructions.indexOf(insn) - return localVariables.firstOrNull { - it.index == varIndex && it.rangeContainsInsn(insnIndex, instructions) - } -} - -private fun LocalVariableNode.rangeContainsInsn(insnIndex: Int, insnList: InsnList) = - insnList.indexOf(start) < insnIndex && insnIndex < insnList.indexOf(end) - -private class VarExpectedTypeFrame(maxLocals: Int) : VarFrame { - val expectedTypeByVarIndex = arrayOfNulls(maxLocals) - - override fun mergeFrom(other: VarExpectedTypeFrame) { - assert(expectedTypeByVarIndex.size == other.expectedTypeByVarIndex.size) { - "Other VarExpectedTypeFrame has different size: ${expectedTypeByVarIndex.size} / ${other.expectedTypeByVarIndex.size}" - } - - for ((varIndex, type) in other.expectedTypeByVarIndex.withIndex()) { - updateExpectedType(varIndex, type ?: continue) - } - } - - fun updateExpectedType(varIndex: Int, new: Type) { - val was = expectedTypeByVarIndex[varIndex] - // Widening to int is always allowed - if (new == Type.INT_TYPE) return - - checkUpdatedExpectedType(was, new) - - expectedTypeByVarIndex[varIndex] = new - } - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other == null || other::class.java != this::class.java) return false - - other as VarExpectedTypeFrame - - if (!Arrays.equals(expectedTypeByVarIndex, other.expectedTypeByVarIndex)) return false - - return true - } - - override fun hashCode(): Int { - return Arrays.hashCode(expectedTypeByVarIndex) - } -} diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/coroutines/CoroutineTransformer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/coroutines/CoroutineTransformer.kt index 4fcd2163a19..46394d8e651 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/coroutines/CoroutineTransformer.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/coroutines/CoroutineTransformer.kt @@ -11,7 +11,6 @@ import org.jetbrains.kotlin.codegen.coroutines.* import org.jetbrains.kotlin.codegen.inline.* import org.jetbrains.kotlin.codegen.optimization.common.asSequence import org.jetbrains.kotlin.codegen.optimization.transformer.MethodTransformer -import org.jetbrains.kotlin.config.JVMConfigurationKeys import org.jetbrains.kotlin.resolve.jvm.AsmTypes import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin import org.jetbrains.org.objectweb.asm.MethodVisitor @@ -92,7 +91,6 @@ class CoroutineTransformer( // TODO: this linenumbers might not be correct and since they are used only for step-over, check them. lineNumber = inliningContext.callSiteInfo.lineNumber, sourceFile = inliningContext.callSiteInfo.file?.name ?: "", - useOldSpilledVarTypeAnalysis = state.configuration.getBoolean(JVMConfigurationKeys.USE_OLD_SPILLED_VAR_TYPE_ANALYSIS) ) if (generateForInline) @@ -127,7 +125,6 @@ class CoroutineTransformer( needDispatchReceiver = true, internalNameForDispatchReceiver = classBuilder.thisName, putContinuationParameterToLvt = !state.isIrBackend, - useOldSpilledVarTypeAnalysis = state.configuration.getBoolean(JVMConfigurationKeys.USE_OLD_SPILLED_VAR_TYPE_ANALYSIS) ) if (generateForInline) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Equals.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Equals.kt index 6950ba3ba87..d05fd8571b7 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Equals.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Equals.kt @@ -18,25 +18,12 @@ package org.jetbrains.kotlin.codegen.intrinsics import org.jetbrains.kotlin.codegen.Callable import org.jetbrains.kotlin.codegen.CallableMethod -import org.jetbrains.kotlin.codegen.DescriptorAsmUtil import org.jetbrains.kotlin.resolve.jvm.AsmTypes.OBJECT_TYPE import org.jetbrains.org.objectweb.asm.Type internal val equalsMethodDescriptor: String = Type.getMethodDescriptor(Type.BOOLEAN_TYPE, Type.getType(Any::class.java)); -class Equals : IntrinsicMethod() { - override fun toCallable(method: CallableMethod): Callable = - createBinaryIntrinsicCallable( - method.returnType, - OBJECT_TYPE, - nullOrObject(method.dispatchReceiverType), - nullOrObject(method.extensionReceiverType) - ) { - DescriptorAsmUtil.genAreEqualCall(it) - } -} - class EqualsThrowingNpeForNullReceiver(private val lhsType: Type) : IntrinsicMethod() { override fun toCallable(method: CallableMethod): Callable = createBinaryIntrinsicCallable( diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicMethods.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicMethods.java index 6742e3763c9..fa6979aaa9a 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicMethods.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicMethods.java @@ -53,7 +53,6 @@ public class IntrinsicMethods { private static final IntrinsicMethod DEC = new Increment(-1); private static final IntrinsicMethod ARRAY_SIZE = new ArraySize(); - private static final Equals EQUALS = new Equals(); private static final IteratorNext ITERATOR_NEXT = new IteratorNext(); private static final ArraySet ARRAY_SET = new ArraySet(); private static final ArrayGet ARRAY_GET = new ArrayGet(); @@ -65,10 +64,10 @@ public class IntrinsicMethods { private final IntrinsicsMap intrinsicsMap = new IntrinsicsMap(); public IntrinsicMethods(JvmTarget jvmTarget) { - this(jvmTarget, false, true); + this(jvmTarget, false); } - public IntrinsicMethods(JvmTarget jvmTarget, boolean canReplaceStdlibRuntimeApiBehavior, boolean shouldThrowNpeOnExplicitEqualsForBoxedNull) { + public IntrinsicMethods(JvmTarget jvmTarget, boolean canReplaceStdlibRuntimeApiBehavior) { intrinsicsMap.registerIntrinsic(KOTLIN_JVM, RECEIVER_PARAMETER_FQ_NAME, "javaClass", -1, JavaClassProperty.INSTANCE); intrinsicsMap.registerIntrinsic(KOTLIN_JVM, StandardNames.FqNames.kClass, "java", -1, new KClassJavaProperty()); intrinsicsMap.registerIntrinsic(KOTLIN_JVM, StandardNames.FqNames.kClass, "javaObjectType", -1, new KClassJavaObjectTypeProperty()); @@ -108,16 +107,8 @@ public class IntrinsicMethods { IntrinsicMethod hashCode = new HashCode(jvmTarget); for (PrimitiveType type : PrimitiveType.values()) { FqName typeFqName = type.getTypeFqName(); - IntrinsicMethod equalsMethod; - if (shouldThrowNpeOnExplicitEqualsForBoxedNull) { - Type wrapperType = AsmUtil.asmTypeByFqNameWithoutInnerClasses(JvmPrimitiveType.get(type).getWrapperFqName()); - equalsMethod = new EqualsThrowingNpeForNullReceiver(wrapperType); - } - else { - equalsMethod = EQUALS; - } - - declareIntrinsicFunction(typeFqName, "equals", 1, equalsMethod); + Type wrapperType = AsmUtil.asmTypeByFqNameWithoutInnerClasses(JvmPrimitiveType.get(type).getWrapperFqName()); + declareIntrinsicFunction(typeFqName, "equals", 1, new EqualsThrowingNpeForNullReceiver(wrapperType)); declareIntrinsicFunction(typeFqName, "hashCode", 0, hashCode); declareIntrinsicFunction(typeFqName, "toString", 0, TO_STRING); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt index 5b2f73c8b69..7c5c2ccf131 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt @@ -248,11 +248,7 @@ class GenerationState private constructor( isIrBackend ) val canReplaceStdlibRuntimeApiBehavior = languageVersionSettings.apiVersion <= ApiVersion.parse(KotlinVersion.CURRENT.toString())!! - val intrinsics: IntrinsicMethods = run { - val shouldUseConsistentEquals = languageVersionSettings.supportsFeature(LanguageFeature.ThrowNpeOnExplicitEqualsForBoxedNull) && - !configuration.getBoolean(JVMConfigurationKeys.NO_EXCEPTION_ON_EXPLICIT_EQUALS_FOR_BOXED_NULL) - IntrinsicMethods(target, canReplaceStdlibRuntimeApiBehavior, shouldUseConsistentEquals) - } + val intrinsics: IntrinsicMethods = IntrinsicMethods(target, canReplaceStdlibRuntimeApiBehavior) val generateOptimizedCallableReferenceSuperClasses = languageVersionSettings.apiVersion >= ApiVersion.KOTLIN_1_4 && !configuration.getBoolean(JVMConfigurationKeys.NO_OPTIMIZED_CALLABLE_REFERENCES) diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt index 0949d930993..3674d02f1f9 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt @@ -142,12 +142,6 @@ abstract class CommonCompilerArguments : CommonToolArguments() { ) var inlineClasses: Boolean by FreezableVar(false) - @Argument( - value = "-Xpolymorphic-signature", - description = "Enable experimental support for @PolymorphicSignature (MethodHandle/VarHandle)" - ) - var polymorphicSignature: Boolean by FreezableVar(false) - @Argument( value = "-Xlegacy-smart-cast-after-try", description = "Allow var smart casts despite assignment in try block" @@ -443,10 +437,6 @@ abstract class CommonCompilerArguments : CommonToolArguments() { put(LanguageFeature.InlineClasses, LanguageFeature.State.ENABLED) } - if (polymorphicSignature) { - put(LanguageFeature.PolymorphicSignature, LanguageFeature.State.ENABLED) - } - if (legacySmartCastAfterTry) { put(LanguageFeature.SoundSmartCastsAfterTry, LanguageFeature.State.DISABLED) } diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt index 57ddada7f01..98f4fbb5b12 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt @@ -166,9 +166,6 @@ class K2JVMCompilerArguments : CommonCompilerArguments() { ) var noParamAssertions: Boolean by FreezableVar(false) - @Argument(value = "-Xstrict-java-nullability-assertions", description = "Generate nullability assertions for non-null Java expressions") - var strictJavaNullabilityAssertions: Boolean by FreezableVar(false) - @Argument(value = "-Xno-optimize", description = "Disable optimizations") var noOptimize: Boolean by FreezableVar(false) @@ -311,12 +308,6 @@ class K2JVMCompilerArguments : CommonCompilerArguments() { ) var jspecifyAnnotations: String? by FreezableVar(null) - @Argument( - value = "-Xno-exception-on-explicit-equals-for-boxed-null", - description = "Do not throw NPE on explicit 'equals' call for null receiver of platform boxed primitive type" - ) - var noExceptionOnExplicitEqualsForBoxedNull by FreezableVar(false) - @Argument( value = "-Xjvm-default", valueDescription = "{all|all-compatibility|disable|enable|compatibility}", @@ -468,12 +459,6 @@ default: `indy-with-constants` for JVM target 9 or greater, `inline` otherwise"" ) var repeatCompileModules: String? by NullableStringFreezableVar(null) - @Argument( - value = "-Xuse-old-spilled-var-type-analysis", - description = "Use old, SourceInterpreter-based analysis for fields, used for spilled variables in coroutines" - ) - var useOldSpilledVarTypeAnalysis: Boolean by FreezableVar(false) - @Argument( value = "-Xuse-14-inline-classes-mangling-scheme", description = "Use 1.4 inline classes mangling scheme instead of 1.4.30 one" @@ -544,9 +529,6 @@ default: `indy-with-constants` for JVM target 9 or greater, `inline` otherwise"" override fun configureLanguageFeatures(collector: MessageCollector): MutableMap { val result = super.configureLanguageFeatures(collector) - if (strictJavaNullabilityAssertions) { - result[LanguageFeature.StrictJavaNullabilityAssertions] = LanguageFeature.State.ENABLED - } if (typeEnhancementImprovementsInStrictMode) { result[LanguageFeature.TypeEnhancementImprovementsInStrictMode] = LanguageFeature.State.ENABLED } diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt index 0f380d0d7dd..f9e4f700dbb 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt @@ -248,10 +248,6 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr put(JVMConfigurationKeys.DISABLE_CALL_ASSERTIONS, arguments.noCallAssertions) put(JVMConfigurationKeys.DISABLE_RECEIVER_ASSERTIONS, arguments.noReceiverAssertions) put(JVMConfigurationKeys.DISABLE_PARAM_ASSERTIONS, arguments.noParamAssertions) - put( - JVMConfigurationKeys.NO_EXCEPTION_ON_EXPLICIT_EQUALS_FOR_BOXED_NULL, - arguments.noExceptionOnExplicitEqualsForBoxedNull - ) put(JVMConfigurationKeys.DISABLE_OPTIMIZATION, arguments.noOptimize) put(JVMConfigurationKeys.EMIT_JVM_TYPE_ANNOTATIONS, arguments.emitJvmTypeAnnotations) put(JVMConfigurationKeys.NO_OPTIMIZED_CALLABLE_REFERENCES, arguments.noOptimizedCallableReferences) @@ -289,7 +285,6 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr put(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE, arguments.allowKotlinPackage) put(JVMConfigurationKeys.USE_SINGLE_MODULE, arguments.singleModule) - put(JVMConfigurationKeys.USE_OLD_SPILLED_VAR_TYPE_ANALYSIS, arguments.useOldSpilledVarTypeAnalysis) put(JVMConfigurationKeys.USE_OLD_INLINE_CLASSES_MANGLING_SCHEME, arguments.useOldInlineClassesManglingScheme) put(JVMConfigurationKeys.ENABLE_JVM_PREVIEW, arguments.enableJvmPreview) diff --git a/compiler/config.jvm/src/org/jetbrains/kotlin/config/JVMConfigurationKeys.java b/compiler/config.jvm/src/org/jetbrains/kotlin/config/JVMConfigurationKeys.java index 399fda8db82..2cf60345878 100644 --- a/compiler/config.jvm/src/org/jetbrains/kotlin/config/JVMConfigurationKeys.java +++ b/compiler/config.jvm/src/org/jetbrains/kotlin/config/JVMConfigurationKeys.java @@ -54,8 +54,6 @@ public class JVMConfigurationKeys { CompilerConfigurationKey.create("disable not-null parameter assertions"); public static final CompilerConfigurationKey ASSERTIONS_MODE = CompilerConfigurationKey.create("assertions mode"); - public static final CompilerConfigurationKey NO_EXCEPTION_ON_EXPLICIT_EQUALS_FOR_BOXED_NULL = - CompilerConfigurationKey.create("do not throw NPE on explicit 'equals' call for null receiver of platform boxed primitive type"); public static final CompilerConfigurationKey DISABLE_OPTIMIZATION = CompilerConfigurationKey.create("disable optimization"); public static final CompilerConfigurationKey USE_TYPE_TABLE = @@ -142,9 +140,6 @@ public class JVMConfigurationKeys { public static final CompilerConfigurationKey NO_UNIFIED_NULL_CHECKS = CompilerConfigurationKey.create("Use pre-1.4 exception types in null checks instead of java.lang.NPE"); - public static final CompilerConfigurationKey USE_OLD_SPILLED_VAR_TYPE_ANALYSIS = - CompilerConfigurationKey.create("Use old, SourceInterpreter-based analysis for fields, used for spilled variables in coroutines"); - public static final CompilerConfigurationKey USE_OLD_INLINE_CLASSES_MANGLING_SCHEME = CompilerConfigurationKey.create("Use old, 1.4 version of inline classes mangling scheme"); diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/CoroutineCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/CoroutineCodegen.kt index cc4e452c3b8..9d2983c3851 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/CoroutineCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/CoroutineCodegen.kt @@ -21,7 +21,6 @@ import org.jetbrains.kotlin.codegen.coroutines.CoroutineTransformerMethodVisitor import org.jetbrains.kotlin.codegen.coroutines.INVOKE_SUSPEND_METHOD_NAME import org.jetbrains.kotlin.codegen.coroutines.SUSPEND_IMPL_NAME_SUFFIX import org.jetbrains.kotlin.codegen.coroutines.reportSuspensionPointInsideMonitor -import org.jetbrains.kotlin.config.JVMConfigurationKeys import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET import org.jetbrains.kotlin.ir.declarations.* @@ -83,7 +82,6 @@ internal fun MethodNode.acceptWithStateMachine( || irFunction.origin == JvmLoweredDeclarationOrigin.SUSPEND_IMPL_STATIC_FUNCTION), internalNameForDispatchReceiver = classCodegen.type.internalName, putContinuationParameterToLvt = false, - useOldSpilledVarTypeAnalysis = state.configuration.getBoolean(JVMConfigurationKeys.USE_OLD_SPILLED_VAR_TYPE_ANALYSIS), initialVarsCountByType = varsCountByType, ) accept(visitor) diff --git a/compiler/testData/cli/js/jsExtraHelp.out b/compiler/testData/cli/js/jsExtraHelp.out index 7cea0fb8cc6..41f4eda337b 100644 --- a/compiler/testData/cli/js/jsExtraHelp.out +++ b/compiler/testData/cli/js/jsExtraHelp.out @@ -77,7 +77,6 @@ where advanced options include: -Xphases-to-validate-after Validate backend state after these phases -Xphases-to-validate-before Validate backend state before these phases -Xplugin= Load plugins from the given classpath - -Xpolymorphic-signature Enable experimental support for @PolymorphicSignature (MethodHandle/VarHandle) -Xprofile-phases Profile backend phases -Xproper-ieee754-comparisons Generate proper IEEE 754 comparisons in all cases if values are statically known to be of primitive numeric types -Xread-deserialized-contracts Enable reading of contracts from metadata diff --git a/compiler/testData/cli/jvm/extraHelp.out b/compiler/testData/cli/jvm/extraHelp.out index e047e70bdcb..60f3de6a5b2 100644 --- a/compiler/testData/cli/jvm/extraHelp.out +++ b/compiler/testData/cli/jvm/extraHelp.out @@ -75,8 +75,6 @@ where advanced options include: Lambda objects created using `LambdaMetafactory.metafactory` will have different `toString()`. -Xlambdas=class Generate lambdas as explicit classes -Xno-call-assertions Don't generate not-null assertions for arguments of platform types - -Xno-exception-on-explicit-equals-for-boxed-null - Do not throw NPE on explicit 'equals' call for null receiver of platform boxed primitive type -Xno-kotlin-nothing-value-exception Do not use KotlinNothingValueException available since 1.4 -Xno-optimize Disable optimizations @@ -112,8 +110,6 @@ where advanced options include: -Xserialize-ir Save IR to metadata (EXPERIMENTAL) -Xsingle-module Combine modules for source files and binary dependencies into a single module -Xskip-runtime-version-check Allow Kotlin runtime libraries of incompatible versions in the classpath - -Xstrict-java-nullability-assertions - Generate nullability assertions for non-null Java expressions -Xgenerate-strict-metadata-version Generate metadata with strict version semantics (see kdoc on Metadata.extraInt) -Xstring-concat={indy-with-constants|indy|inline} @@ -139,8 +135,6 @@ where advanced options include: Should be used in case of problems with the new implementation -Xuse-14-inline-classes-mangling-scheme Use 1.4 inline classes mangling scheme instead of 1.4.30 one - -Xuse-old-spilled-var-type-analysis - Use old, SourceInterpreter-based analysis for fields, used for spilled variables in coroutines -Xuse-type-table Use type table in metadata serialization -Xvalidate-bytecode Validate generated JVM bytecode before and after optimizations -Xvalidate-ir Validate IR before and after lowering @@ -185,7 +179,6 @@ where advanced options include: -Xphases-to-validate-after Validate backend state after these phases -Xphases-to-validate-before Validate backend state before these phases -Xplugin= Load plugins from the given classpath - -Xpolymorphic-signature Enable experimental support for @PolymorphicSignature (MethodHandle/VarHandle) -Xprofile-phases Profile backend phases -Xproper-ieee754-comparisons Generate proper IEEE 754 comparisons in all cases if values are statically known to be of primitive numeric types -Xread-deserialized-contracts Enable reading of contracts from metadata