Skip to content

Commit a34d1b8

Browse files
ddolovovSpace Team
authored andcommitted
[Args] Allow disabling language features by Xklib-ir-inliner argument
The `Xklib-ir-inliner` argument is intended not only for enabling IR inliner-related language features while they are experimental (i.e. `sinceVersion = null`), but also for disabling language features when they will become mature (i.e. `sinceVersion != null`).
1 parent 9f52f80 commit a34d1b8

File tree

8 files changed

+53
-12
lines changed

8 files changed

+53
-12
lines changed

compiler/arguments/resources/kotlin-compiler-arguments.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,15 @@
784784
"deprecatedVersion": null,
785785
"removedVersion": null
786786
}
787+
},
788+
{
789+
"name": "default",
790+
"releaseVersionsMetadata": {
791+
"introducedVersion": "2.3.0",
792+
"stabilizedVersion": null,
793+
"deprecatedVersion": null,
794+
"removedVersion": null
795+
}
787796
}
788797
]
789798
}
@@ -6398,7 +6407,7 @@
63986407
"shortName": null,
63996408
"deprecatedName": null,
64006409
"description": {
6401-
"current": "Enable experimental IR inliner during KLIB generation.",
6410+
"current": "Set the mode of the experimental IR inliner on the first compilation stage.\n- `intra-module` mode enforces inlining of the functions only from the compiled module\n- `full` mode enforces inlining of all functions (from the compiled module and from all dependencies)\n Warning: This mode will trigger setting the `pre-release` flag for the compiled library.\n- `disabled` mode completely disables the IR inliner\n- `default` mode lets the IR inliner run in `intra-module`, `full` or `disabled` mode based on the current language version\n ",
64026411
"valueInVersions": []
64036412
},
64046413
"delimiter": null,
@@ -6409,12 +6418,12 @@
64096418
"valueInVersions": []
64106419
},
64116420
"defaultValue": {
6412-
"current": "disabled",
6421+
"current": "default",
64136422
"valueInVersions": []
64146423
}
64156424
},
64166425
"valueDescription": {
6417-
"current": "{intra-module|full|disabled}",
6426+
"current": "{intra-module|full|disabled|default}",
64186427
"valueInVersions": []
64196428
},
64206429
"releaseVersionsMetadata": {

compiler/arguments/src/org/jetbrains/kotlin/arguments/description/CommonKlibBasedCompilerArguments.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,13 @@ val actualCommonKlibBasedArguments by compilerArgumentsLevel(CompilerArgumentsLe
8484
compilerArgument {
8585
name = "Xklib-ir-inliner"
8686
compilerName = "irInlinerBeforeKlibSerialization"
87-
description = "Enable experimental IR inliner during KLIB generation.".asReleaseDependent()
87+
description = """Set the mode of the experimental IR inliner on the first compilation stage.
88+
- `intra-module` mode enforces inlining of the functions only from the compiled module
89+
- `full` mode enforces inlining of all functions (from the compiled module and from all dependencies)
90+
Warning: This mode will trigger setting the `pre-release` flag for the compiled library.
91+
- `disabled` mode completely disables the IR inliner
92+
- `default` mode lets the IR inliner run in `intra-module`, `full` or `disabled` mode based on the current language version
93+
""".asReleaseDependent()
8894
valueType = KlibIrInlinerModeType()
8995
valueDescription = ReleaseDependent(
9096
current = KlibIrInlinerMode.entries.joinToString(prefix = "{", separator = "|", postfix = "}") { it.modeState }

compiler/arguments/src/org/jetbrains/kotlin/arguments/dsl/types/KlibIrInlinerMode.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,10 @@ enum class KlibIrInlinerMode(
3434
introducedVersion = KotlinReleaseVersion.v2_3_0,
3535
),
3636
),
37-
}
37+
default(
38+
modeState = "default",
39+
releaseVersionsMetadata = KotlinReleaseVersionLifecycle(
40+
introducedVersion = KotlinReleaseVersion.v2_3_0,
41+
),
42+
),
43+
}

compiler/arguments/src/org/jetbrains/kotlin/arguments/dsl/types/KotlinArgumentValueType.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class ReturnValueCheckerModeType(
160160
@Serializable
161161
class KlibIrInlinerModeType(
162162
override val isNullable: ReleaseDependent<Boolean> = ReleaseDependent(false),
163-
override val defaultValue: ReleaseDependent<KlibIrInlinerMode?> = ReleaseDependent(KlibIrInlinerMode.disabled),
163+
override val defaultValue: ReleaseDependent<KlibIrInlinerMode?> = ReleaseDependent(KlibIrInlinerMode.default),
164164
) : KotlinArgumentValueType<KlibIrInlinerMode> {
165165
override fun stringRepresentation(value: KlibIrInlinerMode?): String {
166166
return value?.modeState.valueOrNullStringLiteral

compiler/cli/cli-common/gen/org/jetbrains/kotlin/cli/common/arguments/CommonKlibBasedCompilerArguments.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,16 @@ abstract class CommonKlibBasedCompilerArguments : CommonCompilerArguments() {
7474

7575
@Argument(
7676
value = "-Xklib-ir-inliner",
77-
valueDescription = "{intra-module|full|disabled}",
78-
description = "Enable experimental IR inliner during KLIB generation.",
77+
valueDescription = "{intra-module|full|disabled|default}",
78+
description = """Set the mode of the experimental IR inliner on the first compilation stage.
79+
- `intra-module` mode enforces inlining of the functions only from the compiled module
80+
- `full` mode enforces inlining of all functions (from the compiled module and from all dependencies)
81+
Warning: This mode will trigger setting the `pre-release` flag for the compiled library.
82+
- `disabled` mode completely disables the IR inliner
83+
- `default` mode lets the IR inliner run in `intra-module`, `full` or `disabled` mode based on the current language version
84+
""",
7985
)
80-
var irInlinerBeforeKlibSerialization: String = "disabled"
86+
var irInlinerBeforeKlibSerialization: String = "default"
8187
set(value) {
8288
checkFrozen()
8389
field = value

compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonKlibBasedCompilerArgumentsConfigurator.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,21 @@ open class CommonKlibBasedCompilerArgumentsConfigurator : CommonCompilerArgument
2020

2121
val klibIrInlinerMode = KlibIrInlinerMode.fromString(arguments.irInlinerBeforeKlibSerialization)
2222
when (klibIrInlinerMode) {
23+
KlibIrInlinerMode.DEFAULT -> {
24+
// Do nothing. Rely on the default language feature states.
25+
}
2326
KlibIrInlinerMode.INTRA_MODULE -> {
2427
map[LanguageFeature.IrIntraModuleInlinerBeforeKlibSerialization] = LanguageFeature.State.ENABLED
28+
map[LanguageFeature.IrCrossModuleInlinerBeforeKlibSerialization] = LanguageFeature.State.DISABLED
2529
}
2630
KlibIrInlinerMode.FULL -> {
2731
map[LanguageFeature.IrIntraModuleInlinerBeforeKlibSerialization] = LanguageFeature.State.ENABLED
2832
map[LanguageFeature.IrCrossModuleInlinerBeforeKlibSerialization] = LanguageFeature.State.ENABLED
2933
}
30-
KlibIrInlinerMode.DISABLED -> {}
34+
KlibIrInlinerMode.DISABLED -> {
35+
map[LanguageFeature.IrIntraModuleInlinerBeforeKlibSerialization] = LanguageFeature.State.DISABLED
36+
map[LanguageFeature.IrCrossModuleInlinerBeforeKlibSerialization] = LanguageFeature.State.DISABLED
37+
}
3138
null -> {
3239
collector.report(
3340
CompilerMessageSeverity.ERROR,

compiler/testData/cli/js/jsExtraHelp.out

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,14 @@ where advanced options include:
7474
Define the compile-time log level for partial linkage.
7575
-Xklib-duplicated-unique-name-strategy={deny|allow-all-with-warning|allow-first-with-warning}
7676
Klib dependencies usage strategy when multiple KLIBs has same `unique_name` property value.
77-
-Xklib-ir-inliner={intra-module|full|disabled}
78-
Enable experimental IR inliner during KLIB generation.
77+
-Xklib-ir-inliner={intra-module|full|disabled|default}
78+
Set the mode of the experimental IR inliner on the first compilation stage.
79+
- `intra-module` mode enforces inlining of the functions only from the compiled module
80+
- `full` mode enforces inlining of all functions (from the compiled module and from all dependencies)
81+
Warning: This mode will trigger setting the `pre-release` flag for the compiled library.
82+
- `disabled` mode completely disables the IR inliner
83+
- `default` mode lets the IR inliner run in `intra-module`, `full` or `disabled` mode based on the current language version
84+
7985
-Xklib-abi-version=<version> Specify the custom ABI version to be written in KLIB. This option is intended only for tests.
8086
Warning: This option does not affect KLIB ABI. Neither allows it making a KLIB backward-compatible with older ABI versions.
8187
The only observable effect is that a custom ABI version is written to KLIB manifest file.

compiler/util/src/org/jetbrains/kotlin/config/KlibIrInlinerMode.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package org.jetbrains.kotlin.config
77

88
enum class KlibIrInlinerMode(val state: String) {
9+
DEFAULT("default"),
910
DISABLED("disabled"),
1011
FULL("full"),
1112
INTRA_MODULE("intra-module");

0 commit comments

Comments
 (0)