Denis Zharkov
37b364a70a
Fix processing of uninitialized instances for coroutines
...
The problem is that code in the attached test led to VerifyError at runtime
because the Bar's uninitialized instance created in 'map' was being stored
to the field (leaked from the JVM point of view).
The actual problem was that after repeating visiting of NEW operation
we used to drop the set of already visited copy usages.
For clarification see the comment before 'processUninitializedStores'
#KT-15016 Fixed
2017-01-18 12:00:46 +03:00
Denis Zharkov
630fab1952
Fix signature of accessor for suspend function
...
It must be a suspend function too to have an additional Continuation parameter
#KT-15715 Fixed
2017-01-18 12:00:45 +03:00
Denis Zharkov
d0d617b44e
Fix signature mapping for default suspend function from interface
...
Use jvm suspend function view in function codegen.
Also use SUSPEND_FUNCTION_TO_JVM_VIEW slice if the value exists
for the given key
#KT-15552 Fixed
2017-01-18 12:00:45 +03:00
Denis Zharkov
fae9cc1c63
Fix codegen issue of safe-qualified suspension points
...
#KT-15527 Fixed
2017-01-18 12:00:44 +03:00
Roman Elizarov
25739a08ea
CoroutineContext Key and Element are now inside CoroutineContext interface itself (just like Map.Entry)
...
ContinuationInterceptor companion object is named Key
CoroutineContext.Element property for key is named just key
AbstractCoroutineContextElement implements all of CoroutineContext.Element, including key
2017-01-16 14:33:02 +03:00
Denis Zharkov
14f942aca7
Refine ABI for coroutine lambdas
...
Make their invoke work in the same way as any other suspend function:
it should return SUSPENDED_MARKER iff. it indeed became suspended
2017-01-14 19:51:05 +03:00
Denis Zharkov
6a1ad3a279
Get rid of unnecessary additional declarations in tests
2017-01-14 13:24:53 +03:00
Roman Elizarov
8d6a913cee
CoroutineContext and ContinuationInterceptor (instead of dispatcher)
2017-01-14 13:24:53 +03:00
Denis Zharkov
f56d9cfb26
Ignore failing coroutine related tests on JS
2017-01-14 13:24:53 +03:00
Denis Zharkov
c479aa7d65
JS: simplify how suspend functions inlined
2017-01-14 13:24:53 +03:00
Denis Zharkov
2286027bed
Fix verify error with 'return when/if/try' in suspend function
...
The problem appears for tail-optimized suspend functions,
we erroneously assumed that when/if/try expressions in tail-call
position have simple types like `I` while actually, they can return SUSPENDED
object, i.e. must have `java/lang/Object` as return type.
But this only concerns branching operations in tail-call position,
so we have to make an additional analysis for remembering whether
a given expression is in a tail-call position.
Also, it's important here that we now assume
the return type of the current function as `java/lang/Object`
that is necessary to avoid wrong checkcasts.
#KT-15364 Fixed
2017-01-14 13:24:53 +03:00
Denis Zharkov
695b6d9e67
Minor. Add test on local vars of suspend function type
2017-01-14 13:24:53 +03:00
Denis Zharkov
7837d736f7
Merge RestrictedCoroutineImpl into CoroutineImpl
2017-01-14 13:24:53 +03:00
Denis Zharkov
d487c1ef0f
Refine dispatching convention
...
Dispatching happens only via `suspendWithCurrentContinuation` calls
instead of each `resume` call
#KT-15657 Fixed
2017-01-14 13:24:53 +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
Alexey Andreev
a016147a79
JS: fix translation of return statement surrounded by try..finally block in suspend lambda. See KT-15625
2017-01-12 18:12:39 +03:00
Alexey Andreev
1af01d0ecb
JS: make call to suspend lambda to resume it immediately. See KT-15379
2016-12-29 16:00:35 +03:00
Alexey Andreev
11ce184d8e
JS: add suspendCoroutine function
2016-12-26 12:45:14 +03:00
Alexey Andreev
1ab78dffe5
JS: fix translation of for statement when either next or hasNext method translates to multiple statements. Fix KT-15367
2016-12-22 17:19:24 +03:00
Alexey Andreev
cef32b3327
JS: initialize fields of coroutine state machine with undefined value so that they match local variable semantics. Fix KT-15366
2016-12-22 17:19:23 +03:00
Denis Zharkov
8475869fb3
Support common calls on suspend function typed values
...
Also support multiple value parameters in suspend function type
#KT-15379 Fixed
#KT-15380 Fixed
2016-12-22 11:15:52 +03:00
Denis Zharkov
a1ac77d382
Support async iterator case with coroutines
...
Not all the `hasNext` operators return types is exactly Z,
suspend operators return boxed versions.
So the fix is just coercing result value after invoked function to Z
2016-12-19 11:07:33 +03:00
Denis Zharkov
5dbc04abbb
Refine returns codegen for suspend functions
...
This change should make the logic a bit more simple.
For all suspend functions/coroutines treat them in expression codegen
like they return boxed version of the original type.
Everything works fine then, except Unit type functions:
their bodies must be generated just like they're VOID and then load
Unit on stack manually.
2016-12-19 11:07:32 +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
Alexey Andreev
e2d969d8b0
JS: implement new coroutine convention
2016-12-15 23:58:20 +03:00
Dmitry Petrov
9fd1ac72a9
Purge remaining traces of @AllowSuspendExtensions.
2016-12-15 23:58:19 +03:00
Denis Zharkov
8387d04425
Revert "Add special tests for interceptRun support"
...
This reverts commit 01c21e218a .
2016-12-15 23:57:59 +03:00
Stanislav Erokhin
e014fb7181
Added coroutine import to back-end test.
2016-12-15 23:57:52 +03:00
Stanislav Erokhin
7d1b883171
Replace @Suspend to suspend in box tests.
2016-12-15 23:57:50 +03:00
Denis Zharkov
6649f64e9f
Support new coroutine convention in JVM backend
2016-12-15 23:57:40 +03:00
Alexey Andreev
cf25e17209
JS: add tests that emulates promises and wraps them in coroutines, using suspend functions outside of controller
2016-12-09 14:56:21 +03:00
Alexey Andreev
060f08a8dd
JS: add support of interceptResume function in coroutine controller
2016-12-09 14:56:20 +03:00
Alexey Andreev
9eff193ea4
JS: support stack unwinding convention in coroutines
2016-12-09 14:56:20 +03:00
Alexey Andreev
bf74400776
JS: re-enable coroutine tests for JS backend
2016-12-09 14:56:19 +03:00
Denis Zharkov
b8e1ce7a05
Report error on non-tail suspend-calls
...
It only concerns calls inside another suspend function
#KT-14924 In Progress
2016-12-01 10:11:37 +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
27e4caf046
Temporary disable coroutine tests in JS 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
Alexey Andreev
23428c9544
JS: fix coroutine test. Fix hanging IDEA tests
2016-11-23 17:01:03 +03:00
Alexey Andreev
40e00a62f5
JS: fix translation of augmented assignment when RHS changes value of LHS
2016-11-23 12:19:03 +03:00
Alexey Andreev
dc8e90809c
JS: coroutines: fix handling of throw statement inside try/catch block when controller has handleSuspend function
2016-11-23 12:19:02 +03:00
Alexey Andreev
e44edf12e0
JS: coroutines: fix inlining of suspend functions
2016-11-23 12:13:54 +03:00
Denis Zharkov
01c21e218a
Add special tests for interceptRun support
...
Basically they're built upon basic coroutine tests, but for each of them
different interceptResume implementation are injected
(currently there are 12 of them).
It might be more simple just to generated additional testData, but I see this
more problematic in a sense of further maintenance
Note that all tests add idempotent 'interceptRun' operators,
which just execute given lambda in the current thread
#KT-14891 Fixed
2016-11-22 14:33:40 +03:00
Ilya Gorbunov
38840bb529
Do not reference java.util in tests that run on JS backend.
2016-11-21 18:20:33 +03:00
Alexey Andreev
e2dc7ba37e
JS: coroutines: fixes after code review
2016-11-16 19:29:39 +03:00
Alexey Andreev
d41d09ffc4
JS: add metadata for generated continuation classes to properly implement RTTI
2016-11-16 19:29:37 +03:00
Alexey Andreev
2d315c3df8
JS: coroutines: fix translation of try/finally block without catch
2016-11-16 19:29:35 +03:00
Alexey Andreev
22aea1cf12
JS: fix translation of return statement surrounded by finally block. Temporarily suppress corresponding test case for JVM backend
2016-11-16 19:29:34 +03:00
Alexey Andreev
eae0ceed86
JS: add coroutines tests
2016-11-16 19:29:34 +03:00