Commit Graph

87184 Commits

Author SHA1 Message Date
Dmitriy Novozhilov bce62430ce [FIR] Split CfaUtils to multiple files 2021-09-15 17:11:27 +03:00
Elena Lepilkina bdb61ec5d7 [K/N] Run inline property accessors later to inline all cases including devirtualized 2021-09-15 12:29:03 +00:00
Svyatoslav Scherbina b32ab48596 Native: add tests for autorelease optimization in ObjCExport
The compiler should do its best to avoid putting objects to autorelease
pools.
2021-09-15 11:48:17 +00:00
Svyatoslav Scherbina 8c923f6504 Native: optimize autorelease in ObjCExport calls to Kotlin
Use objc_autoreleaseReturnValue to eliminate the autorelease operation
for return value if the caller is optimized (usually it is).

This required moving autorelease operation from Kotlin -> ObjC ref
conversion to bridge epilogue.

To achieve this, also make ObjCExport Kotlin ref -> ObjC ref dynamic
converters return retained reference (instead of autoreleased one).
To reflect this, rename the corresponding entities in the code.
2021-09-15 11:48:16 +00:00
Svyatoslav Scherbina 75a3070067 Native: implement autoreleaseAndRet for ObjCExportCodeGenerator
This operation is equivalent to "autorelease and then return",
but it supports Obj-C runtime autorelease optimization for return value:
if the caller is optimized (which is usually true), then no autorelease
will happen at runtime.
2021-09-15 11:48:15 +00:00
Svyatoslav Scherbina e00fd6b9b3 Native: allow subclassing FunctionGenerationContext
This allows one to have domain-specific generator without polluting
the global namespace.

Also introduce builders and do minor refactoring.
2021-09-15 11:48:15 +00:00
Svyatoslav Scherbina be1acc8103 Native: eliminate autorelease in ObjCExport set/getAssociatedTypeInfo 2021-09-15 11:48:14 +00:00
pyos 8724bc9525 Add test for KT-48478 2021-09-15 13:23:11 +02:00
pyos 72752b64c5 Revert "JVM_IR: assume function reference adapters are tail-call"
This reverts commit 537ce05bc9.

 #KT-48478 Fixed
2021-09-15 13:23:11 +02:00
pyos 0864f9faf8 JVM_IR: mark inline lambda functions with a special origin
Keeping the origin as LOCAL_FUNCTION_FOR_LAMBDA was a mistake as this
tells codegen nothing. Changing the origin in allows, for example,
removing the hack that detaches inline lambdas from the IR tree before
verification and codegen, or treating inline lambdas and inline
anonymous functions the same way.

This includes fake functions created for inline callable references.

 #KT-48319 Fixed
 #KT-47279 Fixed?
2021-09-15 13:23:11 +02:00
pyos 6b58c3d035 JVM_IR: mark inlined callable references with a different origin
Makes them easier to find.
2021-09-15 13:23:11 +02:00
Ilya Kirillov 81336820e2 FIR IDE: regenerate diagnostics 2021-09-15 11:32:59 +02:00
Ilya Kirillov 585eb9a4f0 FIR IDE: regenerate analysis api tests 2021-09-15 11:32:49 +02:00
Ilya Kirillov 5b38bd2be2 FIR IDE: fix generators after changing analysis api packages 2021-09-15 11:32:47 +02:00
Ilya Kirillov 99a65527b7 FIR IDE: fix symbol light classes imports after package changes 2021-09-15 11:32:45 +02:00
Ilya Kirillov 42f0536904 FIR IDE: move analysis api fir testdata to the analysis directory 2021-09-15 11:32:43 +02:00
Ilya Kirillov 4d52b354af FIR IDE: move analysis api fir generator to the analysis directory 2021-09-15 11:32:33 +02:00
Ilya Kirillov b43e664985 FIR IDE: move analysis api fir test sources to the analysis directory 2021-09-15 11:32:32 +02:00
Ilya Kirillov 5e9f807c78 FIR IDE: move analysis api fir main sources to the analysis directory 2021-09-15 11:32:30 +02:00
Ilya Kirillov 989f3248e4 FIR IDE: move low level api testdata sources to the analysis directory 2021-09-15 11:32:28 +02:00
Ilya Kirillov 633b0fa612 FIR IDE: move low level api test sources to the analysis directory 2021-09-15 11:32:25 +02:00
Ilya Kirillov b70f4f581e FIR IDE: move low level api main sources to the analysis directory 2021-09-15 11:32:22 +02:00
Ilya Kirillov 0c04ff98c3 FIR IDE: move analysis api to the analysis directory 2021-09-15 11:31:30 +02:00
Tianyu Geng 0996513f82 FIR: remove unused private property 2021-09-15 12:11:41 +03:00
Tianyu Geng dfc36ec614 FIR checker: ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_(ANNOTATION|FUNCTION) 2021-09-15 12:11:41 +03:00
Tianyu Geng e95de0a778 FIR checker: report type mismatch for named vararg arguement
ProhibitAssigningSingleElementsToVarargsInNamedForm is enabled from 1.3
so there is no need to make FIR accepting single element passed through
named arguments.

In addition, we may want to report only
ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_FUNCTION and not arg
type mismatch. But FE1.0 is reporting both so I am following it. If we
want to remove the redundant report, we will probably want to remove
FirNamedVarargChecker and report during resolution as a cone diagnostic.
2021-09-15 12:11:36 +03:00
Tianyu Geng 3708290ca3 FIR checker: fix NON_VARARG_SPREAD 2021-09-15 12:11:35 +03:00
Tianyu Geng ef80a8ebf6 FIR checker: createPrimitiveArrayType -> createPrimitiveArrayTypeIfPossible 2021-09-15 12:11:33 +03:00
Tianyu Geng b8b9502db4 FIR checker: fix ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_ANNOTATION
Currently this checker is missing `arrayOf` calls inside annotation.
2021-09-15 12:11:28 +03:00
Alexander Udalov 3ef9649344 Minor, fix test data of localVariables/suspend/mergeLvt.kt
It was incorrectly adapted (by me) in d07070e184.
2021-09-15 00:07:49 +02:00
Tianyu Geng 3c84fbcab1 IR: make calls with explicit singleton receiver tailrec [KT-48602] 2021-09-14 23:48:52 +03:00
Tianyu Geng 8525b4932b FIR Checker: check tailrec
Difference from FE1.0
* KT-4285: calls to virtual method with default argument should be
  reported as not tailrec. FE1.0 is missing such cases.
* KT-48600: calls inside lambda should be reported as not tailrec. FE1.0
  also misses such cases.
2021-09-14 23:48:50 +03:00
Alexander Udalov 5df316a129 Minor, rename module backend.jvm:backend.jvm.entrypoint -> backend.jvm.entrypoint 2021-09-14 22:29:13 +02:00
Alexander Udalov 7efc9dac9b JVM IR: extract lowerings to a separate module
Together with extracting codegen to a separate (unrelated) module in the
future, hopefully it'll speed up the build of JVM IR by making it more
parallel, and helping incremental compilation to avoid recompiling code
that depends on lowerings because of `implementation` dependency.
2021-09-14 22:29:12 +02:00
Alexander Udalov eee8b033a6 JVM IR: minimize usages of jvmPhases outside backend.jvm 2021-09-14 22:29:12 +02:00
Alexander Udalov b4c84aa2a6 JVM IR: move out bridge/collection lowering caches to separate files
Both BridgeLoweringCache and CollectionStubComputer are not tecnically
part of the lowerings, so they shouldn't be in the "lower" package.
2021-09-14 22:29:12 +02:00
Alexander Udalov 08cc789123 JVM IR: move out common utilities from lowerings
The main idea is to remove dependencies on lowerings from other
backend.jvm code (mainly codegen), with the hope of extracting lowerings
and codegen to separate unrelated modules in the future.

To achieve this, code which is used both in lowerings and codegen is
moved to the "common" code, mainly JvmIrUtils/JvmIrTypeUtils.
2021-09-14 22:29:12 +02:00
Alexander Udalov 36a3db44da JVM IR: slightly cleanup and split IrUtils.kt
- Move IrType-specific utilities to separate JvmIrTypeUtils.kt
- Extract JvmIrBuilder to a separate file
- Rename IrUtils.kt to JvmIrUtils.kt to be able to tell it apart from
  numerous other IR utils files
2021-09-14 22:29:12 +02:00
Alexander Udalov e857966edb JVM: remove support for disabling NoConstantValueAttributeForNonConstVals
This feature is enabled by default since 1.4, which is the earliest
language version supported by Kotlin at this moment.
2021-09-14 22:29:12 +02:00
pyos d07070e184 JVM_IR: avoid redundant accessors in private inline funs
Their call sites are all in the same file, so we can check whether the
declarations used in the inline function are accessible from all the
places where it will be inlined.

 #KT-48736 Fixed
2021-09-14 22:17:10 +02:00
Denis.Zharkov ef684c0dff FIR: Improve error reporting for EXPRESSION_EXPECTED_PACKAGE_FOUND 2021-09-14 19:13:47 +03:00
Denis.Zharkov 8f6ec42304 FIR: Drop unnecessary withIncrementedQualifierPartIndex 2021-09-14 19:13:46 +03:00
Denis.Zharkov 0923526162 FIR: Minor. Drop unused getWholeQualifierSourceIfPossible 2021-09-14 19:13:45 +03:00
Denis.Zharkov 8ff25825dd Minor. Extract obtainValueParametersFromResolvedLambdaAtom 2021-09-14 19:13:44 +03:00
Denis.Zharkov e3122d0c90 Minor. Extract transformAnonymousFunctionWithExpectedType 2021-09-14 19:13:42 +03:00
Denis.Zharkov 226893c648 FIR: Adjust test data to correct from FE 1.0 point-of-view behavior
^KT-38031 Related
2021-09-14 19:13:41 +03:00
Denis.Zharkov 6e6be7c953 FIR: Adjust test data
Currently, we've got two places where NO_COMPANION_OBJECT is reported
and they perform it kind of differently
2021-09-14 19:13:40 +03:00
Denis.Zharkov 9ca96ebbd2 FIR: Add FirVisibilityQualifierChecker 2021-09-14 19:13:39 +03:00
Denis.Zharkov 9575d4d242 FIR: Rework qualifier-in-expression resolution
Get rid of stateful FirQualifiedNameResolver
Resolve a.b.c-like calls step-by-step using just recursion

^KT-48363 Fixed
2021-09-14 19:13:38 +03:00
Denis.Zharkov 69f7c2278d FIR: Simplify resolution for qualifier receiver
Seems there's no need anymore in ClassifierPrioritized group
2021-09-14 19:13:36 +03:00