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
Mikhail Zarechenskiy
1d16d21dbb
Fix boxing for non-local and labeled returns with inline classes
2018-02-13 13:16:42 +03:00
Mikhail Zarechenskiy
80dd5c106e
Propagate KotlinType through call generator, fix boxing on arguments
2018-02-13 13:16:42 +03:00
Mikhail Zarechenskiy
22b9c25dd0
Add KotlinType info about this inside inline class
2018-02-13 13:16:41 +03:00
Mikhail Zarechenskiy
c86d3e354b
Skip call to the underlying value of inline class
2018-02-13 13:16:41 +03:00
Mikhail Zarechenskiy
2c279978c8
Fix generation of property accessor to the underlying value
2018-02-13 13:16:40 +03:00
Mikhail Zarechenskiy
b361d0e9c0
Add test and check that iterator over UInt folds to a simple for-loop
2018-02-13 13:16:40 +03:00
Mikhail Zarechenskiy
059f1e9eed
Support inline classes working with collection elements (get/set)
2018-02-13 13:16:39 +03:00
Mikhail Zarechenskiy
8015295059
Desugar constructor call of inline class to the underlying value
...
Also add information about KotlinType to the constant stack values
2018-02-13 13:16:39 +03:00
Mikhail Zarechenskiy
913e4b42bb
Support inline classes as last expression in lambda
2018-02-09 05:06:32 +03:00
Mikhail Zarechenskiy
396cc7d02b
Support unboxing of inline classes in elvis
2018-02-09 05:06:31 +03:00
Mikhail Zarechenskiy
fefcddc803
Support boxing/unboxing for captured vars of inline class types
2018-02-09 05:06:29 +03:00
Mikhail Zarechenskiy
9f24bbd980
Support unboxing of inline classes after assertion operator
2018-02-09 05:06:27 +03:00
Mikhail Zarechenskiy
0fd80ce980
Unbox inline classes after safe calls if needed
2018-02-09 04:56:40 +03:00
Mikhail Zarechenskiy
c5c8d84719
Support boxing/unboxing for method return types
2018-02-09 04:56:36 +03:00
Mikhail Zarechenskiy
390c214943
Support boxing for inline classes on function calls
2018-02-09 04:56:08 +03:00
Mikhail Zarechenskiy
0d682879f5
Initial boxing for inline classes: local variable assignments
2018-02-09 04:55:44 +03:00
Mikaël Peltier
126afbb8ac
Avoid to generate unecessary checkcast
...
StackValue already avoid to generate checkcast from a type or an
array to java.lang.Object. Add a new case to avoid to generate a
checkcast from an array to an array of java.lang.Object when arrays
have the same dimensions.
#KT-22714 Fixed
2018-02-08 16:38:46 +01:00
Mikaël Peltier
a2a3043607
KT-18731 Use reference equality to compare enums
...
Fix of https://youtrack.jetbrains.com/issue/KT-18731
2018-02-05 18:34:44 +03:00
Mikhail Zarechenskiy
5dacfae793
Support calling inline functions inside inline classes
2018-02-05 12:07:41 +03:00
Mikhail Zarechenskiy
928a342ace
Initial version of codegen for inline classes
2018-02-05 12:07:40 +03:00
Dmitry Petrov
40d1925e19
Provide optimized code generation for for-in-withIndex for sequences
...
#KT-5177 In Progress
2018-01-23 10:55:24 +03:00
Dmitry Petrov
2399a39414
Provide optimized code generation for for-in-withIndex for CharSequences
...
#KT-5177 In Progress
2018-01-23 10:55:24 +03:00
Dmitry Petrov
9c9e507172
Provide optimized code generation for for-in-withIndex for iterables
...
#KT-5177 In Progress
2018-01-23 10:55:24 +03:00
Dmitry Petrov
08622b0953
Provide optimized code generation for for-in-withIndex for arrays
...
#KT-5177 In Progress
2018-01-23 10:55:24 +03:00
Denis Vnukov
52ccd67ec1
Remove duplicate parameter null checks in JvmStatic delegate methods.
...
Remove unnecessary non-null parameter checks inside static delegate methods
created for @JvmStatic companion object methods. Allows function generation
strategy decide if such checks need to be injected.
#KT-7188 Fixed
2017-12-14 13:48:50 +03:00
Dmitry Petrov
9fa9a8748b
Check that qualified const expressions are recognized properly in 'for'
2017-12-14 10:41:51 +03:00
Dmitry Petrov
54cceac99b
Intrinsics for 'reversed': until
2017-12-14 10:41:51 +03:00
Dmitry Petrov
5f7460a8c7
Support const-bound counter loop generation for 'downTo'
2017-12-14 10:41:51 +03:00
Dmitry Petrov
a4c29b3587
Support Long and Char in const-bounded counter loop generation
...
If the loop end value is a compile-time constant (best we can do now),
and it is safe to iterate over a given range using "naive" for loop
(using '<=' or '>=' in loop condition),
generate such loops for Longs and Chars as well Ints (Bytes, Shorts).
2017-12-14 10:41:51 +03:00
Dmitry Petrov
455a1c0f53
Intrinsics for 'reversed': downTo
...
#KT-21323 In Progress
2017-12-14 10:41:51 +03:00
Dmitry Petrov
64ba811b7f
Intrinsics for 'reversed': CharSequence.indices
...
#KT-21323 In Progress
2017-12-14 10:41:51 +03:00
Dmitry Petrov
7ba73c1635
Intrinsics for 'reversed': collection.indices
...
#KT-21323 In Progress
2017-12-14 10:41:51 +03:00
Dmitry Petrov
5bcbe25469
Intrinsics for 'reversed': array.indices
...
#KT-21323 In Progress
2017-12-14 10:41:51 +03:00
Dmitry Petrov
beff4a1b92
Intrinsics for 'reversed': support non-literal range expressions
...
#KT-21323 In Progress
2017-12-14 10:41:51 +03:00
Dmitry Petrov
821843e13f
Intrinsics for 'reversed': generate in-const-bound ranges as countable
...
#KT-21323 In Progress
2017-12-14 10:41:51 +03:00
Dmitry Petrov
1775f294f4
Intrinsics for 'reversed': infrastructure & primitive range support
...
#KT-21323 In Progress
2017-12-14 10:41:51 +03:00
Dmitry Petrov
5b8c0d4c3e
Optimize for-in-string loops
...
For-in-string loop can be generated using specialized 'length' and
'charAt' method calls, and with cached string length.
Note that update of the string variable in loop body doesn't affect
loop execution semantics.
#KT-21322 Fixed Target versions 1.2.20
2017-11-29 10:15:38 +03:00
Alexander Udalov
938fd1a57e
Use ResolvedCall for callable reference in KCallableNameProperty intrinsic
...
Instead of manually inspecting the DOUBLE_COLON_LHS slice, which is a
bit more error-prone. Note that new tests were passing before this
change
2017-11-27 12:46:56 +01:00
Dmitry Petrov
354d54aef6
Don't generate DUPX instructions for in-range-literal expressions
...
Store argument into a local variable instead.
2017-11-16 10:54:25 +03:00
Mikhael Bogdanov
dff6e943bb
Always do stack spilling during inline cause of dex problem
...
Dex issue: https://issuetracker.google.com/issues/68796377
#KT-20844 Fixed
2017-11-13 16:50:24 +01:00
Dmitry Petrov
16b7bece46
Fix constant expression inlining logic
...
Constant expressions are inlined if they do not depend on non-inlineable
vals.
Java constants are always inlined.
Kotlin constants are inlined in LV 1.1+.
2017-10-13 17:01:42 +03:00
Dmitry Petrov
e71090ae4c
Spill stack for inline functions only if it's required
...
Stack should be spilled before inline function call and restored after
call only if one of the following conditions is met:
- inline function is a suspend function
- inline function has try-catch blocks
- inline function has loops (backward jumps)
Note that there're quite some "simple" inline functions in Kotlin stdlib
besides run/let/with/apply. For example, many string operations are
implemented as inline wrappers over Java method calls.
2017-10-10 08:49:19 +03:00
Dmitry Petrov
73724bcdc7
Do not copy immediately created arrays in spread arguments
...
E.g., 'foo(x = *intArrayOf(42))'.
#KT-20462 Fixed
2017-09-28 14:55:11 +03:00
Mikhael Bogdanov
81a1bf3319
Recalculate max stack on method emitting: optimizations could change it
2017-09-06 08:20:32 +02:00
Dmitry Petrov
78b69cad77
Support lateinit local vars in redundant null check elimination
...
Lateinit local vars are guaranteed to be non-null after store.
So we mark such stores as storing non-null value
(could be useful for some other constructs, too),
and optimize null checks accordingly.
2017-08-31 11:28:08 +03:00
Denis Zharkov
ad9fe53ee2
Avoid local var entry for continuation parameter in suspend function
...
The primary reason is getting rid of redundant stack spilling, but also
it's not very sensible to have such entry since the parameter
is synthetic
2017-08-22 18:43:31 +03:00
Denis Zharkov
fcd7677a3f
Fix compatibility of suspend functions with strict bytecode analyzers
...
In short, some of the bytecode analyzers assume that there could be
no stores instructions into parameter vars with value of different
types (even when the value type is a subtype)
See the issue for details
#KT-19713 Fixed
2017-08-22 18:43:26 +03:00