Commit Graph

104336 Commits

Author SHA1 Message Date
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 d62323cdf1 [Native] Move addTopLevelInitializer from IrUtils2
This function is actually used only in `InteropLowering` and it
is too specific to be included into utils.
2023-09-05 11:21:51 +00:00
Ivan Kylchik 5cd96831dc [Native] Move isRestrictedSuspendFunction from IrUtils2
This function is also helpful for JVM backend.
2023-09-05 11:21:50 +00:00
Ivan Kylchik 2657adc6dc [Native] Move addFile from IrUtils2
This function is actually used only in `BackendPhases` and it is
too specific to be included into utils.
2023-09-05 11:21:50 +00:00
Ivan Kylchik 4fb29a5e12 [Native] Drop addArguments from IrUtils2
We can simplify single usage of this function
2023-09-05 11:21:50 +00:00
Ivan Kylchik 20165dd699 [Native] Drop defaultOrNullableType from IrUtils2
We can simplify most usages of `defaultOrNullableType`
2023-09-05 11:21:50 +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 5c68ea2b64 [Native] Simplify irCatch from IrUtils2 2023-09-05 11:21:50 +00:00
Ivan Kylchik 8cc4db39d2 [Native] Drop copy from IrUtils2
It is not used anywhere
2023-09-05 11:21:50 +00:00
Ivan Kylchik b3474ac730 [Native] Drop irBuilder from IrUtils2
We can reuse `createIrBuilder` function
2023-09-05 11:21:50 +00:00
Ivan Kylchik 9e750e900d [Native] Drop createField from IrUtils2
We can call `IrFieldImpl` directly, the same way it is done
for other IR declarations in `CBridgeGen` file.
2023-09-05 11:21:50 +00:00
Ivan Kylchik 7e71e778c9 [Native] Drop stub from IrUtils2
It is not used anywhere
2023-09-05 11:21:50 +00:00
Ivan Kylchik b10d330cfd [Native] Drop getContainingFile from IrUtils2
We can reuse `fileOrNull` function from common `IrUtils`
2023-09-05 11:21:50 +00:00
Ivan Kylchik a437e0378a [Native] Drop irCallOp from IrUtils2
It is not used anywhere
2023-09-05 11:21:50 +00:00
Ivan Kylchik 4376e58acb [Native] Drop createArrayOfExpression from IrUtils2
We can reuse the same function from common `IrUtils`
2023-09-05 11:21:50 +00:00
Ivan Kylchik 962172f96d [Native] Drop irSetVar from IrUtils2
We can reuse `irSet` function
2023-09-05 11:21:50 +00:00
Ivan Kylchik 9ab053a3a6 [Native] Drop substitute from IrUtils2
We can reuse the same function from common `IrTypeUtils`
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 3efe07d0cb [Native] Drop getArgumentsWithIr from IrUtils2
We can reuse the same function from common `IrUtils`
2023-09-05 11:21:49 +00:00
Ivan Kylchik abc061e17f [IR] Restore and fix ifConstVal test
It was accidentally dropped after KT-55196 fix.
2023-09-05 11:06:43 +00:00
Alexander Udalov 34f52aaeda Reflection: fix callBy for functions with 32 * N parameters
Optimization in 2439c22ff6 introduced an array `absentArguments` with
default values of all parameter types, which is copied in `callBy`
instead of being recomputed each time. Unfortunately, its size was
computed incorrectly: `maskSize` should only take into account
value parameters (see the `parameter.kind == KParameter.Kind.VALUE`
check in `callBy`).

This led to an issue where if the function had 32 * N value parameters
and 1 receiver parameter, `maskSize` was greater by 1 than expected,
which caused an exception due to mismatching argument array sizes.

 #KT-61304 Fixed
2023-09-05 11:05:29 +00:00
Jinseong Jeon 421cd9929b SLC: use optimal type mapping mode for receiver parameter
...and other kinds of parameters as well
2023-09-05 10:33:54 +00:00
Jinseong Jeon 4cdc22c9cc AA FIR: use fully expanded type when computing optimal type mapping mode
^KT-61460 Fixed
2023-09-05 10:33:53 +00:00
Dmitriy Novozhilov 1868b29cc9 [FIR] Don't map java functions which override kotlin builtin function with erased parameter type if it's not needed
There is a case when we shouldn't hide a function even if it overrides
  builtin member with value parameter erasure: if substituted kotlin
  overridden has the same parameters as current java override. Such
  situation may happen only in case when `Any`/`Object` is used as
  parameterization of supertype:

// java
class MySuperMap extends java.util.Map<Object, Object> {
    @Override
    public boolean containsKey(Object key) {...}

    @Override
    public boolean containsValue(Object key) {...}
}

In this case, the signature of override, made based on the correct
  kotlin signature, will be the same (because of { K -> Any, V -> Any }
  substitution for both functions). And since the list of all such
  functions is well-known, the only case when this may happen is when
  value parameter types of kotlin overridden are `Any`

This change doesn't affect any tests in the moment, because it's part of
  bigger refactoring of proper storing IR declarations during FIR2IR
  conversion (KT-61637)

Without this change, there is one test break in branch for KT-61637:
`FirPsiBlackBoxCodegenTestGenerated.SpecialBuiltins.testMapGetOrDefault`
2023-09-05 10:18:24 +00:00
Pavel Kirpichenkov cf98fb5612 [Tests] Add .knm stub consistency test
The test compares stub trees built from .knm files directly and from
the decompiled text. Test data for .class decompiler is reused,
JVM-specific cases are ignored

KT-61354
2023-09-05 09:36:25 +00:00
Ivan Kylchik 2537ff94b7 [Native] Move StringTable and its builder to separate file 2023-09-05 08:35:48 +00:00
Ivan Kylchik 86b4d36b54 [Native] Make StringTable and its builder internal 2023-09-05 08:35:47 +00:00
Ivan Kylchik 70697af6b9 [Native] Move proto utils from KonanIrLinker into separate utils file 2023-09-05 08:35:47 +00:00
Ivan Kylchik 66b9c2f260 [Native] Move FORWARD_DECLARATION_ORIGIN into KonanForwardDeclarationModuleDeserializer 2023-09-05 08:35:47 +00:00
Ivan Kylchik cc906ad6d5 [Native] Move INVALID_INDEX into KonanPartialModuleDeserializer 2023-09-05 08:35:47 +00:00
Ivan Kylchik 79fa0d2648 [Native] Move KonanForwardDeclarationModuleDeserializer to a separate file 2023-09-05 08:35:47 +00:00
Ivan Kylchik 7d1c929fb5 [Native] Make KonanForwardDeclarationModuleDeserializer nested instead of inner 2023-09-05 08:35:47 +00:00
Ivan Kylchik 701dc72f70 [Native] Move KonanInteropModuleDeserializer to a separate file 2023-09-05 08:35:47 +00:00
Ivan Kylchik 6d0b936639 [Native] Make KonanInteropModuleDeserializer nested instead of inner 2023-09-05 08:35:47 +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 3fba699c49 [Native] Move KonanPartialModuleDeserializer to a separate file 2023-09-05 08:35:47 +00:00
Ivan Kylchik 13a39c82ae [Native] Make KonanPartialModuleDeserializer nested instead of inner 2023-09-05 08:35:47 +00:00
Ivan Kylchik bf7f2afe5d [Native] Rename KonanIrlinker to KonanIrLinker 2023-09-05 08:35:47 +00:00
Ivan Kylchik 66650d2dcc [Native] Drop IrSerializationUtil file
Most methods from there are unused
2023-09-05 08:35:47 +00:00
Ivan Kylchik 852d829d83 [Native] Drop KonanFileMetadataSource class
Replaced it with more common `DescriptorMetadataSource.File`
2023-09-05 08:35:47 +00:00
Ivan Kylchik 36373ddfa7 [Native] Drop unused CodegenStaticFieldMetadata class 2023-09-05 08:35:46 +00:00
Ivan Kylchik d13d249640 [Native] Drop excess cast from isExternalObjCClass method 2023-09-05 08:35:46 +00:00
Ivan Kylchik a35defc682 [Native] Replace KonanIrModuleFragmentImpl with IrModuleFragmentImpl 2023-09-05 08:35:46 +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
Kirill Rakhman f08d4b8bb1 [FIR] Improve condition for sorting equivalent calls by source first
This accommodates for declarations generated by plugins that don't have
a source.
2023-09-05 07:08:28 +00:00
Alexander Shabalin 9ab6a5ff56 [K/N] Migrate all stdlib_external tests to new testing infra ^KT-61259
- Move backend.native/tests/stdlib_external to runtime/test This mirrors
  tests location (in relation to sources) on other backends.
- Remove all backend.native/tests tasks using stdlib_external.
  Additionally remove now unused KonanGTest.
- Include complete native-wasm/test and runtime/test in
  native/native.test
- In runtime/test/numbers/MathTest.kt leave only native-specific part.
2023-09-04 18:51:10 +00:00
Roman Golyshev c9e4b71010 KT-61689 [LL API] Handle scripts in ContextCollector
Add `FirDesignationWithScript`, because regular designation
does not account for scripts at all - that makes it
cumbersome to add the script's top level and implicit
receiver scopes when collecting contexts for the
non-top-level declarations (class members, for example)

^KT-61689 Fixed
2023-09-04 16:57:37 +00:00
Roman Golyshev 83049dc25c KT-61689 [LL API] Improve readability of withInterceptor function 2023-09-04 18:02:20 +02:00
Roman Golyshev 90ed90c9a7 KT-61689 [LL API] Support scripts in ContextCollector tests 2023-09-04 18:02:20 +02:00
Yan Zhulanow 5559a0754d [LL API] Handle smart casts correctly on 'FirCodeFragment' analysis 2023-09-04 15:47:56 +00:00