Commit Graph

533 Commits

Author SHA1 Message Date
Sergej Jaskiewicz f5a00c788a [klib] Disable ManglerChecker on K2
`ManglerChecker` is a class that verifies that for each IR declaration
(except some, see its `needsChecking` property) its mangled name
(computed from IR) is the same as the mangled name computed from its
frontend representation — `DeclarationDescriptor` on K1 or
`FirDeclaration` on K2.

The way it does it is as follows.

On K1, `ManglerChecker` looks if the declaration has a true,
non-IR-based descriptor, it if it does, then it checks it
(see ManglerChecker.Companion#hasDescriptor).

On K2, since we don’t have any descriptors, `ManglerChecker` looks if
the declaration’s metadata property is `null` (because the corresponding
`FirDeclaration` is stored there). If it’s not, it checks it
(see ManglerChecker.Companion#hasMetadata).

The issue is that those two conditions are not equivalent.

When the Compose compiler plugin transforms an IR function, it copies
its `metadata` property (as it should, because `metadata` can contain
anything, not necessarily the frontend representation), but doesn't set
the descriptor. Because of that, on K1 that transformed function is
skipped in `ManglerChecker`, and on K2 it’s not.

The correct usage would be to properly distinguish which declarations
come from the FE as is, and which are transformed/synthesized,
and skip the latter. But it is unclear how to implement this.

For now, the easiest way to fix this on K2 is to not run ManglerChecker
at all.

KT-60648
^KT-59448 Fixed
2023-07-24 19:29:17 +00:00
Sergej Jaskiewicz b57b4e055e [klib] Move some duplicated code from subclasses to IdSignatureBuilder 2023-07-24 16:40:15 +00:00
Sergej Jaskiewicz ce6e904b70 [klib] Don't forget to set signatures' descriptions before serialization
Ensure that in IdSignatureBuilder hashId/hashIdAcc is only set
together with the description.

In 6142d75bb4 we implemented setting
descriptions when building signatures from descriptors, but forgot to
do the same for building signatures from IR, resulting in missing
descriptions in klibs.

See also: KT-59486
2023-07-24 16:40:14 +00:00
Pavel Kunyavskiy d797505f06 [K/N] Drop merging forward and real declaration in deserializer
^KT-59643
2023-07-24 08:24:20 +00:00
Sergej Jaskiewicz 3828552a1c [IR] Make IrFunctionWithLateBinding a subclass of IrSimpleFunction 2023-07-21 13:12:37 +00:00
Sergej Jaskiewicz d16445aef2 [klib] Drop the addDebugInfo setting that was always true 2023-07-21 12:51:47 +00:00
Artem Kobzar 044c0adae7 [K/JS] Implement an incremental compilation for the per-file granularity 2023-07-19 15:57:56 +00:00
Sergej Jaskiewicz e6c4a8957d [IR] Make IrPropertyWithLateBinding a subclass of IrProperty 2023-07-18 10:19:27 +00:00
Dmitriy Novozhilov 11974c14d8 [IR] Fix various TODOs in SymbolTable 2023-07-17 21:02:40 +00:00
Dmitriy Novozhilov 4986cb14aa [IR] Extract descriptor part from SymbolTable into separate component
After this change SymbolTable (and ReferenceSymbolTable) contains only
  methods with IdSignatures. All descriptors-related methods are moved
  into DescriptorSymbolTableExtension, which automatically delegates to
  the SymbolTable if needed

At this moment there are cross-references between SymbolTable, because
  descriptor API is still actively used across backends. So SymbolTable
  is accessible in some place then descriptor extension will be accessible
  too

DescriptorSymbolTableExtension is an implementation of abstract SymbolTableExtension
  which allows to implement different kinds of storages, e.g. FIR based
  (it probably will be needed for FIR2IR)
2023-07-17 21:02:39 +00:00
Artem Kobzar df0e4e0b53 [K/JS] Remove declarations with @JsExport.Ignore from klib explicit roots 2023-07-17 15:11:47 +00:00
Sergej Jaskiewicz 6142d75bb4 [klib] Serialized mangled names of declarations along with signatures
^KT-59486 Fixed
2023-07-14 20:26:45 +00:00
Sergej Jaskiewicz 9fcdc10019 [IR] Reorder parameters in IrFactory#createValueParameter
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-30 12:41:02 +00:00
Sergej Jaskiewicz f14a713e49 [mangling] Remove the unused fqnString method from KotlinMangler 2023-06-29 13:04:25 +00:00
Sergej Jaskiewicz 30cd2c3025 [IR] Reorder parameters in IrFactory#createProperty
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-28 13:21:55 +00:00
Sergej Jaskiewicz 7b77ec9930 [IR] Reorder parameters in IrFactory#createFunction
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-28 10:13:09 +00:00
Sergej Jaskiewicz 5b8b3644fc [IR] Reorder parameters in IrFactory#createLocalDelegatedProperty
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-27 10:22:54 +00:00
Dmitriy Dolovov 4c0583e415 [IR] Two modes of signature rendering
^KT-59486
2023-06-26 15:59:31 +00:00
Sergej Jaskiewicz d73e44b89b [FIR] Set metadata for IrFields generated from FirFields
This is useful for signature tests (see how
IrMangledNameAndSignatureDumpHandler uses `metadata` to retrieve
the original FIR declaration)
2023-06-26 12:39:37 +00:00
Sergej Jaskiewicz 2b4a08524d [IR] Reorder parameters in IrFactory#createTypeParameter
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-26 09:52:11 +00:00
Sergej Jaskiewicz b1f7b5e982 [IR] Reorder parameters in IrFactory#createTypeAlias
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-26 09:34:41 +00:00
Sergej Jaskiewicz f46761a241 [IR] Reorder parameters in IrFactory#createClass
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-23 13:25:34 +00:00
Sergej Jaskiewicz 0ae95b39c3 [IR] Reorder parameters in IrFactory#createConstructor
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-22 16:31:17 +00:00
Sergej Jaskiewicz 0b7db067e6 [IR] Reorder parameters in IrFactory#createField
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-22 15:55:02 +00:00
Alexander.Likhachev a93c49baf1 [Build] Fix a bunch of buildscript compilation warnings
#KTI-1221 Fixed
2023-06-22 15:16:08 +00:00
Igor Chevdar cc9dd48c09 [K/N] Support non-LazyIR for cached libraries
Use the same lazy deserialization mechanism (inline function bodies, class fields)
for both LazyIR and usual IR
2023-06-22 08:10:11 +00:00
Alexander Udalov da884bd554 Minor, add error message to linker exception
(cherry picked from commit 04048d57ab912823504e9f57ddbc3a5f06b6af7c)
2023-06-21 14:24:28 +00:00
Sergej Jaskiewicz 487847bedc fixup! [IR] Add the description field to CommonIdSignature 2023-06-20 15:31:46 +00:00
Sergej Jaskiewicz e0b8cf827a fixup! [IR] Add the description field to CommonIdSignature 2023-06-20 15:31:46 +00:00
Sergej Jaskiewicz 3a30d74096 [IR] Add the description field to CommonIdSignature
This field shall be used for storing a human-readable representation
of the declaration, that would be a mangled name for now.

This field is not yet serialized. Serialization will be implemented in
follow-up commits.

See KT-59486
2023-06-20 15:31:45 +00:00
Sergej Jaskiewicz c2fde1a915 [IR] Reorder parameters in IrFactory#createEnumEntry
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-20 14:12:58 +00:00
Kirill Rakhman 67fc46a190 [FIR] Fix handling of type parameters in FIR mangling
#KT-57429 Fixed
2023-06-09 08:22:21 +00:00
Alexander Korepanov 22dfe07580 [IR BE] Add the ability to collect PL stubbed symbols
^KT-57347 related
2023-06-06 09:27:57 +00:00
Dmitriy Dolovov 280caf003f [PL] W/a for broken @Deprecated annotations in existing c-interop KLIBs
^KT-59030
2023-06-05 12:47:56 +00:00
Ivan Kylchik b9856320cf [IR] Rename fqName to packageFqName for IrPackageFragment 2023-06-02 16:38:04 +00:00
Nikolay Lunyak 70605c84df [FIR Native] KT-58549: Get rid of the builtin provider
According to
`FirNativeCodegenBoxTestGenerated.testNestedClassesInAnnotations`,
the annotation
`kotlin.internal.PlatformDependent` is
unresolved reference.

^KT-58549 Fixed
2023-06-01 10:27:54 +00:00
Dmitriy Dolovov 161fe1d2ca [IR] Don't produce gaps for skipped IR declarations during serialization 2023-05-30 10:14:08 +00:00
Dmitriy Dolovov a01a6b64ad [PL] Fix: Don't use locations in compiler messages
^KT-58837
2023-05-26 14:03:33 +00:00
Sergej Jaskiewicz 02180e8685 Factor out duplicated mangling logic for functions into the base class
^KT-57777 Fixed
^KT-57818 Fixed
2023-05-26 10:55:24 +00:00
Pavel Kunyavskiy ee1608ec99 [PL] Make call an exception in case of several inherited implementations
^KT-57701
2023-05-24 08:17:59 +00:00
Dmitriy Dolovov 650a3c467d [PL] Fix: Use stable order of return targets in 'illegalNonLocalReturn' case 2023-05-23 16:23:41 +00:00
Dmitriy Dolovov 1536bca1bb [PL] Handle illegal fun interface SAM conversions
^KT-53967
2023-05-23 16:23:41 +00:00
Dmitriy Dolovov 7f4d9ddde5 [PL] Optimization: Avoid excessive type checks in IR type operators 2023-05-23 16:23:41 +00:00
Nikolay Lunyak 00e8dc1c39 [FIR] KT-58444: Don't run IR generation when compiling native shared
Normally during metadata compilation we use
`K2MetadataCompiler` and it serializes
metadata to klibs without generating IR.

Native shared compilation uses the K2Native
compiler, which generates klibs based on both
the fir and fir2ir information.

It would be nice to reuse `K2MetadataCompiler`
for native shared, but currently it has no
support for the commonizer, and also reads
the stdlib metadata from a jar instead of a
klib, and there's no simple idiomatic way
to pass the `distribution.klib` value down
to `KLibResolverHelper` (native compilation
has some commonized dependencies, and they
explicitly depend on `stdlib`, so we must
resolve it this way or strip it away to be
able to use the metadata jar instead). There
may be other issues, I only digged a bit.

Instead, this change modifies the K2Native
in such a way that it can generate klibs
with metadata without fir2ir info.

Note that this change does not fix KT-58139,
because KT-58139 fails due to performing the
constants evaluation directly during the
metadata serialization when the needed info
does (and, as I was told, should) not exist
(namely, valid property initializers).

^KT-58444 Fixed
2023-05-23 15:59:41 +00:00
Sergej Jaskiewicz 1a29b9efff [FIR, IR] Fix name mangling for functions with context receivers
- Mangled names of property accessors now include context receiver
  types of the corresponding property when computed from FIR.
- Context receivers are now supported when computing mangled names
  from IR
- IrBasedDescriptors now account for context receivers

^KT-57435 Fixed
2023-05-23 08:55:50 +00:00
Sergej Jaskiewicz e473eaa5d6 [IR] Give generic parameters proper names in IrSymbol-related classes
Single-letter names were very confusing, especially in declarations like

```kotlin
private inline fun <
        reified D : IrDeclaration,
        reified ES : IrDelegatingSymbol<AS, D, *>,
        reified AS : IrBindableSymbol<*, D>
        > finalizeExpectActual(
    expectSymbol: ES,
    actualSymbol: IrSymbol,
    noinline actualizer: (e: D, a: D) -> Unit
)
```
2023-05-18 12:19:52 +00:00
Dmitriy Dolovov 706a4e9919 [PL] Fix: Remove annotations containing unlinked arguments
Both explicitly specified and default argument expressions are considered.

In case an argument expression is considered as 'unlinked' the whole annotation
is removed from the declaration. An appropriate compiler warning logged for each
such case.
2023-05-16 08:30:29 +00:00
Sergej Jaskiewicz 6c211f3a39 [IR] Make IrFunctionSymbol a sealed interface 2023-05-10 11:51:26 +00:00
Sergej Jaskiewicz 1a371350ea [IR] Make IrClassifierSymbol a sealed interface 2023-05-10 11:51:25 +00:00
Igor Chevdar f90db20512 [K/N][caches] Added klib hash computing and storing 2023-05-10 08:37:32 +00:00