5988 Commits

Author SHA1 Message Date
Alexander Udalov b4d65fe5cd JVM: remove obsolete code for reporting JVM backend diagnostics
The last remaining usages from diagnostic tests were removed in previous
commits.
2024-03-15 14:39:56 +00:00
Sonya Valchuk 0005ba47f8 JVM: extract some helpers for SMAP inlining 2024-03-13 21:31:19 +00:00
Dmitriy Novozhilov d352cc9d96 [Frontend] Make DiagnosticSuppressor a project-level extension
Originally it was an application-level component, which caused non-trivial
  logic and cognitive load to carefully handle those extensions to avoid
  memory leaks.

6740a596 introduced a way to easily register `DiagnosticSuppressor` to
  project, and this commit continues this work, making it a proper
  project-level extension

A lot of changes caused by the fact, that this extension is needed to be
  obtained from `BindingContext` (see `BindingContextSuppressCache` and
  its usages), so almost all changes are introducing `Project` to
  `BindingContext`

^KT-66449 Fixed
2024-03-12 06:43:58 +00:00
Sonya Valchuk e5ad035039 JVM: do not write trivial SMAPs to any classes
Even ones inside inline functions. This was a backwards compatibility
hack for Kotlin 1.4, where the inliner would crash if it attempted to
regenerate an anonymous object with no SMAP; that has been fixed in 1.5,
and ever since then trivial SMAPs could be inferred from line number
markers in methods.

There are three kinds of changes to tests in this commit:

  * Some SMAPs are gone entirely - self-explanatory.

  * Some SMAPs have narrower line ranges - that's because the old SMAP
    had the range for the entire file, while the new one only maps up to
    the last line number used in the class. There should be no
    difference in behavior.

  * Some "source file name" markers are removed in continuation objects
    - continuations don't have any line numbers, so there's no debugging
    information anyway. The actual source information is in the
    containing class.
2024-03-11 17:25:50 +00:00
Sonya Valchuk fc992274bb JVM: make SMAP utilities a little prettier 2024-03-11 17:25:50 +00:00
Jinseong Jeon 94e5653eb7 Migrate utils to check/alter TypeMappingMode according to suppress wildcard annotations
^KT-61734
2024-03-07 10:16:59 +00:00
Jinseong Jeon 5d730233cd Migrate Jvm(Suppress)?Wildcard(s)? FqName (and ClassId) 2024-03-07 10:16:58 +00:00
Nikita Nazarov 407448d8e3 [JVM] Implement new inlined variable naming format
^KT-65478 fixed
2024-02-23 23:59:13 +01:00
Dmitrii Gridin 072d191306 [compiler] replace Enum values() with entries
To fix warnings. Also, use of `Enum.entries` may improve the performance

^KT-48872
2024-02-20 17:56:46 +00:00
vladislav.grechko d753a22fc6 [FIR] Handle expect declarations in JVM backend
1. Do not generate bytecode for expect declarations

2. Serialize @OptionalExpectation annotations into .kotlin_module file

^KT-62931: Fixed
2024-02-19 18:17:37 +00:00
vladislav.grechko b74501ee93 Compare module metadata in JVM ABI consistency tests 2024-02-19 18:17:37 +00:00
Ilya Kirillov d925d3be76 [Analysis API] Fix Unexpected FirClassLikeSymbol null for class org.jetbrains.kotlin.fir.types.ConeClassLikeErrorLookupTag exception
on calling `asPsiType` on an unresolved type with type arguments

 ^KT-65550 fixed
2024-02-15 06:38:47 +00:00
Ilmir Usmanov f1fd84f539 Put $completion parameter to LVT
The parameter, unlike other ones, should span the whole method, since
throughout the whole method it has some value and thus should be
visible.

This effectively rolls bb5a99ec back

 #KT-64309 Fixed
2024-02-08 22:58:20 +00:00
Alexander Udalov 28797a31b4 JVM: refactor JvmDefaultMode, remove/rename some entries
- remove ENABLE/COMPATIBILITY because they can no longer be used
- remove forAllMethodsWithBody because its behavior is now equivalent to
  isEnabled
- inline isCompatibility
- inline DEFAULT
- rename ALL_INCOMPATIBLE -> ALL
2024-02-06 17:18:44 +00:00
Alexander Udalov 49c659b379 CLI: remove obsolete -Xdump-declarations-to
It was only used in the very old version of binary compatibility
validator. It was never supported in the JVM IR backend.
2024-02-01 23:37:23 +00:00
Ivan Kylchik d7d42134df [JVM] Don't analyze KtCodeFragment's file twice
We could get several files from the IDE to analyze. For example, some
code fragment and a file with context information. This additional
file, in fact, can be a file where a code fragment is defined, and we
can accidentally analyze a single file twice that leads to errors.
2023-11-16 15:59:48 +00:00
Ivan Kylchik d6f0530215 [JVM] Use getContextContainingFile method in CodegenBinding 2023-11-16 15:59:48 +00:00
Alexander Udalov 6a0a64eb6d JVM: remove usages of trove4j
#KTI-1135
2023-11-10 21:56:34 +00:00
Ivan Kochurkin 1827df82c4 Removed useless as casts from compiler code
It allows compiling code with K2 and enabled `-Werror`
2023-10-24 20:59:56 +00:00
Dmitriy Novozhilov 704e2ef5c5 Suppress K2 specific warnings in the codebase
^KT-62472
2023-10-18 07:59:27 +00:00
Alexander Udalov 9fd1445631 JVM: use metadata version 1.9 for .kotlin_module if LV=2.0
See the comment in the code for more info.

No proper test added because the compiler test infrastructure lacks the
ability to run old compiler versions, however I've verified manually
that the change fixes the issue.

 #KT-62531 Fixed
2023-10-16 12:45:47 +00:00
Ivan Kylchik a30d0aeeb0 [JVM] Replace AbstractInsnNode.getType with new util function
This change speeds up backend by approximately 0.96%.
2023-10-13 08:50:47 +00:00
Ivan Kylchik 67460962c3 [JVM] Use HashSet instead of SmartSet in MaxStackFrameSizeAndLocalsCalculator
This change speeds up backend by approximately 0.25%.
2023-10-13 08:50:47 +00:00
Ivan Kylchik 05b364a5f1 [JVM] Simplify equals method in StrictBasicValue 2023-10-13 08:50:47 +00:00
Ivan Kylchik 96a2da4906 [JVM] Split mergeControlFlowEdge into full and fast versions
This is needed because for `FastStackAnalyzer` we actually
will use only `fast` version, that can potentially improve overall
performance.
2023-10-12 13:04:43 +00:00
Ivan Kylchik 07c7792693 [JVM] Drop toArray call where iterator can be used 2023-10-12 13:04:43 +00:00
Ivan Kylchik 2387fe302c [JVM] Use reference comparison for objects defined in StrictBasicValue 2023-10-12 13:04:43 +00:00
Ivan Kylchik c1c04376cf [JVM] Replace open functions in FastAnalyzer with constructor args 2023-10-12 13:04:43 +00:00
Ivan Kylchik 99655cfa15 [JVM] Make newFrame constructor's parameter for FastAnalyzer 2023-10-12 13:04:43 +00:00
Ivan Kylchik cfe38470af [JVM] Use composition instead of inheritance in FixStackAnalyzer
This way we will be able to pass `createFrame` argument
directly to `FastAnalyzer`.
2023-10-12 13:04:43 +00:00
Ivan Kylchik 2327800a95 [JVM] Make BoxingInterpreter an abstract class instead of open
This way, it is a little bit easier to fit the semantics of this
class in the head.
2023-10-12 13:04:43 +00:00
Ivan Kylchik 38dd75c6c8 [JVM] Drop boxingInterpreter constructor parameter from BoxingFrame 2023-10-12 13:04:43 +00:00
Ivan Kylchik 6d57cbe23c [JVM] Reorganize positions of methods in FastAnalyzer 2023-10-12 13:04:43 +00:00
Ivan Kylchik 895afc736d [JVM] Drop I : Interpreter<V> type parameter from FastAnalyzer 2023-10-12 13:04:43 +00:00
Ivan Kylchik 87c46db3d5 [JVM] Drop getFrame and setFrame methods from FastAnalyzer 2023-10-12 13:04:43 +00:00
Ivan Kylchik f7f253d2bf [JVM] Move isTcbStart computation in FastAnalyzer 2023-10-12 13:04:43 +00:00
Ivan Kylchik 53d9b3c54f [JVM] Combine all mergeControlFlowEdge methods
This is just a refactoring commit. All fast analyzers are doing the
same thing in `mergeControlFlowEdge`, so we extract it in common
`FastAnalyzer`. The only exception is `FastStackAnalyzer`.
There was no `isMergeNode` check, but this is an optimization
that allows us to reuse a frame and not copy it.
2023-10-12 13:04:42 +00:00
Ivan Kylchik 68e4a7a318 [JVM] Combine all analyzeInstruction methods 2023-10-12 13:04:42 +00:00
Ivan Kylchik 58473b94a7 [JVM] Reuse visitNopInsn method in all Fast...Analyzer classes 2023-10-12 13:04:42 +00:00
Ivan Kylchik ed95ebc585 [JVM] Move visit...Insn methods in FastAnalyzer
They are actually the same.
2023-10-12 13:04:42 +00:00
Ivan Kylchik 7845e6bb0a [JVM] Drop visitControlFlowExceptionEdge method from FastStackAnalyzer
There is no class that overrides this method.

Also replaced `newValue` call with `newExceptionValue`. Under the hood,
`newExceptionValue` still calls `newValue` if the interpreter doesn't
redefine it. And it kind of makes sense to call `newExceptionValue`
here because we are handling try-catch block.
2023-10-12 13:04:42 +00:00
Ivan Kylchik e9019e9fb3 [JVM] Drop StoreLoadInterpreter class 2023-10-12 13:04:42 +00:00
Ivan Kylchik 364faa9506 [JVM] Drop StoreLoadValue interface 2023-10-12 13:04:42 +00:00
Ilya Kirillov f11cb277cd Remove obsolete @OptIn(ExperimentalStdlibApi::class) annotations
They were added when `buildList`, `buildMap` and `buildSet` were experimental.

^KT-62510
2023-10-12 10:41:00 +00:00
Alexander Udalov 9943c7078c JVM: add more flags to JvmBackendConfig
And use them instead of CompilerConfiguration, to reduce dependencies of
backend on the whole compiler (as opposed to just backend)
configuration.
2023-10-02 14:58:24 +00:00
Alexander Udalov 72b5123fc8 JVM: reduce usages of GenerationState in favor of JvmBackendConfig
To help in decoupling JVM IR from the old JVM backend.
2023-10-02 14:58:23 +00:00
Dmitriy Novozhilov 9e5ee3afa0 [FE] Add isLocal name to ClassId constructor calls where it needed 2023-09-21 12:40:44 +00:00
Nikolay Lunyak ec9cb8beb6 [FIR] Rename JvmNames -> JvmStandardClassIds
This is more consistent with the code of
the common compiler checkers.

It would be nice to refactor the contents
of this object further, but it's out
of scope of the current branch.

^KT-54596
2023-09-19 22:14:09 +00:00
Nikolay Lunyak 986f1624ec [FIR] Remove jvm-specific annotations from common compiler code
^KT-54596 Fixed
2023-09-19 22:14:09 +00:00
Ilmir Usmanov f16ea9dfbb JVM: Reduce number of comparison on bytecode analysis merge
operations. Since these methods are hot - they are call on each branch,
even such primitive optimizations should give measurable speedup.
2023-09-14 15:35:51 +00:00