Commit Graph

146 Commits

Author SHA1 Message Date
Ivan Kylchik d3d28783c5 [IR] Support const optimizations for JS backend 2023-07-06 11:00:14 +00:00
Vladimir Sukharev 3d60ed8874 [Test] Convert IGNORE: NATIVE directives in box tests from A to C
^KT-59057

Merge-request: KT-MR-10747
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-06-22 08:39:20 +00:00
Ivan Kylchik dd264cff50 [IR] Split const folding into necessary one and for optimizations only
In this commit we have a lot of change in test data. This was caused
by the way where we evaluate constants. We split constant evaluation
into two distinct parts: only necessary evaluations for `fir2ir`
(like const val and annotations) and optimizations for lowering.
Now we don't do all constant evaluation on `fir2ir`, but IR
dump is executed after this phase, so test data changed.

#KT-58923
2023-06-14 19:02:39 +00:00
Pavel Kunyavskiy 456783436c [K/N] Fix cast to NativePtr mis-compilation
^KT-59022
2023-06-08 10:40:29 +00:00
Pavel Kunyavskiy f2520a9cb7 [K/N] Rework is checks and as casts codegeneration
^KT-58707
^KT-59022
2023-06-05 08:56:17 +00:00
Igor Yakovlev 44190937b0 [Wasm] Fix generic call return type for functions with default parameters 2023-04-04 18:39:18 +00:00
Vladimir Sukharev 9df5c54db3 [K2/N] KT-55828: Enable fixed tests
Merge-request: KT-MR-9246
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-03-27 17:25:54 +00:00
Ivan Kylchik 7cf9dda8dc [JS] Support evaluation of const intrinsics for K2
#KT-56023 Fixed
#KT-51582 Fixed
2023-03-24 15:55:04 +00:00
Svyatoslav Kuzmich abf70a586c [Wasm] stdlib API: make kotlin.assert internal
Being disabled by default
 and not well-documented, these functions cause confusion among early
 adopters as to why their code don't work properly.

Assert APIs need a proper design across Kotlin platforms.
 Since APIs are not available in common code and K/JS, it is premature
  to have such a general feature in a new experimental platform.

Compiler tests:
* Mute tests that rely on assert.
* Replace JVM-specific assert calls with require calls and unmute passed K/JS tests.

Merge-request: KT-MR-8636
Merged-by: Svyatoslav Kuzmich <svyatoslav.kuzmich@jetbrains.com>
2023-02-02 07:06:12 +00:00
Vladimir Sukharev fbcb07d375 [K2/N] KT-55828 Enable already fixed and accidentally disabled tests
Merge-request: KT-MR-8605
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-02-01 10:44:26 +00:00
Artem Kobzar 71486a321c [K/JS] Add support of compilation with ES-classes 2023-01-17 18:14:17 +00:00
Vladimir Sukharev ff6ea40056 KT-55828: Disable failed tests for K2 Native in OPT mode
Merge-request: KT-MR-8229
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-01-09 15:09:04 +00:00
Pavel Mikhailovskii 06d3e1d8bd KT-55005 Do not generate CHECKCAST before AASTORE 2022-12-21 15:06:07 +00:00
Alexander Udalov d7a58a7c6c Keep track of array types in OptimizationBasicInterpreter
Merging array types with different element types, for example
`[Lj/l/String;` and `[Lj/l/Object;`, now produces `[Lj/l/Object;`
(instead of `Lj/l/Object;`), which allows for more precise tracking of
null values because we assume that AALOAD on a non-array typed value is
possible only if that value is null.

 #KT-54802 Fixed
2022-11-07 17:22:38 +01:00
Alexander Udalov 54ab66cd4e Add regression test for KT-54707 2022-11-01 11:24:03 +01:00
pyos 65c153a722 JVM: consider casts of null to be redundant
These should only have ever been necessary for field type inference in
coroutines, which should have been fixed by 0fc676a20c.

Unlike 903a5d69a4, this time the change is in an optimization pass.
Advantage: optimization passes have a closer to the JVM view of the
bytecode, which makes this change significantly more likely to be correct.
Disadvantage: technically we don't really guarantee optimization passes
other than FixStack will run at all. For KT-54581 this is 100% fine
since the problem itself is caused by redundant checkcast elimination in
the first place (otherwise there would've been a redundant cast to
String), but for KT-53146 this means the fix is somewhat incidental and
not necessarily guaranteed.

^KT-53146 Fixed
^KT-54581 Fixed
2022-10-24 11:11:21 +02:00
Pavel Mikhailovskii 0947834f0d Add a test for KT-54318 2022-10-10 13:47:34 +02:00
Pavel Mikhailovskii 5fdfd4a421 Revert "KT-53146 Don't coerce Nothing? returned from "catch" clauses"
This reverts commit 903a5d69a4.
2022-10-10 13:36:44 +02:00
Pavel Mikhailovskii 903a5d69a4 KT-53146 Don't coerce Nothing? returned from "catch" clauses
At first, I tried to modify the logic in PromisedValue.materializeAt
to get rid of all casts from Nothing? to other types, but that broke
a number of tests containing casts of java.lang.Void to other types,
so I decided to fix only this particular case with try...catch
(for some reason, here we get a null of type java.lang.Object).
2022-09-29 06:15:39 +00:00
Pavel Mikhailovskii a75d5ba4cf KT-53465, KT-53677 Get rid of unnecessary checkcasts to array of reified type 2022-09-06 18:33:38 +00:00
Mads Ager 59c2bde10a [K/N] Unmute passing tests. 2022-08-01 08:57:16 +00:00
Victor Petukhov 0f1d212fc5 [FE] Fix tests 2022-04-27 19:50:27 +00:00
Pavel Kunyavskiy 4873f18067 [K/N] Enable definitely not null cast test for native 2022-03-31 09:02:14 +00:00
Svyatoslav Scherbina cf581738c3 Native: improve ClassCastException message for local classes
Previously it was like "null cannot be cast to MyObject" or
"MyObject cannot be cast to null", because `KClass.qualifiedName` is
`null` for local classes (including anonymous ones).

Use `KClass.toString()` instead, for both object actual dynamic type
and cast target type. This string representation is generally more
meaningful for such cases, and contains useful details for local
classes.
2022-03-28 08:21:55 +00:00
Mikhael Bogdanov 15e08893aa FIR: support DefinitelyNotNull types
#KT-49465 Fixed
2022-02-03 14:07:20 +01:00
Pavel Punegov a4123a6be9 [K/N][test] Ignore test that fails due to ^KT-50763 2022-01-13 08:31:10 +00:00
Pavel Punegov 8744e3db74 [K/N][test] Ignore test ^KT-49422 2022-01-10 09:01:05 +00:00
Dmitry Petrov 4ad6cfcf53 JVM_IR fix cast to not-null type
We can't rely on argument type nullability here, because it still can
hold an uninitialized value on JVM.

KT-50577 KT-35272 KT-27427
2021-12-30 13:41:17 +03:00
Xin Wang c74453d8d2 JVM_IR KT-48987 handle star projection arguments in smart casts 2021-12-22 00:48:15 +01:00
Mikhail Glukhikh 0f4647d95e Black box: update/set FIR status for some new tests 2021-12-09 13:26:37 +03:00
Roman Artemev 3bef04cf5e Fix test and unmute it for JVM 2021-11-22 19:00:43 +03:00
Mikhail Glukhikh cf104c8433 FIR: add status line to all failing black box tests 2021-11-20 03:37:31 +03:00
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00
Igor Yakovlev ce360bb10b [WASM] Implementation of Class references 2021-11-15 19:53:46 +03:00
Roman Artemev 23ad0e7c63 [TEST] Add test checking cast to DNN type
muted temporary due to required support in backends
2021-10-28 18:03:14 +03:00
Igor Laevsky 50ca86838f [WASM] Fix build 2021-10-14 17:24:07 +03:00
Igor Laevsky cb5bef1535 [Wasm] Remove unnecessary testHelpers and add assertions from stdlib 2021-10-14 17:24:06 +03:00
Svyatoslav Kuzmich 15acc412ba [Wasm] Update testdata after coroutines support 2021-10-12 08:42:00 +03:00
Svyatoslav Kuzmich aa5f98f919 [JS] Remove KJS_WITH_FULL_RUNTIME for tests that already have WITH_RUNTIME 2021-10-07 22:36:18 +03:00
Svyatoslav Kuzmich 6eb81517a0 [Wasm] Unmute passed Wasm tests 2021-10-02 06:14:35 +00:00
Svyatoslav Kuzmich c88cde2f8b [Wasm] DONT_TARGET_WASM_BACKEND => IGNORE_BACKEND in testdata 2021-10-02 06:14:35 +00:00
Svyatoslav Kuzmich ab9a23cbfa [Wasm][Stdlib] Reuse K/N collections and StringBuilder 2021-10-01 17:18:49 +03:00
Alexander Udalov b821b26cfe JVM IR: do not try to optimize casts in TypeOperatorLowering
In case the cast value is used as a receiver to a private method call,
the cast is actually necessary, see KT-48927. Also, this optimization
has backfired once already (see kt48659_identityEqualsWithCastToAny.kt).
It seems that the best way to optimize these casts is not to generate
them in the first place, and/or use bytecode postprocessing.

Apparently the only kind of casts which need to be eliminated are those
which occur on an inline class to its supertype. Otherwise the
unsafe-coerce intrinsic is inserted at the incorrect place, and several
tests fail (uncastInlineClassToAnyAndBack.kt, genericOverride.kt,
classGenericOverride.kt).

 #KT-48927 Fixed
2021-09-30 13:32:36 +02:00
Igor Yakovlev 41a69ad388 [WASM] Add receiver capturing to callable references 2021-09-20 19:08:22 +03:00
Igor Laevsky 00f61978b8 WASM: Enable exception handling tests 2021-09-08 19:56:38 +03:00
Svyatoslav Kuzmich b79719d6f5 [Wasm] Fix unit issues
- Materialize unit when its value is actually needed.
- Special-case Unit_getInstance return type at codegen. It should be a
  proper Unit object instead of a "void"
2021-09-08 19:56:26 +03:00
pyos dab693b075 Revert "JVM IR: Implement CHECK_NOT_NULL as a lowering"
This reverts commit dcd72b06d8.

Using a temporary variable has an effect on casts and GC.
2021-04-19 16:05:12 +02:00
Denis.Zharkov a750d9466e FIR2IR: Rework resulted overridden-relation structure
The difference is how we deal with intermediate fake overrides
E.g., in case

interface A { /* $1 */ fun foo() }
interface B : A {
     /* $2 */ fake_override fun foo()
}
interface C : B {
   /* $3 */ override fun foo()
}

We've got FIR declarations only for $1 and $3, but we've got
a fake override for $2 in IR.

Previously, override $3 had $1 as its overridden IR symbol, just because
FIR declaration of $3 doesn't know anything about $2.

Now, when generating IR for $2, we save the necessary information
and using it for $3, so it has $2 as overridden.

So, it's consistent with the overridden structure of FE 1.0 and this
structure is necessary prerequisite for proper building of bridges
for special built-ins.
2021-02-20 10:59:22 +03:00
Jinseong Jeon 4cb32cd38a FIR2IR: add implicit NOT_NULL cast for @FlexibleNullability type 2020-11-18 13:06:48 +03:00
Svyatoslav Kuzmich fdd7fa5aea [Wasm] Mute codegen box tests 2020-11-09 16:04:43 +03:00