Commit Graph

682 Commits

Author SHA1 Message Date
Ilmir Usmanov b3890885c4 JVM: Break infinite loop in finding meaningful instruction
during tail-call optimization.

There can be code, where all next instructions are non-meaningful and
there is a back-edge, for example, while(true){}. Previously, analyzer
incorrectly assumed, that this cannot happen. Now, it keeps track of
visited instructions and says, that there is no meaningful instruction
in such case.
 #KT-56815 Fixed
2023-02-23 17:54:46 +00:00
Ilmir Usmanov 6be734c27e JVM: Remove inplace arguments before state-machine building
#KT-56258 Fixed
2023-02-22 12:45:03 +00:00
Svyatoslav Scherbina f206ff950c [K2/N] Ignore kt15016.kt test because it fails due to KT-56747 2023-02-21 11:52:06 +00:00
Ilmir Usmanov b262070922 JVM IR: Copy type parameters from outer class to suspendImpl
Previously we copied only type parameters from containing class, but we
need to do that for outer classes as well.
 #KT-55125
2023-02-15 13:43:24 +00:00
Ilmir Usmanov e42efe1ee6 JVM IR: Ignore class type parameters if function is static
Otherwise, it leads to type parameters duplication in case of
suspendImpls, since they inherit type parameters from containing class.

 #KT-56407: Fixed
2023-02-07 13:39:25 +00:00
Ilmir Usmanov 901ff06e90 JVM IR: Copy type parameters from class to suspendImpl
These type parameters where used in function parameters,
but since suspendImpl is static function, it has no access
to class type parameters. Solution is to copy them to
the function itself.

 #KT-55125 Fixed
2023-02-02 15:48:10 +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 1990883bdc [K2/N] KT-55464, KT-56091 Fix various klib annotations, including critical ones
Merge-request: KT-MR-8457
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-01-26 11:15:15 +00:00
Igor Chevdar 9d911247fa [K/N] Wrap continuation with ContinuationImpl on callable references
#KT-55869
2023-01-25 15:55:16 +00:00
Ilmir Usmanov 945cdc8884 Minor. Ignore tests in JS_IR_ES6, regenerate tests 2023-01-19 17:04:31 +01:00
Ilmir Usmanov d18672bfb1 Wrap continuation with ContinuationImpl on callable references
in startCoroutineUninterceptedOrReturn. Otherwise, the coroutine will
not be interceptable later.

Add a test, which checks, that intercepted continuation is released.

 #KT-55869
2023-01-19 00:35:36 +00:00
Artem Kobzar 71486a321c [K/JS] Add support of compilation with ES-classes 2023-01-17 18:14:17 +00:00
Vladimir Sukharev 924898afb7 [K/N] KFC-446: K2 platform: Native alpha
Merge-request: KT-MR-7905
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-01-04 16:10:40 +00:00
Igor Chevdar 0f2ebeea15 [tests] Added a test for KT-55494 2022-12-16 18:32:42 +00:00
Steven Schäfer 6af616d3c3 FIR: make declarations marked with 'override' implicitly open
#KT-52236 Fixed
2022-12-14 21:46:41 +00:00
Dmitriy Novozhilov 9946bfcdfd [FIR2IR] Properly handle error references in generation of receivers
^KT-53698 Fixed
2022-12-09 12:02:06 +00:00
Dmitriy Novozhilov 6b343515e1 [Test] Save IR bytecode dumps from BytecodeListingHandler to .ir.txt file instead of _ir.txt
This is needed to keep consistency with other dumps and to allow
  test helper plugin to recognize those dumps
2022-12-01 07:29:37 +00:00
Svyatoslav Kuzmich 78bd6dbdcd [Wasm] Allow implementing function interfaces 2022-11-14 11:23:18 +01:00
Ilya Chernikov 78ca733c38 FIR JS: add K2 variants of all other JS tests
except tests that are not possible to add without some modifications in
the test infra. See todos on the commented-out test declarations
2022-11-12 16:28:24 +01:00
Ilya Chernikov 5b3816cce5 Test infra: refactor IGNORE_BACKEND directive
treat it as a general one, introduce *_K1 and *_K2 variants for
more specific ignoring
2022-11-12 16:28:23 +01:00
vladislav.grechko 70c2f2b86f Support specifying different bytecode listings for FIR and old frontend 2022-10-21 12:57:11 +00:00
Pavel Kunyavskiy ea3713f051 Fix building fake overrides for sam and function references 2022-09-30 08:48:59 +00:00
Pavel Kunyavskiy 2d4c94a115 [K/N] Add test for inter-module suspend function override 2022-09-30 08:48:59 +00:00
pyos 2dd49e5fb4 JVM_IR: unwrap suspend views when generating SAM wrappers
If the super class is in a file that has already been lowered, the base
method has an extra continuation parameter which breaks things.

Also, SAM wrappers around functional objects are tail-call and do not
need continuations ever, so don't even try.

^KT-50950 Fixed
2022-09-23 21:55:00 +02:00
Ilmir Usmanov 3ee09f05ef JVM: Check for multiple {POP, Unit} sequences in suspend function TCO
We already check for {POP, Unit} sequence before ARETURN, but if the
there are multiple sequence before ARETURN, the compiler assumes, that
TCO misses.

The fix is to check, that the instruction after the sequence is either
ARETURN or another {POP, Unit} sequence.

 #KT-50835
 #KT-54152 Fixed
2022-09-22 19:46:52 +02:00
Pavel Mikhailovskii 18e61315f4 KT-27936 Generate InnerClasses attributes 2022-08-23 22:06:10 +00:00
Mads Ager 59c2bde10a [K/N] Unmute passing tests. 2022-08-01 08:57:16 +00:00
Steven Schäfer 2acfb3a41f JVM IR: Avoid direct lambda invokes in inline tests 2022-07-14 23:24:18 +02:00
Steven Schäfer 7d59c7689c JVM IR: Avoid direct invokes in callable reference tests
Due to the direct invoke optimization, most callable reference tests
were not generating callable references/lambdas.
2022-07-14 23:24:18 +02:00
Nikita Nazarov 939a720686 Add android ignore directives for debug mode tests 2022-07-07 14:51:24 +03:00
Nikita Nazarov 7287be6879 Add tests on variable spilling with debug mode enabled
#KT-48678 Fixed
2022-07-07 14:51:24 +03:00
Nikolay Krasko d080297c20 Revert "Add tests on variable spilling with debug mode enabled"
This reverts commit 65bb6abae4.
2022-07-05 11:04:50 +00:00
Nikolay Krasko c1137d9986 Revert "Set android ignore directives for debug mode tests"
This reverts commit 12e40e7b92.
2022-07-05 11:04:49 +00:00
Nikita Nazarov 12e40e7b92 Set android ignore directives for debug mode tests 2022-07-05 09:31:12 +03:00
Nikita Nazarov 65bb6abae4 Add tests on variable spilling with debug mode enabled
#KT-48678 Fixed
2022-07-02 18:29:18 +03:00
Ilmir Usmanov 09c9641e23 FE: Use safe call when searching for suspend modifier
The modifier does not exist, when the parameter type is typealias.

 #KT-35187 Fixed
2022-06-29 06:12:44 +02:00
Ilmir Usmanov f34ae686a0 JVM: Make coroutines spilling tests runtime
instead of bytecode text ones. Check the content of continuation
object instead of bytecode, since this is less prone to changes during
changes in coroutines codegen.

 #KT-48678
2022-06-27 23:11:40 +02:00
Victor Petukhov fa7809cd80 [FE] Remove BuilderInference annotation from tests 2022-06-21 15:01:56 +02:00
Pavel Mikhailovskii ecb3cc193c KT-51883 Don't use "-" in generated unique lifted declaration names 2022-06-10 18:36:04 +00:00
Pavel Mikhailovskii f81d47bad6 KT-46797 Generate generic signatures for suspendImpl 2022-06-08 16:15:08 +02:00
Ilmir Usmanov f922684169 Minor. Add regression test
#KT-52561 Fixed
2022-06-02 13:26:24 +00:00
pyos 513ef575ce JVM: correctly merge typed null values
1. merge(null of type A, null of type B) = null of unknown type;
2. merge(null of type A, something of type B) = merge(unknown null, B).

^KT-52311 Fixed
2022-05-17 11:58:06 +00:00
Ilmir Usmanov 4f53b085ec Do not override collection stub, if the override is suspend
but the stub is not. The other way around should be OK.

 #KT-52237 Fixed
2022-05-09 23:16:58 +00:00
pyos b19b265735 JVM_IR: generate continuation classes for suspend inline references
This is somewhat suboptimal since this results in `::suspendInline`
generating 2 classes while `{ suspendInline() }` only creates 1, but
it's the best allowed by the existing hierarchy of classes in stdlib. At
least it works?

^KT-50832 Fixed
2022-05-09 23:15:05 +00:00
Victor Petukhov fb76d819f0 [FE] Erase type parameters of super types during intersection type emptiness check as well 2022-04-27 19:50:27 +00:00
Victor Petukhov 0f1d212fc5 [FE] Fix tests 2022-04-27 19:50:27 +00:00
pyos a07e21d913 JVM: streamline handling of tail-call suspend functions
Just see if every suspend call is followed only by safe instructions or
returns, then insert a suspension point check if there isn't a direct
return.

The first part of this is equivalent to the old implementation, just
refactored. The second part generates strictly more checks; see, for
example, the fixed test, in which the previous implementation failed to
insert a check before a CHECKCAST.

^KT-51818 Fixed
2022-04-11 17:00:26 +00:00
Ilmir Usmanov 1e3f84402d Safely check for suspend function parent
The issue here is that the function can be in unlowered file, and
thus its parent package fragment and not class.

 #KT-49317 Fixed
2022-04-08 23:31:49 +02:00
Ilmir Usmanov 1488790cd3 Replace recursion with a loop
#KT-51530 Fixed
2022-04-07 01:08:22 +00:00
Ilmir Usmanov 7579be6c68 Generate CHECKCAST after ACONST_NULL in coroutines
If we do not do this, the state-machine builder will not know the type
of the ACONST_NULL, defaulting to Object, leading to VerifyError.
Alternatively, we could use LVT to deduce the type, but getting types
from LVT is something I got rid of long time ago, and I have no desire
to return it back.

Generating CHECKCAST hints the state-machine builder the type of the
variable avoiding the issue of VerifyError. However, this CHECKCAST
replaces StrictBasicValue.NULL_VALUE with BasicValue in
OptimizationBasicInterpreter. To preserve optimization on not-spilling
known nulls, introduce BasicValues, which represent typed nulls and
create BasicInterpreter, which is aware of them. This way we have the
best of two worlds - we do not spill known nulls, and we know the type
of ACONST_NULL.

 #KT-51718 Fixed
2022-03-30 14:27:29 +00:00