Commit Graph

488 Commits

Author SHA1 Message Date
Steven Schäfer
9816e62d08 JVM_IR: Fix inlining of interface methods 2019-07-31 11:18:44 +02:00
Ilmir Usmanov
e60674f5e1 Fix test data 2019-07-29 20:34:51 +03:00
Mikhael Bogdanov
496765f41e Support target templates in bytecode tests
Avoid test data duplication
2019-07-16 14:08:27 +02:00
Mark Punzalan
de1e27c584 Make all progression headers inclusive, and decrement last for
last-exclusive progressions (i.e., "until" progressions and loop over
array indices).

This change makes it possible to correctly implement the handling of
"step" progressions. Computing the last element of a stepped progression
requires that the last is inclusive.

Also invert the while loop (into if + do-while) that is used when
lowering for-loops over progressions that cannot overflow. This keeps
the performance characteristics closer to the ForLoopsLowering in
kotlin-native, since the goal is to converge to this shared version.

Also used IrType instead of KotlinType, where possible.

 https://github.com/JetBrains/kotlin/pull/2390
 https://github.com/JetBrains/kotlin/pull/2305
2019-07-16 14:08:21 +02:00
Jake Wharton
4386518c4d Add intrinsic for ULong/UInt.toString on Java 8+
Unfortunately this cannot currently be done for the extension overload which accepts a radix due to behavior difference with regard to invalid radix values.
2019-07-16 11:15:19 +02:00
Steven Schäfer
da8fb3a195 JVM_IR: Respect -Xno-param-assertions 2019-07-08 17:48:33 +02:00
Steven Schäfer
dd20b74030 Split GenerateNotNullAssertionsTests into standard box and bytecode tests 2019-07-08 17:48:33 +02:00
Steven Schäfer
078ccbf077 JVM_IR: Implement name mangling exceptions for Result class. 2019-07-01 15:49:12 +02:00
Ilmir Usmanov
60cbf0696d Do not generate tests with experimental coroutines on JVM_IR backend
Enable working tests.
2019-06-25 16:30:01 +03:00
Steven Schäfer
917ef250cf Add and (un)mute inline class tests 2019-06-13 12:25:06 +02:00
Mikhael Bogdanov
81e6416bfe Support bound callable reference inlining in IR 2019-06-04 14:56:13 +02:00
Mikhael Bogdanov
3c093f321d Support unbound callable function references in inliner 2019-06-04 14:56:12 +02:00
Alexander Udalov
e72388895b JVM IR: invoke codegen after lowering all files in the module
Inspired by discussion in #2316
2019-05-30 13:28:31 +02:00
Jiaxiang Chen
d3cc0e6ce9 JVM_IR: Optimize disjunction condition with intrinsic function call. 2019-05-28 08:48:43 +02:00
pyos
6b2d874ccc JVM_IR: generate non-null assertions for arguments 2019-05-21 18:30:27 +03:00
Alexander Udalov
a53fa0dfbf Minor, optimize newly added tests on unsigned intrinsics
Remove "JVM_TARGET: 1.6" directive from box tests and remove tests with
JVM target 1.8. By default, box tests are run with JVM target 1.6, and
there's an additional configuration `codegenTarget8Jvm8Test` that runs
all box tests with JVM target 1.8.

Also, remove box tests with JVM target 1.6. They aren't needed because
even if we manage to generate incorrect bytecode with target 1.6, the
corresponding box tests will catch that
2019-05-15 13:30:16 +02:00
Jake Wharton
aaf533df16 IR lowering for computing trimIndent/trimMargin on constants 2019-05-14 20:19:43 +02:00
Ilmir Usmanov
360e30c133 Remove redundant continuation classes and INNERCLASS nodes
#KT-31339 Fixed
2019-05-14 16:00:39 +03:00
pyos
40696f65c3 JVM_IR: generate WhenMappings for enum ordinal subjects 2019-05-13 19:09:07 +03:00
pyos
fb194e982e Copy EnumWhenLowering from Kotlin/Native 2019-05-13 19:09:07 +03:00
Steven Schäfer
570ee38256 Implement special cases for the hashCode intrinsic in JVM_IR 2019-05-10 09:40:57 +02:00
Jiaxiang Chen
4b99d85322 Optimize JVM byte code generation for conditional conjunction
Implement an intrinsic method for boolean.and operation, and replace
ANDAND condition with a call to such intrinsic method.
2019-04-29 13:28:18 +02:00
Jake Wharton
373424f430 Add ULong.compareTo and UInt.div/rem/compareTo intrinsics for Java 8 2019-04-25 13:21:25 +02:00
Steven Schäfer
f2392a6a28 Remove Concat and StringPlus intrinsics in favor of IrStringConcatenation. 2019-04-24 12:04:12 +02:00
pyos
5b595b58b2 JVM_IR: fold constant string concatenations 2019-04-23 16:20:43 +02:00
Mikhael Bogdanov
dd005d3c02 Introduce IrLazyField 2019-04-18 19:56:19 +02:00
pyos
b23f2a4dbb JVM_IR: set ConstantValue on static final primitive fields 2019-04-18 09:16:32 +02:00
Ilmir Usmanov
20b9d8b2f3 Generate state-machine even if the object is going to be transformed
This fixes Java interop of inline functions, which use coroutines.
However, we cannot transform the state-machine. Thus, we generate
a $$forInline counterpart for suspend functions (similar to inline
suspend functions) and invokeSuspend$$forInline for lambdas if these
coroutines are going to transformed (i.e. are declared inside inline
functions).
During transformation we just skip method with state-machine and
transform the $$forInline counterpart. Of course, if inline site is
inline itself, we generate both state-machine version (which will be
dropped during the next transformation) and $$forInline version.
Consequently, the final version of the coroutines will not have
$$forInline counterpart.
Unfortunately, since CompileKotlinAgainstInlineKotlin tests do not allow
java sources, the tests for the interop are usual box tests.

 #KT-30707 Fixed
2019-04-18 01:12:52 +03:00
Mark Punzalan
1b703448d3 Handle reversed() in ForLoopsLowering.
We get the info for the underlying progression and invert it. For
progressions whose last bound was open (e.g., `until` loop), the
reversed version will have an open first bound and so the induction
variable must be incremented first.

Also unified the way of extracting HeaderInfo out of changed calls
(e.g., `indices.reversed()`), and fixed declaration parents in
ForLoopsLowering.
2019-04-11 08:54:55 +02:00
pyos
e249c3c594 Return a stripped version of StackValue from ExpressionCodegen 2019-04-10 20:51:46 +02:00
pyos
31c7183781 Return immaterial values from comparison intrinsics 2019-04-10 20:51:46 +02:00
pyos
9aff1cefb4 Make materialization of StackValues explicit 2019-04-10 20:51:46 +02:00
Mikhael Bogdanov
944c200a5d Initial support of try as expression in JVM IR 2019-04-08 13:10:24 +02:00
Mikhael Bogdanov
4c59d161d4 Support basic reification in IR 2019-04-08 13:10:22 +02:00
pyos
23d742237f Add tests for merging SAM wrappers and references 2019-04-04 09:45:00 +02:00
pyos
e05c151a73 Remove explicit mention of an internal name from a test 2019-04-04 09:45:00 +02:00
Mark Punzalan
a0940b1342 Use stricter assertions in for-loop bytecode text tests. 2019-04-04 09:07:19 +02:00
Mark Punzalan
dd65e0876f Simplify loop building by encoding open/closed bound information in the
HeaderInfo object, and modifying the operator in the loop condition.

The "additional emptiness condition" is no longer necessary with this.
The open/closed property was removed from HeaderInfo in an earlier
commit, but bringing it back in to simplify the loop building makes
more sense.

Also expanded tests for evaluation order of range bounds.
2019-04-04 09:07:19 +02:00
Mark Punzalan
7680e7fd56 Use while loop for progressions that cannot overflow (instead of
do-while with enclosing "not empty" check).

Also do not add additional "not empty" condition for `until` loops when
the given bound is a constant != MIN_VALUE.
2019-04-04 09:07:19 +02:00
Mark Punzalan
ba0e016c4e Add bytecode tests for array for-loop iteration. 2019-04-04 09:07:19 +02:00
Mark Punzalan
7afe121238 Eliminated the redundant ForLoopHeader.needsEmptinessCheck property, cast "bound" to progression type if necessary, fixed variable declaration order. 2019-04-04 09:07:19 +02:00
Mark Punzalan
ea9572ad28 Add DefaultProgressionHandler that handles for-loops over
non-specialized progressions, including "step" progressions.

DefaultProgressionHandler uses the "first/last/step" properties of
the progression when building the loop header.
2019-04-04 09:07:19 +02:00
Mark Punzalan
7b153b2b68 Move building of "not empty" condition (used to check if loop is empty)
from ForLoopsLowering into ForLoopHeader, reducing the building logic in
ForLoopsLowering.
2019-04-04 09:07:19 +02:00
Mark Punzalan
409d99a52a Add ForLoopsLowering to JVM phases.
Also deleted StepHandler. Since the HeaderInfo.needLastCalculation is
only set to true for handling step progressions, deleted that property
and all associated logic around it.
2019-04-04 09:07:19 +02:00
Ilmir Usmanov
d2a80e7938 Add $result to suspend functions' LVT
#KT-28535
2019-04-01 18:19:32 +03:00
Ilmir Usmanov
05937a28ee Rename result to $result
this way it does not interfere with user-defined variables.
 #KT-28535 Fixed
2019-04-01 18:19:31 +03:00
pyos
ef5e02da84 JVM_IR: handle Nothing and Unit more consistently.
* In blocks, discard the result of any statement that has a return
   type other than void. This was previously done by wrapping each
   statement into an "implicit Unit conversion" that was actually
   compiled down to a stack pop instead. If an expression happened to
   already have type Unit, however, such a conversion was not inserted,
   resulting in a stray reference on the stack. These conversions are
   now redundant and should probably be removed.

 * In assignments and non-exhaustive conditionals, materialize a Unit
   on the stack to avoid depth mismatches that trip up the bytecode
   validator. Because such expressions are generally used at block level
   (and, indeed, the frontend will reject a non-exhaustive conditional
   used as an expression), combined with the above change this results
   in no additional GETSTATIC opcodes, as they are immediately removed
   by the peephole optimizer.
2019-03-26 13:32:02 +01:00
Steven Schäfer
29b7da7c49 Implement support for KClass fields in annotation classes. 2019-03-26 11:54:16 +01:00
Ting-Yuan Huang
79fcaae991 Implement constant folding in the IR backend for JVM
The newly added pass folds the set of constant functions of the
current backend, plus IrBuiltIns.
2019-03-20 21:02:55 +01:00
Jake Wharton
6ee987fa2e Add intrinsics for compile-time computing trimMargin/trimIndent
These only apply when the receiver can be resolved to a constant and the margin prefix, if specified, is also a constant.
2019-03-20 17:25:29 +01:00