Commit Graph

102 Commits

Author SHA1 Message Date
Ilmir Usmanov
2cfe387bab Move coroutines to kotlin.coroutines package: compiler
Generate continuation type as kotlin.coroutines.Continuaion. This code will
fail at runtime since there is no stdlib backing this change yet.
However, in order to generate compatible stdlib we need a compiler, which
generates continuation type as kotlin.coroutines.Continuation.
Thus, firstly we support the change in the compiler, make it bootstrap
compiler and only then change stdlib and tests accordingly.
 #KT-23362
2018-04-10 22:51:46 +03:00
Ilmir Usmanov
eb3b9032d6 Add synthetic flag to generated private suspend functions
Private suspend functions need to be generated as package-local, since
they are called from their continuations.
However, this means that they can be called from Java, which breaks
their private visibility.
Adding synthetic to them fixes the issue.
 #KT-17584: Fixed
2018-04-10 17:25:12 +03:00
Ilmir Usmanov
eb81c205c7 Replace CHECKCAST kotlin/Unit with ARETURN for tail call optimization
Sometimes instead of {POP, GETSTATIC Unit.INSTANCE, ARETURN} sequence
the codegen emits {CHECKCAST Unit, ARETURN} sequence, which breaks tail
call optimization. By replacing CHECKCAST with ARETURN we eliminate
this issue.

 #KT-19790: Fixed
2018-04-03 20:04:18 +03:00
Ilmir Usmanov
bd7ad8c9d5 Raise deprecation level to ERROR of coroutineContext
inside kotlin.coroutines.experimental.intrinsics package
 #KT-22400
2018-03-22 22:12:27 +03:00
Ilmir Usmanov
07ec704228 Fix modifiers generation for companion objects
when language verion is 1.3

 #KT-23002: Fixed
2018-03-01 20:03:26 +03:00
Mikhail Zarechenskiy
30c79ffadc Support generating computable properties inside inline classes 2018-02-09 04:57:20 +03:00
Mikhail Zarechenskiy
70cd1cfcdf Fix generation of companion object inside inline classes 2018-02-09 04:56:45 +03:00
Mikhail Zarechenskiy
e1d3b21201 Skip bridge methods generation for inline classes 2018-02-09 04:56:43 +03:00
Mikhail Zarechenskiy
1ac4e9755a Generate synthetic unbox method for each wrapper of inline class 2018-02-09 02:08:11 +03:00
Mikhail Zarechenskiy
a59917b6f8 Generate synthetic box method for each erased inline class 2018-02-09 02:08:10 +03:00
Mikhail Zarechenskiy
9d05fac771 Don't generate backing field for erased inline class 2018-02-09 02:08:09 +03:00
Mikhael Bogdanov
0954d1ab1b Don't generate hash in sam wrapper class name
#KT-17091 Fixed
2018-02-08 10:11:48 +01:00
Ilmir Usmanov
18c03f94f8 Move coroutineContext to correct package
from kotlin.coroutines.experimental.instrinsics to kotlin.coroutines.experimental

 #KT-22400
2018-02-01 13:18:32 +03:00
Ilmir Usmanov
f4ad5182b8 Fix OOM error in ReturnUnitMethodTransformer
#KT-22345: Fixed
2018-01-19 20:13:23 +03:00
Ilmir Usmanov
ed11528664 Ignore unreachable code on tail call optimization
#KT-21759: Fixed
2018-01-15 12:57:10 +03:00
Ilmir Usmanov
32a94c70e9 Use tail call optimization if ARETURN has multiple sources
#KT-21977: Fixed
2018-01-10 20:14:32 +03:00
Ilmir Usmanov
5dbab2f907 Disable tail call optimization, if the call is inside try block
#KT-21165: Fixed
2018-01-10 20:13:55 +03:00
Alexander Udalov
f3f8db989a Fix test data for annotations on DefaultImpls members
After ea5505f80c, the annotations are now generated correctly
2017-12-27 14:12:14 +01:00
Ilmir Usmanov
c8904b1c7c Replace POP with ARETURN if it pops Unit and ARETURN shall return Unit
#KT-16880: Fixed
2017-12-21 18:08:39 +03:00
Dmitry Petrov
f586bd4a34 Generate proper visibility for companion object instance field in LV1.3+ 2017-11-27 17:15:16 +03:00
Ilmir Usmanov
0f9a21d429 Add regression test for KT-17640 2017-11-10 19:16:06 +03:00
Ilmir Usmanov
817f79520a Implement coroutineContext intrinsic
This intrinsic allows coroutine to access its context without suspention
and, furthermore, disabling tail-call optimization.
KT-17609: Fixed
2017-11-02 12:45:24 +03:00
Dmitry Petrov
891799c853 Generate 'Deprecated' annotation on invisible companion object field
Design decision: if the field for a companion object should have
non-public visibility, generate it with @Deprecated annotation in
language version 1.2.

TODO: generate it with proper visibility in 1.3 and later.

KT-11567 Companion object INSTANCE field more visible than companion object class itself
2017-07-19 17:38:17 +03:00
Dmitry Petrov
17d2472511 Do not patch generic signature for methods with special bridges
Somewhat awkward solution for KT-18189.
2017-05-31 10:18:48 +03:00
Dmitry Petrov
fd00a6fbe8 Generate generic signatures for special bridges
#KT-12408 Fixed Target versions 1.1.4
2017-05-31 10:18:48 +03:00
Dmitry Petrov
48a60e6f39 Dump generic signatures in bytecode listing tests if required
Add '// WITH_SIGNATURES' to test file if generic signatures should be
dumped.
2017-05-31 10:18:48 +03:00
Denis Zharkov
49453ca705 Avoid dependency on coroutine-related public API changes
These changes has been introduced in c3a032ea0b
to support new scheme for named functions

At the same time they can be avoided by generating some additional
code/accessors in the anonymous classes for coroutine state

Now we cannot simply remove introduced API because of bootstrap problems

 #KT-17898 Fixed
2017-05-18 12:42:12 +03:00
Denis Zharkov
5b5f612a7c Support new strategy for suspend inline functions
The main idea is to leave all the inline functions as is, without
state machines (but keeping suspend-calls markers) and
determine whether we need a state machine from the bytecode
after inlining into a non-inline function

 #KT-17585 In Progress
 #KT-16603 In Progress
 #KT-16448 Fixed
2017-05-05 14:14:00 +03:00
Mikhael Bogdanov
d24ebf711b Fix for KT-16441: NoSuchFieldError: $$delegatedProperties when delegating through provideDelegate in companion object
#KT-16441 Fixed
2017-02-21 13:01:40 +01:00
Alexander Udalov
0db60bf6cb Do not always generate synthetic "$annotations" as private
Since annotations are a part of the declaration, they must have the same
visibility as the declaration in the bytecode. Otherwise obfuscators like
Proguard might strip the "$annotations" method and no annotations would be
found via Kotlin reflection

 #KT-15993 Fixed
2017-02-03 19:35:15 +03:00
Denis Zharkov
8fa8ba7055 Move coroutine-related runtime parts to kotlin.coroutines.experimental package
#KT-15975 Fixed
2017-01-27 23:24:13 +03:00
Mikhael Bogdanov
456037a30d Generate proper annotaions on parameters for @JvmOverloads;
Fix for KT-15743: Overloaded Kotlin extensions annotates wrong parameters in java

 #KT-15743 Fixed
2017-01-27 14:09:13 +01:00
Denis Zharkov
9f217de10b Write kotlin metadata on class-files for coroutine state machines
Otherwise it breaks JPS assumptions, that leads to exceptions like:
Error:Kotlin: [Internal Error] java.lang.AssertionError: Couldn't load KotlinClass from /Users/jetbrains/IdeaProjects/KotlinPlaygroundBeta11/out/production/KotlinPlaygroundBeta11/Counter$both$1.class; it may happen because class doesn't have valid Kotlin annotations
    at org.jetbrains.kotlin.build.GeneratedJvmClass.<init>(generatedFiles.kt:36)
    at org.jetbrains.kotlin.jps.build.KotlinBuilder.getGeneratedFiles(KotlinBuilder.kt:469)
    at org.jetbrains.kotlin.jps.build.KotlinBuilder.doBuild(KotlinBuilder.kt:241)
    at org.jetbrains.kotlin.jps.build.KotlinBuilder.build(KotlinBuilder.kt:140)
...
2017-01-16 17:53:15 +03:00
Denis Zharkov
0240ab0738 Support non-tail suspend calls in JVM back-end
#KT-15597 In Progress
2017-01-14 13:24:53 +03:00
Denis Zharkov
2cb9d3a8ad Move coroutine intrinsics to kotlin.coroutine.intrinsics package
Also rename val SUSPENDED to SUSPENDED_MARKER

 #KT-15698 Fixed
2017-01-14 13:24:53 +03:00
Mikhael Bogdanov
dc4cdbf82d Fix for KT-14162: Support @InlineOnly on inline properties
#KT-14162 Fixed
2017-01-10 14:09:41 +01:00
Denis Zharkov
d0ba048342 Refine coroutine/suspend functions ABI
- `invoke` method must always start a suspend functions
- For creation of coroutine that has not been started yet, there are
two special internal interfaces `SuspendFunction0`/`SuspendFunction1`
2016-12-22 11:08:42 +03:00
Denis Zharkov
01ff975cc0 Minor. Update tests on coroutines 2016-12-16 13:27:11 +03:00
Stanislav Erokhin
b527a4d158 Global rename in test data for coroutines
(cherry picked from commit 132f97b)
2016-12-15 23:58:26 +03:00
Denis Zharkov
845e116aa9 Update bytecodeText and bytecodeListing tests on coroutines 2016-12-15 23:58:00 +03:00
Yan Zhulanow
e31a39386e Minor: Fix testDeprecatedJvmOverloads test (Kotlin runtime is not enabled by default now in bytecode listing tests) 2016-12-05 19:58:06 +03:00
Yan Zhulanow
328286ab14 Use box tests to check if the light analysis mode (without analyzing bodies when possible) produces the same result as the complete analysis. See also the next commit in which light analysis mode is applied. Note that no tests were changed. 2016-12-05 19:57:47 +03:00
Denis Zharkov
fcd9ee037e Support coroutines stack-unwinding in JVM backend
#KT-14924 In Progress
2016-11-29 14:14:50 +03:00
Denis Zharkov
1f98accad2 Support new suspend convention in JVM backend partially
Stack-unwinding does not work yet

 #KT-14924 In Progress
2016-11-29 14:14:50 +03:00
Dmitry Petrov
3dd0c9d1c7 Equality comparison for bound callable references takes into account bound receiver.
Fixed KT-14939: use expected receiver type when generating receiver code in get/set methods for bound property references.
Otherwise we have VerifyError for bound receiver 'null' of type 'Nothing?', which is mapped to 'java.lang.Void'.

TODO: proper equality comparison for property accessors ('x::prop.getter', 'x::prop.setter').
2016-11-25 14:49:24 +03:00
Dmitry Jemerov
a57748f4f4 @JvmOverloads-generated overloads of final methods are also final; test to verify that overloads of deprecated methods are deprecated 2016-11-18 11:05:03 +01:00
Denis Zharkov
bd5c08f598 Make fields for storing lambda parameters non-final
Because they get assigned within `invoke` call that contradicts with JVM spec
where it's told that they must not be assigned outside of constructors
2016-11-09 12:25:31 +03:00
Denis Zharkov
e54b466010 Make fields representing variables in coroutines non-volatile
#KT-14636 Fixed
2016-11-09 12:25:31 +03:00
Denis Zharkov
dfb9b323ff Avoid generation of redundant abstract special stubs
#KT-13698 Fixed
2016-10-07 11:59:15 +03:00
Denis Zharkov
6e838f0adc Avoid generation of redundant toArray stubs
#KT-13698 In Progress
2016-10-07 11:59:15 +03:00