Commit Graph

229 Commits

Author SHA1 Message Date
Dmitry Petrov db13ab59a6 Test: SuccessOrFailure calls don't generate erased class references 2018-09-05 12:20:57 +03:00
Dmitry Petrov 203fd6a5d6 Make inline class wrapper constructor synthetic 2018-09-05 12:20:57 +03:00
Dmitry Petrov 65881dda97 Fix tests after rebase 2018-09-05 12:20:57 +03:00
Dmitry Petrov 1bf8cfca8b Test: property accessors are called by inline class 2018-09-05 12:20:57 +03:00
Dmitry Petrov a2900282fd Call factory method for primary constructors of inner classes
We might want to add 'init' blocks later, so now, for the sake of
binary compatibility with 1.3-RC binaries, we have to generate these
'constructor' calls.

Note that in some tests inline class boxing is no longer redundant,
because resulting value is passed to 'constructor' as an argument.
2018-09-05 12:20:57 +03:00
Dmitry Petrov b1016936b2 'box'/'unbox' methods are called by inline class 2018-09-05 12:20:57 +03:00
Dmitry Petrov 687b492bf9 Test: inline class secondary constructors are called by inline class 2018-09-05 12:20:57 +03:00
Dmitry Petrov 80a67477db Generate method calls for inline classes through IC, not IC$Erased
IC extends IC$Erased, so it should be fine.
2018-09-05 12:20:57 +03:00
Dmitry Petrov 3080b65f7d Inline (wrapper) class IC extends erased inline class IC$Erased 2018-09-05 12:20:57 +03:00
Dmitry Petrov 583c66a2a7 Don't mangle synthesized 'box' function for inline classes 2018-08-30 16:21:30 +03:00
Dmitry Petrov a56d1d3ce8 Mangle function names with inline class parameters
Avoid name clashes in cases such as

  inline class Login(val login: String)
  inline class Password(val password: String)

  fun validate(login: Login) { ... }
  fun validate(password: Password) { ... }
2018-08-30 14:58:50 +03:00
Ilmir Usmanov 300876348a Fix line numbers generation for coerced primitives
in coroutines
 #KT-25076: Fixed
2018-08-15 13:47:45 +03:00
Ilmir Usmanov 82f64b9b14 Generate LVT entry for continuation
#KT-25688: Fixed
2018-07-26 16:12:54 +03:00
Mikhail Zarechenskiy 9aa4247065 Do not box primitives in a single-entry string template expression 2018-07-20 13:46:11 +03:00
Ilmir Usmanov 0ed5ec868c Generate probeCoroutineSuspended call in suspendCoroutineUninterceptedOrReturn
#KT-25508: Fixed
2018-07-19 14:24:09 +03:00
Dmitry Petrov 82f22f92ca Don't generate ConstantValue for non-const vals in Kotlin 1.3+ 2018-07-18 15:02:54 +03:00
Denis Zharkov 820506d9c6 Fix tests after new Continuation API support
#KT-24863 Fixed
2018-07-09 15:27:19 +03:00
Mikhail Zarechenskiy 4f490ac264 Fix generation of checkcast instructions for inline classes
Normalize LHS and RHS types to use only boxed ones and then let bytecode
 optmizer reduce redundant boxing
2018-07-05 12:55:39 +03:00
Roman Artemev c887b88ed9 Fix coroutine test generator 2018-07-02 15:35:02 +03:00
Mikhail Zarechenskiy ba6da7c40a Support varargs of inline class types with non-trivial spread
#KT-24880 In Progress
2018-06-25 17:15:50 +03:00
Dmitry Petrov d35a92a81d Generate accessor for private companion object 2018-06-22 16:53:07 +03:00
Dmitry Petrov a4b5d74ae3 Generate debug information for 'when' subject variable
NB debugger tests currently don't support language version or individual
language feature settings.
2018-06-20 14:06:34 +03:00
Alexander Udalov 863639c9ab Revert changes to data class equals/hashCode (KT-12330)
This looked like a small and useful change, but caused so many issues
(KT-24474, KT-24790, 30b9caea, and another unreported one -- see the
test update in this commit) that it didn't pay off after all. The
optimization is not that critical for now, as it's only relevant for
data classes where component types have trivial equals/hashCode
implementation, which is not very often

 #KT-12330 Declined
2018-06-19 12:05:55 +02:00
Mikhail Zarechenskiy 01d9be65bc Perform bytecode optimisations for inline classes
#KT-23742 Fixed
2018-06-18 11:52:36 +03:00
Mikhail Zarechenskiy 656f6cbded Support constant evaluation of unsigned type constructors
#KT-23816 In Progress
2018-06-04 18:37:34 +03:00
Mikhail Zarechenskiy b25a1d9522 Support inline functions inside inline classes 2018-05-07 15:25:46 +03:00
Mikhail Zarechenskiy 5c57c799fc Fix generation of elvis with null constant for inline classes 2018-05-07 15:25:45 +03:00
Ilmir Usmanov f507a26a12 Generate decomposed lambda params in suspend lambda's local variables
Unlike ordinary lambdas, suspend lambdas do the computation in
doResume(Ljava/lang/Object;Ljava/lang/Throwable;)Ljava/lang/Object;
method. As you can see, there are no decomposed parameters. As a result,
they used not to be generated.
To fix the issue, I add decomposed parameters to value parameters while
generating local variables table.

In addition, when generating suspend lambda for inline, the codegen
does not take this kind of parameters into account. This is also fixed.

 #KT-18576: Fixed
2018-05-03 10:35:13 +03:00
Alexander Udalov ac4edbba5b Regenerate tests 2018-05-02 16:17:14 +02:00
Denis Vnukov c5373c9029 Ensure deterministic insertion of checkExpressionValueIsNotNull.
Kotlinc source’s file DescriptorUtils.kt demonstarted non-deterministic
insertion of checkExpressionValueIsNotNull for value returned by
CallableDescriptor::getOriginal(). It was difficult to reproduce
this behavior on ф smaller example, but I added a test which was
failing once in 5-10 times while I was testing manually.

I believe this bug is close to KT-23704.

This PR addresses non-determinism to a degree when I can run 120
Compilations with './gradlew dist' and get same classes in all
jars in 'dist'.

NOTE that thew fact that insertion of checkExpressionValueIsNotNull may
depend on order of the types seems suspicios. This CL only addresses
non-determinism part, but I believe it’s worth looking into this more
from semantics point of view.
2018-05-02 14:36:04 +02:00
Ilmir Usmanov f60787d57c Move coroutines to kotlin.coroutines package: tests
Introduce COMMON_COROUTINES_TEST directive.
Every test with this directive is run twice: one time with
language version 1.2 and kotlin.coroutines.experimental package
and the other time with language version 1.3 and kotlin.coroutines
package. Each run is a separate method: with suffixes _1_2 and _1_3
respectively.
However, since codegen of release coroutines is not supported in JS
backend, we generate only one method: with suffix _1_2.
 #KT-23362
2018-04-23 21:51:59 +03:00
Dmitry Petrov 1eca402332 Use correctElementType to determine array element type for withIndex
Rather unkind "gotcha" in ASM API.

 #KT-23900 Fixed Target versions 1.2.50
2018-04-23 18:00:12 +03:00
Dmitry Petrov 54cf11fd0a Skip empty string entries when generating string template expression
#KT-19738 Fixed Target versions 1.2.50
2018-04-20 14:52:14 +03:00
Zalim Bashorov ab03ab84bb Regenerate tests 2018-04-19 13:17:27 +03:00
Mikaël Peltier 0a11385006 KT-12330 Improve bytecode for data class equals/hashCode methods
- Do not longer call hashCode on java/lang/Object but do this
on statically checked type.
- Do not longer call Intrinsics.areEqual but use directly
equals method on statically checked type.

Fix of https://youtrack.jetbrains.com/issue/KT-12330
2018-04-09 14:16:02 +02:00
Mikaël Peltier 3a50d0d78f KT-22063 Add intrinsics for javaObjectType and javaPrimitiveType
Fix of https://youtrack.jetbrains.com/issue/KT-22063
2018-03-26 15:52:19 +02:00
Ilmir Usmanov e6a353e590 Remove returns unit markers in suspend lambdas 2018-03-16 16:26:09 +03:00
Mikaël Peltier d0ed0c4049 KT-14258 Optimize accesses to properties defined into companion
- Use direct access to property defined into companion object when
it is possible rather than always use an accessor to access the
property.
- Use direct access will speedup runtime performance.
- Avoid to generate useless accessors for companion properties.

Fix of https://youtrack.jetbrains.com/issue/KT-14258
2018-03-14 15:30:40 +01:00
Zalim Bashorov 9970dd051f Fix copyright's start year in generated tests 2018-03-14 15:04:58 +03:00
Mikhail Zarechenskiy f23b5103ec Avoid non-null assertions for inline classes based on nullable types
Note that there are more places where assertions for inline classes should refined:
  - lateinit vars
  - values that come from Java
  - type casts (interfaces to inline class type)
2018-02-20 14:41:48 +03:00
Mikhail Zarechenskiy 413e2d7fa1 Fix KotlinType of constructor call for inline classes 2018-02-20 11:58:18 +03:00
Mikhail Zarechenskiy 530dd01ca6 Fix unboxing values of inline class type from type parameters 2018-02-20 11:45:49 +03:00
Mikhael Bogdanov d732f0e160 Never delete types from inline functions during inline transformations
#KT-19399 Fixed
2018-02-16 16:48:53 +01:00
Mikaël Peltier 9fb0f59813 KT-17110 Rewrite branches targeting other branches
- Rewrite branches targeting other branches to target directly the
final destination to avoid runtime performance penalties.

Fix of https://youtrack.jetbrains.com/issue/KT-17110
2018-02-16 15:15:52 +03:00
Mikaël Peltier 8676ca34d7 KT-22334 Specialized loops using range such as integer..array.size-1
- Into PrimitiveNumberRangeLiteralRangeValue modifies how bounded
value are created by checking if the high bound range can be modified
to be exclusive instead of inclusive such as the generated code will
be optimized.
- Add black box tests checking that the specialization does not fail
on any kind of arrays.
- Add a bytecode test checking that the code is correctly optimized.

Fix of https://youtrack.jetbrains.com/issue/KT-22334
2018-02-15 12:41:33 +03:00
Mikhail Zarechenskiy e017e9cb5f Support passing inline class values with spread operator 2018-02-13 13:16:45 +03:00
Mikhail Zarechenskiy 3919dc94e1 Box values of inline class types when passing to function as varargs 2018-02-13 13:16:44 +03:00
Mikhail Zarechenskiy 6687751cf5 Generate as check for inline classes using wrapper
Should be improved when inline class is based on non-null reference
2018-02-13 13:16:44 +03:00
Mikhail Zarechenskiy a88dbefcd9 Generate is check for inline classes same as for primitives
Should be improved when inline class is based on non-null reference
2018-02-13 13:16:44 +03:00
Mikhail Zarechenskiy d606e5bc89 Correct boxing for functional types containing inline classes 2018-02-13 13:16:43 +03:00