Commit Graph

6911 Commits

Author SHA1 Message Date
Sergej Jaskiewicz 0fd4f10f6c [K/N] Avoid magic strings in KonanMangler 2023-09-13 14:25:10 +00:00
Sergej Jaskiewicz ddfd94b3b2 [K/N] Move KonanMangler to a new common module
^KT-61248 Fixed
2023-09-13 14:25:10 +00:00
Sergej Jaskiewicz d1127f1a31 [K/N] Move IR-related ObjC interop helpers to a new common module
This is a step towards KT-61248. We need those helpers to be available
in non-Native-specific code.
2023-09-13 14:25:09 +00:00
Sergej Jaskiewicz 5cb252fe49 [descriptors] Move DeclarationDescriptor#findPackage helper to core
There is nothing serialization-specific about this function
2023-09-13 14:25:09 +00:00
Sergej Jaskiewicz 56cb0bf071 [utils] Move atMostOne to core/util.runtime
There is nothing backend-specific about this helper function.
2023-09-13 14:25:08 +00:00
Alexander Udalov f9712597e1 IR: support IrExternalOverridabilityCondition in IrOverrideChecker
The code is analogous to OverridingUtil and
ExternalOverridabilityCondition.
2023-09-13 15:04:53 +02:00
Alexander Udalov 86eb79e095 IR: extract IrOverrideChecker to separate file 2023-09-13 15:03:41 +02:00
Alexander Udalov 57c1df7875 IR: extract FakeOverrideBuilderStrategy to separate file 2023-09-13 15:01:52 +02:00
Alexander Udalov 0afee8685a IR: remove unused parameter of IrOverridingUtil.isOverridableBy
The value of checkReturnType is false at all call sites.
2023-09-13 15:01:52 +02:00
Alexander Udalov b650f0ce8e IR: slightly refactor FakeOverrideRebuilder
Deduplicate some code, improve assertion messages, fix grammar in
comments.
2023-09-13 15:01:52 +02:00
Artem Kobzar 2578bfefd5 [K/JS] Add useEsClasses to list of compiler arguments that invalidate IC cache ^KT-61795 Fixed 2023-09-13 09:50:24 +00:00
Igor Chevdar 93dea12efe [IR] Supported top level local classes in names inventor
Such classes might appear after local objects extraction from inline bodies
2023-09-13 09:18:20 +03:00
Artem Kobzar 7bc521ab92 [K/JS] Reset exceptionState inside coroutines with a finally block ^KT-58685 Fixed 2023-09-12 15:18:16 +00:00
Alexander Udalov d16f33cf5b JVM IR: do not collect all dependency modules in IDE
Collecting all modules takes a lot of time in Evaluate Expression in
IDE, and it's useless because we then invoke JvmIrLinker to load module
headers, but that linker is discarded in the IDE (see `val irProviders`
below).

 #IDEA-329915
2023-09-12 09:11:44 +00:00
Ivan Kylchik 386d69018d [JVM] Rename JvmLower to JvmLoweringPhases
This is done to unify the way how we name file
that contains lowerings in different backends.
2023-09-11 10:04:50 +00:00
Johan Bay a1c2ded8a3 [K/N] Header klibs: Keep private properties in value classes
^KT-61767 Fixed
2023-09-08 13:13:19 +00:00
Nikita Bobko 6868c95263 KMP: Put "prohbit expect/actual different annotations" under the flag
^KT-61668 Fixed

Review: https://jetbrains.team/p/kt/reviews/12062/timeline
2023-09-08 10:51:42 +00:00
Ivan Kylchik 6048d52a97 [K2] Avoid field inlining during FIR2IR phase
Before const inlining for fields, we actually want to remember a given
field in `InlineConstTracker`. We are doing it already in const
evaluation. So we just need to ignore const inlining in
`CallAndReferenceGenerator` and delegate it to const evaluation.

#KT-60737
2023-09-07 19:12:18 +00:00
strangepleasures 88453a05f1 KT-53551 KT-52213 KT-58476 Fix handling of suspend functional types with context receivers 2023-09-07 12:40:01 +00:00
Artem Kobzar bff433f4e9 [K/JS] Support eager initialization for per-file granularity 2023-09-06 09:27:28 +00:00
Ivan Kylchik c2076a0227 [Native] Move hasNonConstInitializer from IrUtils2
This function could be useful for other backends.
2023-09-05 11:21:51 +00:00
Ivan Kylchik ddde95bd78 [Native] Move irByte from IrUtils2
We already have similar functions in `ExpressionHelpers`. Makes
sense to keep them together.
2023-09-05 11:21:51 +00:00
Ivan Kylchik 583a5496d5 [Native] Drop irCall from IrUtils2
We can reuse the same function from common `ExpressionHelpers`
2023-09-05 11:21:50 +00:00
Ivan Kylchik d0a5738499 [Native] Drop addChild from IrUtils2
We can reuse the same function from common `IrUtils`
2023-09-05 11:21:50 +00:00
Ivan Kylchik 5661316d7a [Native] Use FORWARD_DECLARATIONS_MODULE_NAME instead of hardcoded value 2023-09-05 08:35:47 +00:00
Ivan Kylchik dfa60ee092 [IR] Drop TODO from IrModuleFragmentImpl
This TODO doesn't have any description, and it is already
hard to understand what the author meant.
2023-09-05 08:35:46 +00:00
Iaroslav Postovalov 059046a2b1 [JVM] Micro-optimize method signature mapping
This commit optimizes functions related to method signature mapping on
the JVM backend. The most significant change is avoiding re-allocations
in StringBuilder when building internal names. The commit also includes
minor optimizations, such as removing redundant allocations of strings
and other objects.
2023-09-01 20:26:17 +00:00
Pavel Kunyavskiy bf9cae6410 [Fir2Ir] Support rebuilding fake overrides over IR
^KT-61514
2023-08-31 13:12:15 +00:00
Pavel Kunyavskiy 44c2a749c9 [Ir common] Introduce symbol table api to remove entries
^KT-61514
2023-08-31 13:12:15 +00:00
Evgeniy.Zhelenskiy 6ede1bcf85 [IR] Reduce unnecessary allocations 2023-08-31 10:43:30 +00:00
Kirill Rakhman ac102dedac [IR Actualizer] Fix fake-override generation in actual A -> common B -> actual C hierarchy
...  where C defines a member x and A overrides the member x

#KT-61166 Fixed
2023-08-31 07:52:02 +00:00
Alexander Udalov 12bbdebed2 JVM IR: support value classes only when feature is enabled
Remove NeedsToVisit because it doesn't really help with performance, and
it significantly increases code complexity.
2023-08-30 15:35:43 +00:00
Alexander Udalov 2dee47a8c1 JVM IR: simplify JvmValueClassAbstractLowering.visitReturn
Change the existing IrReturn object instead of returning a new one.
2023-08-30 15:35:43 +00:00
Alexander Udalov d1f884bad9 JVM IR: micro-optimization in IrType.erasedUpperBound
Avoid `is` on interfaces, use classes instead.
2023-08-30 15:35:43 +00:00
Alexander Udalov 35d498847e JVM IR: reorder some resolveFakeOverride calls 2023-08-30 15:35:43 +00:00
Alexander Udalov 29fab6c3eb IR: optimize IrDeclarationWithName.fqNameWhenAvailable
Do not construct lots of FqName objects, since doing so takes ~1% of JVM
backend time.
2023-08-30 15:35:43 +00:00
Alexander Udalov f1886f8219 JVM IR: optimize comparison with FQ name of kotlin.Result 2023-08-30 15:35:43 +00:00
Alexander Udalov 70f48db226 JVM IR: optimize IrIntrinsicMethods.getIntrinsic
Create a nested hash map with names as keys that are easier to compute
than the whole `Key`. It helps to substantially reduce the number of
computed FqName instances, since intrinsics are queried on generation of
each call.

Also put intrinsic query a bit lower in SyntheticAccessorLowering, after
operations which are easier to compute.
2023-08-30 15:35:43 +00:00
Dmitriy Novozhilov b53ccf7fac [FIR2IR] Drop Fir2IrSymbols in favor of IrPublicSymbol...Impl
Effectively, those two symbol hierarchies have the same semantics, so
  there is no sense to keep them both
2023-08-30 14:51:45 +00:00
Yan Zhulanow 4b80c2197f [Analysis API] Run code fragment compilation tests against libraries 2023-08-30 06:38:44 +00:00
vladislav.grechko 593b326c80 Don't do full type parameters erasure in resultIsActuallyAny
The only case when erasure required is when type is a type parameter.
2023-08-29 18:46:53 +00:00
vladislav.grechko 8f2825506a Don't do full type parameters erasure in PromisedValue::materializeAt
The only case when erasure matters in a context of materialization of
`PromisedValue` is when the type is a type parameter which upper bound
is an inline class. Since `PromisedValue::materializeAt` is a hot spot
and `eraseTypeParameters` is an expensive operation, we should not do
type erasure in other cases.
2023-08-29 18:46:53 +00:00
Johan Bay 0a612e4268 [klib] Add an option to write out header klibs
The header klib is supposed to only contain the public abi of the module
similar to jvm-abi-gen. It is intended to be used as a dependency for other
klib compilations instead of the full klib for compilation avoidance.

^KT-60807
2023-08-29 13:25:07 +00:00
Alexander Udalov 3246b0a6bd JVM IR: inherit some lowerings from ClassLoweringPass
This slightly simplifies code, but has no other immediate benefits. In
the future though, we may end up optimizing all ClassLoweringPass
JVM IR phases by making them traverse only one list of all classes in
the module, instead of traversing the whole IR tree each time.
2023-08-29 11:32:41 +00:00
Iaroslav Postovalov 9c8b215bbb [JVM IR] Don't track fake override methods in JvmSignatureClashDetector
trackFakeOverrideMethod in JvmSignatureClashDetector is modified to
ignore fake overrides to prevent duplicate tracking of such methods,
improving efficiency
2023-08-29 04:22:59 +00:00
Dmitriy Novozhilov 76d3c0e804 [FIR2IR] Get rid of all usages of IrSymbol.owner from DataClassMembersGenerator
This change uncovered the following problem in pipeline: we have a contract,
  that all bodies will be generated after all fake overrides will be preprocessed.
  But DataClassMembersGenerator generates bodies before f/o creation,
  which leads to the problem, if data class has forward reference to some
  class which was not processed before (because in this case generator
  of `hashCode` function will try to reference f/o, which is not created yet,
  which leads to `SymbolAlreadyBound` problem)

```
data class Some(val a: A) {
    generated fun hashCode(): Int {
        return a.hashCode() // (1) is not generated yet
    }
}

class A {
    fake-override fun hashCode(): Int // (1)
}
```

This problem will be fixed in the next commit

(related test is compiler/testData/codegen/box/ir/kt52677.kt)

^KT-60924
2023-08-25 14:23:41 +00:00
Dmitriy Novozhilov b38de13696 [IR] Mark some IR utilities with IrSymbolInternals
Those utilities have symbol as input and output, but call `owner` under the hood

^KT-60923
2023-08-25 14:23:41 +00:00
Roman Efremov 3124cbcbad [FE, IR] Refactor: rename areAnnotationArgumentsEqual parameters
Rename to "expect" and "actual" annotation.
This will be needed in next commit to make it clear that
only expect annotation value needs special handling.

^KTIJ-26700
2023-08-23 13:15:20 +00:00
Dmitriy Novozhilov 250b94d5dd [FIR2IR] Create builtin IR class for @IntrinsicConstEvaluation manually if it is missing in stdlib
^KT-59151
2023-08-22 18:36:20 +00:00
Roman Efremov def4388c19 [FE, IR] Check annotations on expect and actual enum entries
^KT-60668
^KT-60936
2023-08-22 12:14:43 +00:00