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.
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.
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?
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.
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.
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.
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.
- 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
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