Commit Graph

911 Commits

Author SHA1 Message Date
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
Mikhael Bogdanov b88a9025e0 Don't check DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE when compiling to 1.0 2017-01-13 18:01:05 +01:00
Ilya Gorbunov cdfb72ab76 Provide protected toArray implementation in AbstractCollection.
Relates to #KT-13898
2017-01-13 19:38:28 +03:00
Dmitry Petrov ba933fa887 KT-15112, KT-15631
Revert changes for "tolerant to uninitialized values" in OptimizationBasicInterpreter:
this approach doesn't converge for some specific cases where local variable is reused
(e.g., in several inlined functions - see https://youtrack.jetbrains.com/issue/KT-15112).

Instead, treat fake always-false conditional jump in the beginning of the post-condition loop as a "reference point" for stack on loop break / continue.
This requires an extra abstraction layer in FixStackAnalyzer, since we can't perform fine-grain manipulations on Frames
(such as "combine frame C from local variables of frame A and stack of frame B").

NB additional NOPs will be generated for post-condition loops.
Should make a separate bytecode postprocessing pass to get rid of unnecessary NOPs
(several YT issues for perceived quality of the generated bytecode are about such NOPs).
2017-01-13 10:31:07 +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 10a3fbf53f JS: disable TemporaryAssignmentElimination, fix KT-15512 2017-01-12 18:12:39 +03:00
Alexey Andreev 4eed7c1fcb JS: fix translation of augmented assignment in class initializer. See KT-15569 2017-01-12 18:12:38 +03:00
Alexey Andreev ee74342fbe JS: fix compiler crash when optimizing JS AST with empty do..while statement. See KT-15513 2017-01-12 18:12:37 +03:00
Alexey Andreev bad6f41d6e JS: make some JVM tests compatible with JS BE 2017-01-12 18:12:37 +03:00
Alexey Andreev 70176dfacc JS: translate call arguments in the order the occur in source code, not in order of parameters in descriptor. See KT-15506 2017-01-12 18:12:36 +03:00
Alexey Andreev e6b78f68cd JS: support case when class inherits method from superclass and both implements same method (but with optional parameter) from superinterface. 2017-01-12 18:12:36 +03:00
Mikhael Bogdanov 2931c316a3 Fix for KT-15575: VerifyError: Bad type on operand stack
#KT-15575 Fixed
2017-01-11 11:50:33 +01:00
Mikhael Bogdanov 043f3199c7 Fix for KT-15446: Property reference on an instance of subclass causes java.lang.VerifyError
#KT-15446 Fixed
2017-01-10 14:09:42 +01:00
Alexander Udalov 32d2faf3d1 Fix KAnnotatedElement.findAnnotation when no annotation is found
#KT-15540 Fixed
2017-01-10 12:23:26 +03:00
Mikhail Zarechenskiy cff0865c87 Fix error type for implicit invoke with function literal argument
#KT-11401 Fixed
2017-01-10 11:44:51 +03:00
Alexey Andreev 069711c3d5 JS: fix translation of float constants. See KT-8413 2016-12-30 16:22:07 +03:00
Mikhael Bogdanov e775cc697e Fix for KT-15447: Compiler backend error: "Don't know how to generate outer expression for class"
#KT-15447 Fixed
2016-12-29 16:57:03 +01:00
Alexey Andreev 07de819377 Regenerate tests and test data 2016-12-29 16:15:49 +03:00
Alexey Andreev 175d37fdc8 JS: add test to prove that KT-13523 is no more reproducible 2016-12-29 16:00:54 +03:00
Alexey Andreev 27c2a4f6a8 JS: disable mangling for PublishedApi. Export declarations marked with PublishedApi. See KT-15442 2016-12-29 16:00:51 +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 84f094c770 JS: prohibit to implement functional interfaces. See KT-15136 2016-12-29 16:00:29 +03:00
Ilya Gorbunov 0a840d0174 Migrate 1.1 reflection API usages in tests. 2016-12-29 06:51:01 +03:00
Alexander Udalov b4051c4577 Do not generate unnecessary super-call checks for functions with defaults
Such check should only be generated for a function in an open class

 #KT-11962 Fixed
2016-12-27 16:22:12 +03:00
Mikhael Bogdanov 4c9bac084c Fix for KT-15437: VerifyError: Bad local variable type on simplest provideDelegate
#KT-15437 Fixed
2016-12-27 14:07:37 +01:00
Mikhael Bogdanov f1c1fcf0fc Fix for KT-11969: ProGuard issue with private interface methods
#KT-11969 Fixed
2016-12-27 14:07:37 +01:00
Alexander Udalov f8a88bdffb Fix "Rewrite at slice LEXICAL_SCOPE" for callable references
For special calls (when-expressions, if-expressions, etc.), do not attempt to
get type of the argument expression, which is the block with the callable
reference, instead get type of the callable reference itself. The difference
matters because for block expressions, a new lexical scope is created for each
getTypeInfo (see ExpressionTypingServices.getBlockReturnedType), and we do not
support rewrites of this value in the binding trace

 #KT-12044 Fixed
2016-12-27 10:45:46 +03:00
Mikhail Zarechenskiy 38a2518498 Fix computation of erased receiver for intersection types
#KT-9630 Fixed
2016-12-26 22:34:40 +03:00
Ilya Gorbunov 85232ffa07 Drop deprecated pre-1.0 API. Remove remaining usages in tests. 2016-12-26 19:07:20 +03:00
Alexey Andreev 11ce184d8e JS: add suspendCoroutine function 2016-12-26 12:45:14 +03:00
Alexey Andreev 1ecd957981 JS: fix translation of delegated constructor call from secondary constructor when argument is a complex expression which translates to multiple statements. See KT-15357 2016-12-22 17:19:24 +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
Mikhael Bogdanov ef825a7559 Fix for KT-14868: CCE in runtime while converting Number to Char
#KT-14868 Fixed
2016-12-22 09:44:24 +01: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