Commit Graph

5907 Commits

Author SHA1 Message Date
Alexander Udalov 971b4e63e7 JVM: support enumEntries intrinsic for Java & old Kotlin enums
#KT-59710 Fixed
2023-07-25 09:55:43 +00:00
Alexander Udalov 874d1c514a JVM: support enumEntries intrinsic for Kotlin enums
Implementation is very similar to the `enumValues` intrinsic.

Java enums and old (pre-1.9) Kotlin enums will be supported in a
subsequent commit.

 #KT-59710
2023-07-25 09:55:43 +00:00
Ivan Kylchik 5a09ca6908 [JVM] Slightly rewrite inliner code to understand it more easily 2023-07-20 09:01:42 +00:00
Ivan Kochurkin 20c53fc15d Unify JvmSignatureSerializer 2023-07-12 13:11:25 +00:00
vladislav.grechko e4f1c10bc1 [JVM_IR] Do not compile-time evaluate apiVersionIsAtLeast in stdlib
Function `apiVersionIsAtLeast` was introduced to be able to have
different inline function content inlined to user code call sites
depending on their api version settings. Thus, it should not be
compile-time evaluated when being called in the body of inline stdlib
function.

^KT-59452: Fixed
2023-06-19 16:24:57 +00:00
Abduqodiri Qurbonzoda fd4d4f516f Fix data class hashcode generation
It considers Boolean hashCode equal to 1/0 for true/false,
which is different from actual hashCode of the Boolean type.
2023-06-14 08:19:47 +00:00
Alexander Udalov b8785fbd90 K2: do not support disabling NoSourceCodeInNotNullAssertionExceptions
Disabling of this language feature (see KT-57570) was not supported in
the (default) light tree mode, and after this change it will not be
supported in the PSI mode as well. This makes the behavior more
consistent and allows us to remove the directive
IGNORE_BACKEND_K2_LIGHT_TREE in the future (KT-56757).
2023-06-06 10:06:39 +00:00
Alexander Udalov ad1dfd5cb9 JVM: change logic of applying KT-57570 behavior a bit
If `-Xno-unified-null-checks` is specified, do not throw exceptions, but
rather revert to the old behavior, with source code in exception
messages.

Note that `-Xno-unified-null-checks` is a flag which enables behavior of
Kotlin 1.3. It can be removed once we no longer support API version 1.3.
2023-05-24 11:29:51 +00:00
Alexander Udalov fb900d2e2a JVM: remove most usages of JvmTarget.JVM_1_6 2023-05-19 13:24:00 +00:00
Alexander Udalov fc0ce415d7 JVM: remove source code from not null assertion message text
This is implemented under a LanguageFeature which will be enabled later,
when behavior change described in KT-57570 is approved.

 #KT-57570
2023-04-28 10:26:15 +00:00
Roman Golyshev d4cffb8a5a [213] Switch to 213 platform
KTI-1114
2023-04-21 13:19:04 +00:00
Pavel Mikhailovskii 3bb66e8432 KT-57714 Fix remapping of signatures with reified type parameters 2023-04-19 07:20:51 +00:00
Ilmir Usmanov b36e1f1a5b Do not reference object's toString result in exception messages
Since we put object's hash code in toString, we end up in putting
non-stable hash code to constant table, which leads to unstable
binaries.

 #KTI-1193 Fixed
2023-04-04 13:41:03 +00:00
Ivan Kylchik 71487e534b Reuse some available variables in JVM backend 2023-03-14 20:47:40 +00:00
Ivan Kylchik 32a7633c06 Support smap creation for functions inlined with IR inliner 2023-03-14 20:47:38 +00:00
Evgeniy.Zhelenskiy 3b5ad0681f [IR] Fix compiler bugs with MFVC to let KorGE run
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
2023-03-13 13:09:56 +00:00
Alexander Udalov 4f380e876c Deprecate ClassBuilderInterceptorExtension
ClassGeneratorExtension is supposed to be used instead.
2023-03-13 13:54:06 +01:00
Alexander Udalov fba5b96bef JVM IR: introduce ClassGeneratorExtension
This is a low-level extension point for Kotlin/JVM, which is supposed to
be used instead of ClassBuilderInterceptorExtension.

 #KT-54758 Fixed
 #KT-56814 Fixed
2023-03-13 13:51:52 +01:00
Alexander Udalov b1d109e7a3 JVM IR: do not use JvmDeclarationOrigin in duplicate signatures
Apparently the client code which reports errors only meaningfully uses
the `descriptor` field of `JvmDeclarationOrigin` in case of JVM IR.
2023-03-13 13:51:52 +01:00
Alexander Udalov 6595275ba7 Remove ClassBuilderMode.ABI
It was a special mode used only by the removed legacy implementation of
jvm-abi-gen.
2023-03-10 12:24:50 +00:00
Alexander Udalov 9f269b83aa Remove "legacy" mode of jvm-abi-gen plugin
#KT-55375 Fixed
2023-03-10 12:24:50 +00:00
Evgeniy.Zhelenskiy 5b868becf4 [IR] Hide regular class constructor with MFVC parameters
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
2023-03-07 21:44:41 +00:00
Ilmir Usmanov b3890885c4 JVM: Break infinite loop in finding meaningful instruction
during tail-call optimization.

There can be code, where all next instructions are non-meaningful and
there is a back-edge, for example, while(true){}. Previously, analyzer
incorrectly assumed, that this cannot happen. Now, it keeps track of
visited instructions and says, that there is no meaningful instruction
in such case.
 #KT-56815 Fixed
2023-02-23 17:54:46 +00:00
Ilmir Usmanov 6be734c27e JVM: Remove inplace arguments before state-machine building
#KT-56258 Fixed
2023-02-22 12:45:03 +00:00
Stanislav Erokhin bec9ad0f6b Minor. Rename FunctionClassDescriptor#functionKind -> functionTypeKind
This commit is needed for the following commit.
There we will restore the compatibility API with Android IDEA plugin
2023-02-10 16:01:04 +00:00
Dmitriy Novozhilov 89c42e20c9 [FIR] Consistently use _function_ instead of _functional_ in names of classes and functions 2023-02-02 08:24:52 +00:00
Dmitriy Novozhilov 67aa80562d [FE] Completely replace FunctionClassKind with FunctionalTypeKind
FunctionalTypeKind can be used in FE 1.0 too, so there is no need to
  keep both classes. Also, removal of FunctionClassKind simplifies work
  with FunctionalTypeKind in common code, like Analysis Api
2023-02-02 08:24:50 +00:00
Dmitriy Novozhilov 2783aa13f5 [Backend] Restore isMostPreciseContravariantArgument method for binary compatibility
^KT-56033 Fixed
2023-01-31 07:53:08 +00:00
Roman Efremov 14b4cdc7c4 Write "hasEnumEntries" flag into metadata when feature enabled
^KT-53929 Fixed
2023-01-23 12:53:04 +01:00
Mikhail Glukhikh 0c4a0360ac Deserialization/class reading: pass chosen JvmMetadataVersion whenever possible 2023-01-16 18:16:07 +01:00
Mikhail Glukhikh 52ab565cc6 Move LANGUAGE_TO_METADATA_VERSION to compiler:frontend.common.jvm 2023-01-16 18:14:52 +01:00
Mikhail Glukhikh f6b8b3438a Extract & use GenerationState.metadataVersion helper 2023-01-16 18:12:55 +01:00
Mikhail Glukhikh 3dc05f4ec5 Introduce language version 2.0 and associate K2 compiler with it 2023-01-16 18:12:55 +01:00
Dmitriy Novozhilov bd26c29229 [FIR] Resolve arguments of error types during type resolution 2023-01-12 17:45:06 +00:00
Vladimir Dolzhenko 4542b3947b Clean up: rename Jet* to Kt* 2023-01-03 16:36:53 +01:00
Xin Wang 7278f9a4fd JVM Inline: Update tryCatchBlocks when expand mask conditions
Fixes: KT-48989
2022-12-22 12:50:41 +00:00
Pavel Mikhailovskii 06d3e1d8bd KT-55005 Do not generate CHECKCAST before AASTORE 2022-12-21 15:06:07 +00:00
Evgeniy.Zhelenskiy 40f38c8adb [IR] Eliminate redundant boxing/unboxing of MFVC after inlining
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
2022-12-08 15:12:28 +00:00
Pavel Mikhailovskii 2d69fd5a8a KT-52027 Encapsulate and fix calculation of parameter indices 2022-12-06 23:16:11 +00:00
Alexander Udalov 1418423423 Remove unsafe cast function usages from JVM backend modules 2022-12-06 19:44:55 +00:00
Nikolay Lunyak 2e9f9f987b [FIR] KT-44698: Print file:line:offset on K2 crash
^KT-44698 Fixed
2022-11-29 22:35:51 +00:00
Dmitriy Novozhilov 32f6b71525 [FE] Add ability to configure PublicDeclaration type approximation configuration
This configuration allows to choose what to do with local and anonymous types
2022-11-22 15:46:18 +00:00
Yan Zhulanow ea3f550b58 [FE] Support analyzable files throughout all 'KtPsiFactory' API
Before, the only way of getting analyzable elements was to create an
analyzable file by using 'createAnalyzableFile()'. So made all utilities
available in 'KtPsiFactory' useless as they delegate to 'createFile()'
that always set the 'doNotAnalyze' flag.

The new behavior is to pass the 'analysisContext' instead if it is
passed to the 'KtPsiFactory' constructor.

The newly appeared API is going to be used in the Kotlin's UAST
implementation.
2022-11-11 11:28:34 +00:00
Alexander Udalov d7a58a7c6c Keep track of array types in OptimizationBasicInterpreter
Merging array types with different element types, for example
`[Lj/l/String;` and `[Lj/l/Object;`, now produces `[Lj/l/Object;`
(instead of `Lj/l/Object;`), which allows for more precise tracking of
null values because we assume that AALOAD on a non-array typed value is
possible only if that value is null.

 #KT-54802 Fixed
2022-11-07 17:22:38 +01:00
Vladimir Dolzhenko 5dc2442872 Safe reporting PSI elements in KEWA 2022-11-03 17:27:11 +00:00
pyos a30d19b655 jvm-abi-gen: consider private type aliases to be public API
They can be referenced from public declarations right now.

^KT-54500 Fixed
2022-10-31 22:13:21 +01:00
pyos 65c153a722 JVM: consider casts of null to be redundant
These should only have ever been necessary for field type inference in
coroutines, which should have been fixed by 0fc676a20c.

Unlike 903a5d69a4, this time the change is in an optimization pass.
Advantage: optimization passes have a closer to the JVM view of the
bytecode, which makes this change significantly more likely to be correct.
Disadvantage: technically we don't really guarantee optimization passes
other than FixStack will run at all. For KT-54581 this is 100% fine
since the problem itself is caused by redundant checkcast elimination in
the first place (otherwise there would've been a redundant cast to
String), but for KT-53146 this means the fix is somewhat incidental and
not necessarily guaranteed.

^KT-53146 Fixed
^KT-54581 Fixed
2022-10-24 11:11:21 +02:00
Evgeniy.Zhelenskiy 0c1c25e477 [IR] Implement MFVC basic flattening
#KT-1179
2022-10-07 12:43:36 +00:00
Evgeniy.Zhelenskiy d4969e9b97 Revert "rra/zhelenskiy/flattening_impl"
This reverts commit b7f5c039a6.
2022-10-07 12:43:36 +00:00
Evgeniy.Zhelenskiy 2896f5613d [IR] Implement MFVC basic flattening
#KT-1179
2022-10-07 12:42:06 +00:00