Separate JvmTarget::bytecodeVersion version into major/minor parts
This commit is contained in:
@@ -201,7 +201,7 @@ class GenerationState private constructor(
|
|||||||
|
|
||||||
val target = configuration.get(JVMConfigurationKeys.JVM_TARGET) ?: JvmTarget.DEFAULT
|
val target = configuration.get(JVMConfigurationKeys.JVM_TARGET) ?: JvmTarget.DEFAULT
|
||||||
val runtimeStringConcat =
|
val runtimeStringConcat =
|
||||||
if (target.bytecodeVersion >= JvmTarget.JVM_9.bytecodeVersion)
|
if (target.majorVersion >= JvmTarget.JVM_9.majorVersion)
|
||||||
configuration.get(JVMConfigurationKeys.STRING_CONCAT) ?: JvmStringConcat.INLINE
|
configuration.get(JVMConfigurationKeys.STRING_CONCAT) ?: JvmStringConcat.INLINE
|
||||||
else JvmStringConcat.INLINE
|
else JvmStringConcat.INLINE
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArgu
|
|||||||
}
|
}
|
||||||
|
|
||||||
val jvmTarget = get(JVMConfigurationKeys.JVM_TARGET) ?: JvmTarget.DEFAULT
|
val jvmTarget = get(JVMConfigurationKeys.JVM_TARGET) ?: JvmTarget.DEFAULT
|
||||||
if (jvmTarget.bytecodeVersion < JvmTarget.JVM_1_8.bytecodeVersion) {
|
if (jvmTarget.majorVersion < JvmTarget.JVM_1_8.majorVersion) {
|
||||||
val jvmDefaultMode = languageVersionSettings.getFlag(JvmAnalysisFlags.jvmDefaultMode)
|
val jvmDefaultMode = languageVersionSettings.getFlag(JvmAnalysisFlags.jvmDefaultMode)
|
||||||
if (jvmDefaultMode.forAllMethodsWithBody) {
|
if (jvmDefaultMode.forAllMethodsWithBody) {
|
||||||
messageCollector.report(
|
messageCollector.report(
|
||||||
@@ -53,7 +53,7 @@ fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArgu
|
|||||||
val runtimeStringConcat = JvmStringConcat.fromString(arguments.stringConcat!!)
|
val runtimeStringConcat = JvmStringConcat.fromString(arguments.stringConcat!!)
|
||||||
if (runtimeStringConcat != null) {
|
if (runtimeStringConcat != null) {
|
||||||
put(JVMConfigurationKeys.STRING_CONCAT, runtimeStringConcat)
|
put(JVMConfigurationKeys.STRING_CONCAT, runtimeStringConcat)
|
||||||
if (jvmTarget.bytecodeVersion < JvmTarget.JVM_9.bytecodeVersion && runtimeStringConcat != JvmStringConcat.INLINE) {
|
if (jvmTarget.majorVersion < JvmTarget.JVM_9.majorVersion && runtimeStringConcat != JvmStringConcat.INLINE) {
|
||||||
messageCollector.report(
|
messageCollector.report(
|
||||||
WARNING,
|
WARNING,
|
||||||
"`-Xstring-concat=${arguments.stringConcat}` does nothing with JVM target `${jvmTarget.description}`."
|
"`-Xstring-concat=${arguments.stringConcat}` does nothing with JVM target `${jvmTarget.description}`."
|
||||||
|
|||||||
@@ -21,34 +21,33 @@ import org.jetbrains.org.objectweb.asm.Opcodes
|
|||||||
|
|
||||||
enum class JvmTarget(
|
enum class JvmTarget(
|
||||||
override val description: String,
|
override val description: String,
|
||||||
|
val majorVersion: Int,
|
||||||
val descriptionForJavacArgument: String = description,
|
val descriptionForJavacArgument: String = description,
|
||||||
val isPreview: Boolean = false,
|
val isPreview: Boolean = false,
|
||||||
) : TargetPlatformVersion {
|
) : TargetPlatformVersion {
|
||||||
JVM_1_6("1.6"),
|
JVM_1_6("1.6", Opcodes.V1_6),
|
||||||
JVM_1_8("1.8"),
|
JVM_1_8("1.8", Opcodes.V1_8),
|
||||||
JVM_9("9"),
|
JVM_9("9", Opcodes.V9),
|
||||||
JVM_10("10"),
|
JVM_10("10", Opcodes.V10),
|
||||||
JVM_11("11"),
|
JVM_11("11", Opcodes.V11),
|
||||||
JVM_12("12"),
|
JVM_12("12", Opcodes.V12),
|
||||||
JVM_13("13"),
|
JVM_13("13", Opcodes.V13),
|
||||||
JVM_14("14"),
|
JVM_14("14", Opcodes.V14),
|
||||||
JVM_15("15"),
|
JVM_15("15", Opcodes.V15),
|
||||||
JVM_15_PREVIEW("15_PREVIEW", descriptionForJavacArgument = "15", isPreview = true),
|
JVM_15_PREVIEW(
|
||||||
|
"15_PREVIEW", Opcodes.V15,
|
||||||
|
descriptionForJavacArgument = "15", isPreview = true
|
||||||
|
),
|
||||||
;
|
;
|
||||||
|
|
||||||
|
val minorVersion: Int =
|
||||||
|
if (isPreview)
|
||||||
|
0xffff
|
||||||
|
else
|
||||||
|
0
|
||||||
|
|
||||||
val bytecodeVersion: Int by lazy {
|
val bytecodeVersion: Int by lazy {
|
||||||
when (this) {
|
(minorVersion shl 16) + majorVersion
|
||||||
JVM_1_6 -> Opcodes.V1_6
|
|
||||||
JVM_1_8 -> Opcodes.V1_8
|
|
||||||
JVM_9 -> Opcodes.V9
|
|
||||||
JVM_10 -> Opcodes.V10
|
|
||||||
JVM_11 -> Opcodes.V11
|
|
||||||
JVM_12 -> Opcodes.V12
|
|
||||||
JVM_13 -> Opcodes.V13
|
|
||||||
JVM_14 -> Opcodes.V14
|
|
||||||
JVM_15 -> Opcodes.V15
|
|
||||||
JVM_15_PREVIEW -> Opcodes.V15 + (0xffff shl 16)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
+1
-1
@@ -62,7 +62,7 @@ class InlinePlatformCompatibilityChecker(val jvmTarget: JvmTarget, languageVersi
|
|||||||
|
|
||||||
val propertyOrFun = DescriptorUtils.getDirectMember(resultingDescriptor)
|
val propertyOrFun = DescriptorUtils.getDirectMember(resultingDescriptor)
|
||||||
|
|
||||||
val compilingBytecodeVersion = jvmTarget.bytecodeVersion
|
val compilingBytecodeVersion = jvmTarget.majorVersion
|
||||||
if (!properError) {
|
if (!properError) {
|
||||||
val inliningBytecodeVersion = getBytecodeVersionIfDeserializedDescriptor(propertyOrFun, false)
|
val inliningBytecodeVersion = getBytecodeVersionIfDeserializedDescriptor(propertyOrFun, false)
|
||||||
if (inliningBytecodeVersion != null && compilingBytecodeVersion < inliningBytecodeVersion) {
|
if (inliningBytecodeVersion != null && compilingBytecodeVersion < inliningBytecodeVersion) {
|
||||||
|
|||||||
+1
-1
@@ -59,7 +59,7 @@ class LocalFunInlineChecker : DeclarationChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class JvmStaticChecker(jvmTarget: JvmTarget, languageVersionSettings: LanguageVersionSettings) : DeclarationChecker {
|
class JvmStaticChecker(jvmTarget: JvmTarget, languageVersionSettings: LanguageVersionSettings) : DeclarationChecker {
|
||||||
private val isLessJVM18 = jvmTarget.bytecodeVersion < JvmTarget.JVM_1_8.bytecodeVersion
|
private val isLessJVM18 = jvmTarget.majorVersion < JvmTarget.JVM_1_8.majorVersion
|
||||||
|
|
||||||
private val supportJvmStaticInInterface = languageVersionSettings.supportsFeature(LanguageFeature.JvmStaticInInterface)
|
private val supportJvmStaticInInterface = languageVersionSettings.supportsFeature(LanguageFeature.JvmStaticInInterface)
|
||||||
|
|
||||||
|
|||||||
@@ -460,7 +460,7 @@ public abstract class CodegenTestCase extends KotlinBaseTest<KotlinBaseTest.Test
|
|||||||
JvmTarget customDefaultTarget = JvmTarget.fromString(DEFAULT_JVM_TARGET);
|
JvmTarget customDefaultTarget = JvmTarget.fromString(DEFAULT_JVM_TARGET);
|
||||||
assert customDefaultTarget != null : "Can't construct JvmTarget for " + DEFAULT_JVM_TARGET;
|
assert customDefaultTarget != null : "Can't construct JvmTarget for " + DEFAULT_JVM_TARGET;
|
||||||
JvmTarget originalTarget = configuration.get(JVMConfigurationKeys.JVM_TARGET);
|
JvmTarget originalTarget = configuration.get(JVMConfigurationKeys.JVM_TARGET);
|
||||||
if (originalTarget == null || customDefaultTarget.getBytecodeVersion() > originalTarget.getBytecodeVersion()) {
|
if (originalTarget == null || customDefaultTarget.getMajorVersion() > originalTarget.getMajorVersion()) {
|
||||||
// It's not safe to substitute target in general
|
// It's not safe to substitute target in general
|
||||||
// cause it can affect generated bytecode and original behaviour should be tested somehow.
|
// cause it can affect generated bytecode and original behaviour should be tested somehow.
|
||||||
// Original behaviour testing is perfomed by
|
// Original behaviour testing is perfomed by
|
||||||
|
|||||||
Reference in New Issue
Block a user