Commit Graph

614 Commits

Author SHA1 Message Date
Igor Laevsky 8dc81b6c57 [Wasm][Temporary] Stubs for typeOf and ::class constructs 2021-11-03 16:23:01 +03:00
Roman Artemev 9f52326d14 [JS IR] Fix default arguments in suspend functions
Don't forget to remap parameter references in default arg expressions

The issue originally discovered in kotlinx.coroutines tests.

 - add test
2021-10-25 12:56:16 +00:00
Igor Laevsky 50ca86838f [WASM] Fix build 2021-10-14 17:24:07 +03:00
Artem Kobzar d2e5523180 test: adapt genericParameterResult.kt test for JS IR backend. 2021-10-14 14:05:39 +00:00
pyos 226306ac83 IR: check whether local declarations need to throw after Nothing return
^KT-48982 Fixed
2021-10-12 15:09:05 +02:00
Svyatoslav Kuzmich 15acc412ba [Wasm] Update testdata after coroutines support 2021-10-12 08:42:00 +03:00
Ilmir Usmanov f760cd6736 Make CHECKCAST Object not break tail-call optimization
Since CHECKCAST Object does nothing for return value of suspend
function - the function returns references only, this is safe.
 #KT-49157 Fixed
2021-10-11 06:40:26 +00: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
Sergej Jaskiewicz 65d40c2253 [JS IR] Make tests that use directives pass with IR BE 2021-10-06 09:23:50 +00:00
Alexander Udalov 31ba7f24b1 JVM IR: fix generic signatures of suspend function references
Using `kotlin.jvm.functions.Function{n+1}` (via
`getJvmSuspendFunctionClass`) for suspend functions was wrong in the
function reference lowering, because we didn't adapt the parameter types
by transforming the last type to Continuation and adding Object, and
generic signature ended up being incorrect.

Actually there was no need to use `kotlin.jvm.functions.Function{n+1}`
at all. We can just use the built-in
`kotlin.coroutines.SuspendFunction{n}` as a supertype, and it will be
mapped correctly later in codegen. It's not even needed to add the
`kotlin.coroutines.jvm.internal.SuspendFunction` marker manually, since
it's also handled by the codegen (see `IrTypeMapper.mapClassSignature`).

 #KT-48732 Fixed
2021-10-01 12:43:00 +02:00
Ilmir Usmanov b0088fd06d Minor. Ignore test on JS_IR 2021-09-20 21:29:58 +00:00
Ilmir Usmanov 91491eef06 Fixup end label of local variable if it is before start label
In that case, put end label to next label after start label.
2021-09-20 21:29:58 +00:00
pyos 0864f9faf8 JVM_IR: mark inline lambda functions with a special origin
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?
2021-09-15 13:23:11 +02:00
pyos 7ce5556de3 JVM_IR: try to fix SyntheticAccessorLowering.isAccessible again
The condition on the relationship between the current class and the type
of the receiver for protected members was the opposite of what the JVMS
says, and yet somehow mostly worked?

 #KT-48331 Fixed
 #KT-20542 Fixed
2021-09-03 15:54:16 +03:00
Dmitry Petrov b669de1663 JVM_IR generate range-based loop closer to Java counter loop
KT-48435 KT-48507
2021-09-03 10:38:20 +03:00
Ilmir Usmanov 1f8dd45c2b Remove experimental coroutines support. Part 2 2021-08-30 14:21:57 +03:00
Ilya Goncharov 0ca9e08c11 [JS IR] Add test with fail with vararg call in suspend
^KT-48344 fixed
2021-08-26 08:52:34 +00:00
Ilya Goncharov 4179d078ca [JS IR] Add test on call of suspend super type 2021-08-26 08:50:14 +00:00
Steven Schäfer 1b5214a2dc JVM: Fix usage of ClassBuilder API in AnonymousObjectTransformer 2021-08-23 18:25:33 +02:00
Dmitriy Novozhilov 27ac7dbf9a [Test] Unmute passing codegen tests 2021-08-23 14:29:12 +03:00
Ilmir Usmanov b5fa129540 Loosen tail-call optimization check for functions returning Unit
Do not check, that all Unit predecessors are POPs. This is safe for the
same reason, as it is safe to allow some of ARETURN sources not be
suspension point results.
To elaborate, before Unit, the stack is empty. This is because if there
are multiple paths to Unit and at least one of them comes from POP after
suspension point (we are interested in this case only - otherwise, the
call is not tail-call), in path from said POP the stack is empty, since
after suspension point the stack contains only one element. Thus, the
stack in other paths leading to Unit has to be empty, otherwise, merge
operation is not possible and ASM will report error during analysis.
Since the stack is empty in all paths, we can hoist Unit and following
ARETURN to predecessors, effectively turning path from suspension point
to tail-call.
2021-08-19 16:05:21 +00:00
Ilya Goncharov 766857881a [JS IR] Review remarks
- Use intrinsic on this
- Enqueue invoke for DCE
- Change transform
- Ignore instead of target backend

^KT-46204 fixed
2021-08-10 07:24:51 +00:00
Ilya Goncharov b6c3132614 [JS IR] Ignore test for legacy backend
^KT-46204 fixed
2021-08-10 07:24:49 +00:00
Ilya Goncharov 22d202e657 [JS IR] Add test on type check of suspend functional interfaces
^KT-46204 fixed
2021-08-10 07:24:47 +00:00
Ilya Goncharov 755f847ab9 [JS IR] Use invoke for coroutines in runtime
^KT-46204 fixed
2021-08-10 07:24:46 +00:00
Dmitry Petrov 8763235053 JVM specially hacked method analyzer for FixStack 2021-07-20 19:50:58 +03:00
Roman Artemev 09d30c91bf [JS TESTS] Disable mangler checker in tests 2021-07-01 17:40:41 +03:00
Ilmir Usmanov 435b522cc5 Minor. Unmute test 2021-06-23 11:18:25 +02:00
pyos 537ce05bc9 JVM_IR: assume function reference adapters are tail-call
Meaning, they never need continuation objects. This shouldn't affect
correctness (if the assumption is valid, the continuation object
should always have been removed in the end), but the phantom
continuation sometimes left behind unused accessors (and in case of
inline function references, those accessors would refer to non-existent
functions) - see the modified test and Kotlin/kotlinx.coroutines#2769.
2021-06-23 11:18:25 +02:00
pyos cf660cf24a JVM_IR: expect unboxed return value from suspend default stubs
#KT-47206 Fixed
2021-06-21 18:53:31 +03:00
pyos 0bd8d16fe2 JVM_IR: fix Result types in continuations & remove more codegen hacks
#KT-47129 Fixed
2021-06-07 09:57:42 +02:00
Steven Schäfer 984e912f8d JVM IR: Do not unbox Results in suspend lambda invoke methods (KT-46813) 2021-05-20 14:40:00 +02:00
Dmitriy Dolovov 896929cb21 [Native] Support suspend functions as supertypes
^KT-46777
2021-05-19 16:09:38 +03:00
Mads Ager d397efb2bd [JVM IR] Copy attributes for JVM_STATIC_WRAPPERS. 2021-05-11 16:26:04 +02:00
Ilmir Usmanov cb89bd0e13 Generate SuspendFunction marker interface if supertype is suspend
Otherwise, is/as checks will not work.
 #KT-18707
2021-04-29 17:11:31 +03:00
Ilmir Usmanov 0c0710bb79 Fix outer class accesses inside suspendImpl functions
We need to generate this$0 fields to get to the outer class and generate
accesses to these fields inside suspendImpl function.
 #KT-46214 Fixed
2021-04-27 10:44:18 +02:00
Ilmir Usmanov dc2485ae71 Support suspend functions as superinterfaces
Forbid mixing suspend and non-suspend functional supertypes.
Since JVM BE generates suspend functional types as non-suspend ones
with SuspendFunction marker interface, there is not way to distinguish
non-suspend functional type from suspend one if they are mixed.
 #KT-18707 Fixed
2021-04-26 22:14:32 +02:00
Mark Punzalan 9a4742c08d FIR: Properly build nullable suspend function types, and aggregate
modifiers and annotations within KtTypeReference/REFERENCE_TYPE nodes.
2021-04-26 15:11:38 +03:00
Ilmir Usmanov f7a9bc3521 Minor. Make test actually suspend and add a test without suspension 2021-04-23 03:50:08 +02:00
pyos 23ffbe4d9e JVM_IR: do not box inline classes in suspend multifile bridges 2021-04-23 03:49:47 +02:00
pyos 7d95943b8b JVM_IR: do not box inline classes in suspend synthetic accessors 2021-04-23 03:49:43 +02:00
Alexander Udalov 21e9bd7ea2 Add regression tests for obsolete issues
#KT-9304
 #KT-14961
 #KT-16549
 #KT-21080
 #KT-28234
 #KT-30102
 #KT-31994
 #KT-34291
 #KT-38099
 #KT-41174
 #KT-44622
 #KT-44701
 #KT-44781
 #KT-44849
 #KT-44978
 #KT-45081
 #KT-45286
 #KT-45383
 #KT-45444
 #KT-45907
2021-04-20 21:24:29 +02:00
Ilmir Usmanov 1c48fb28db Generate return when generating continuation class for expression body
Otherwise, the function will return Unit instead of correct value.
 #KT-46007 Fixed
2021-04-15 13:54:45 +03:00
Ilmir Usmanov 29c975fc43 Minor. Add regression test
#KT-45539 Obsolete
2021-04-14 10:48:57 +02:00
Steven Schäfer 7a9ff15d73 JVM IR: Handle suspend interface default methods with generic types (KT-45166) 2021-04-13 23:04:32 +02:00
Mads Ager b27a109a1e [JVM] Fix shrinking of local range for dead variables.
Coroutine transform would occasionally *extend* the range of a
local instead of shrinking it (if the next suspension point
is after the end point for the local). That leads to the local
variable table having a local that covers code where it is not
defined. That is invalid and leads to D8 removing the locals
table from the code.
2021-04-09 19:06:13 +03:00
Ilmir Usmanov 786999bcfe Minor. Add regression tests
#KT-44143
2021-04-01 00:51:08 +03:00
Ilya Goncharov 47f1a8a0bb [IR] Make IrTypeOperatorCall copyable
^KT-45655 fixed
2021-03-31 20:14:52 +03:00
Ilmir Usmanov 5e6f52009f JVM IR: IC coroutines: return boxed type from suspend function if
the function overrides function, returning type argument
 #KT-45451 Fixed
2021-03-25 16:21:55 +01:00
Dmitry Petrov 4f250ed498 JVM_IR KT-45377 rewrite constants again after AddContinuationLowering 2021-03-23 16:05:24 +03:00