Commit Graph

3870 Commits

Author SHA1 Message Date
Alexander Udalov bd8ea9412d JVM IR: implement MethodSignatureMapper.mapFunctionName directly 2019-09-16 14:57:20 +02:00
Alexander Udalov 45929f57b6 Minor, add test on name mangling of private multi-file part members 2019-09-16 14:44:16 +02:00
Alexander Udalov 9d257a1ed8 JVM IR: generate call to checkNotNull in IrCheckNotNull since 1.4
#KT-22275
2019-09-16 12:33:01 +02:00
Dmitry Petrov f3837e91e3 Add BE tests for 'break' and 'continue' inside 'when' 2019-09-12 15:11:01 +03:00
Mads Ager 90a37617a4 [JVM_IR, IR] Remove more needless temporary variables.
Avoid using a separate origin for temporary variables introduced
for for loops. That doesn't add anything and gives one more case
for optimizations to deal with.

Extend the JVM specific optimizations to remove temporary
variables to deal with more cases encountered in for loops
lowering.
2019-09-11 10:07:45 +02:00
Roman Artemev e5a1040dbd [KLIB] Fix references to private top-level typealias via type abbreviation 2019-09-10 19:59:01 +03:00
Kristoffer Andersen e7d0909979 JVM_IR: Fix null-constant comparison with primitive types. 2019-09-09 10:23:11 +02:00
Mikhail Zarechenskiy e21da3a61a Avoid resolving array-set method several times
While origin problem was in NI, it's also nice to have this change in OI
 in order to slightly improve performance

 #KT-33125 Fixed
2019-09-09 11:04:18 +03:00
Mikhail Zarechenskiy f8449bf15a [NI] Clear partially resolved calls after resolve of top-level call
#KT-32433 Fixed
2019-09-09 11:04:17 +03:00
Steven Schäfer 62a1ea643a Add additional tests for bound receivers in callable references 2019-09-06 15:11:59 +02:00
Steven Schäfer d89d68e3df JVM IR: Cache SAM wrappers in top-level classes and use proper naming scheme 2019-09-06 15:11:59 +02:00
Steven Schäfer c77fa1ecd6 JVM IR: Fixes in SAM lowering 2019-09-06 15:11:59 +02:00
Georgy Bronnikov 7ede26e8f4 IrCompileKotlinAgainstInlineKotlin tests 2019-09-06 09:19:57 +03:00
Mads Ager 3f28b71509 [IR] Fix issue getting the length property from CharSequence bounded type parameter
Use the class of the subtype of CharSequence when available. When
it is not (for type parameters bounded by CharSequence) call the
CharSequence getter and 'get' method. Using the most specific type
posible fixes the forInStringSpecialized test that expects the
use of INVOKEVIRTUAL and not INVOKEINTERFACE.

Add tests for the type parameter use.
2019-09-03 20:18:03 +02:00
Mads Ager 85b1e0165b [IR] For loop lowering for CharacterSequence.indices. 2019-09-03 13:18:21 +02:00
Steven Schäfer 102a3d60e0 IR: Consistently copyAttributes in DeepCopyIrTreeWithSymbols
This was missing for IrFunctionReferences, which caused problems when
copying default parameters before CallableReferenceLowering in the
JVM_IR backend.
2019-09-02 19:55:36 +02:00
Nikolay Krasko 4d0fc1dc22 Remove 182 support
#KT-33536 Fixed
2019-08-30 12:13:44 +03:00
Mads Ager 8ed1317839 [IR] For loop lowering for iteration over CharacterSequences.
Change-Id: I7aeadfffc80f791ec19a3607e219c1dc4de028db
2019-08-30 09:35:59 +02:00
Mads Ager 6c7a904663 Psi2Ir: Mark accessors with no bodies as default accessors.
They are currently marked as defined even when they get a
default implementation. That makes it hard to figure out
if the accessor should be removed when introducing a backing
field in the JVM_IR backend.
2019-08-28 19:25:13 +02:00
Alexander Udalov aea9642ea0 JVM IR: implement MethodSignatureMapper.mapToCallableMethod directly
Instead of calling enormously complicated
KotlinTypeMapper.mapToCallableMethod, where most of special cases are
handled in the IR backend via lowerings.
2019-08-27 19:27:46 +02:00
Alexander Udalov 2b4424b564 JVM IR: replace function accesses in multi-file parts
Any access to a function from a multi-file part needs to be replaced
with the access to the corresponding public method (if it exists) from
the facade class. Note that this has no immediate effect because we use
KotlinTypeMapper for mapping calls, and it understands that a call to a
function from the part must actually be generated into a call to the
function from the facade in the bytecode. This commit merely changes the
IR to better reflect what's generated in the final bytecode, and to be
able to use simplified IR-based method signature mapping instead of the
legacy KotlinTypeMapper in the future.
2019-08-27 19:27:45 +02:00
Steven Schäfer 6bf16a96e1 Add more tests for type operators on the jvm 2019-08-27 10:44:23 +02:00
Ilmir Usmanov ef5fcb4e9e Fix test data 2019-08-23 19:09:28 +03:00
Alexander Udalov d59f2bcc80 Fix KotlinReflectionInternalError on invoking callBy with defaults in supertypes
There are two parts in this change:

1) Previously, we looked up $default methods with the incorrect
   signature in supertypes. For example in defaultInSuperClass.kt, we'd
   try to find a method foo$default with the signature `(B, String,
   String, int, Object)` in the class A. Now we're modifying the array
   of parameter types on each step if we're looking for a static
   $default method, by assigning its first element to be the containing
   class. This fixes cases when defaults come from a superclass.
2) For interfaces, $default methods are actually located in the
   corresponding DefaultImpls class. Now we look up that class and
   search for the $default method there. Note that this is needed
   because of KT-33430. This fixes cases when defaults come from a
   superinterface.

 #KT-13936 Fixed
2019-08-22 18:04:00 +02:00
Alexander Udalov cb2e68fece JVM IR: skip temporary variables in InventNamesForLocalClasses 2019-08-22 18:04:00 +02:00
Ilmir Usmanov f9506db20a Ignore sources which are not LOADs in refinedIntTypeAnalysis
#KT-33414 Fixed
2019-08-22 16:08:08 +03:00
Alexander Udalov f64afbf152 JVM IR: reduce usages of IrTypeMapper.kotlinTypeMapper 2019-08-21 15:13:49 +02:00
Igor Chevdar 8d2ccb7bcd [IR] Taught inliner to work with inline suspend lambdas 2019-08-20 12:52:54 +03:00
pyos 7ff700ff97 JVM_IR: lower calls to @JvmStatic functions from other files.
Note: this currently results in invalid IR (but valid bytecode) if the
@JvmStatic function is imported, because its IR representation is
unlowered and therefore has a dispatch receiver, but the call will not.
2019-08-20 11:39:25 +03:00
Alexander Udalov ad43bc23ea Minor, add test case on SAM conversion over smart cast 2019-08-19 18:09:32 +02:00
Igor Chevdar ad8bcda99e [IR] Merged K/N inliner with the common one 2019-08-16 18:32:19 +03:00
Mikhail Zarechenskiy d59b910403 Add tests for obsolete issues
#KT-32207 Obsolete
 #KT-32836 Obsolete
 #KT-32949 Obsolete
 #KT-9384 Obsolete
2019-08-15 13:01:39 +03:00
Dmitry Petrov 986654b709 psi2ir: fix unsubstituted type parameters around SAM conversions
Preserve type substitution:
- when obtaining function type for SAM type;
- when generating SAM conversions for SAM adapter arguments;
- for "original" method corresponding to a SAM adapter.
2019-08-14 14:18:42 +03:00
Dmitry Petrov 7d49b72b79 JVM_IR: Support 'CHECK_NOT_NULL' intrinsic
TODO: migrate to changes related to KT-22275
2019-08-14 11:16:10 +03:00
Steven Schäfer ac667403ef (Un)mute and add tests for vararg codegen 2019-08-13 14:24:55 +02:00
Alexander Udalov 01ddac58e1 Add language feature for changed name of property annotations method
#KT-31352 Fixed
2019-08-12 16:48:26 +02:00
Alexander Udalov ea0142da60 Use JVM name of getter in synthetic method for property annotations
#KT-31352 In Progress
2019-08-12 16:48:25 +02:00
Alexander Udalov e207c96336 Throw NPE instead of TypeCastException since 1.4
#KT-22275 In Progress
2019-08-12 16:09:23 +02:00
Alexander Udalov 2baddb029c Use Intrinsics.checkNotNullParameter to throw NPE in parameter null checks
Similarly to previous commits, this method was unused, so we're changing
its semantics in API version >= 1.4.

 #KT-22275 In Progress
2019-08-12 16:09:23 +02:00
Alexander Udalov 480313210a Use Intrinsics.checkNotNullExpressionValue to throw NPE in Java null checks
Similarly to previous commit, this method was unused since its
introduction before 1.0, so we're changing its semantics to throw NPE
and starting to use it with API version >= 1.4.

 #KT-22275 In Progress
2019-08-12 16:09:23 +02:00
Alexander Udalov a7c8fdcbe2 Use Intrinsics.checkNotNull and throw NPE in !! operator generation
This method was introduced in c204e8fc67 "just in case" and was never
used. Therefore we're free to change its semantics and use it in all new
generated code (with API version >= 1.4), without even worrying that the
newly used API will leak from inline functions in stdlib when used with
an older API version. Since we agreed to change the type of thrown
exceptions to java.lang.NPE in KT-22275, invoke a new method
throwJavaNpe now which throws that exception instead of KNPE.

Note that the additional method that takes an exception message is still
unused and exists just in case we need to use it in the future. The new
method throwJavaNpe is public also "just in case" we need to invoke it
in the future; currently it's not invoked from the bytecode.

 #KT-22275 In Progress
2019-08-12 16:09:23 +02:00
Ilmir Usmanov e88dce3e19 Use CFG to recognize suspension point's end
Previously it was linear scan, failing on unbalanced suspension markers.
Now, I use CFG to find end markers, which are reachable from start
markers. Using CFG allows to walk through suspension point instructions
only, since they form region.
If, for some reason, end marker does not exist (inliner or unreachable
code elimination pass remove unreachable code) or is unreachable,
just ignore the whole suspension point, as before.
 #KT-33172 Fixed
 #KT-28507 Fixed
2019-08-09 21:05:03 +03:00
Steven Schäfer 73d2ae961c JVM IR: BridgeLowering boxing fixes 2019-08-09 12:14:44 +03:00
Steven Schäfer 6aa8ecd745 JVM IR: Remove bridge construction from CallableReferenceLowering 2019-08-09 12:14:44 +03:00
Mikhael Bogdanov 1eda42cb88 JVM_IR. Generate SMAP information for anonymous classes
#KT-28092 Fixed
2019-08-08 12:02:50 +02:00
Mikhael Bogdanov a444a40849 JVM_IR. Basic support of 'inlineCallSiteInfo' 2019-08-08 12:02:49 +02:00
Steven Schäfer f34a08cbbf JVM IR: Convert interface companion fields to static fields. 2019-08-08 12:01:52 +02:00
Mikhail Zarechenskiy 04e57f712e [NI] Introduce feature for passing function references with defaults
Relates to KT-8834, we continue reducing differences between old and new
 inference. Note that as for `SamConversionPerArgument`, this feature
 is enabled in the compiler and not in the IDE to avoid breaking code
 for those users that already enabled new inference in the compiler
2019-08-07 15:58:36 +03:00
Steven Schäfer 43a27ab58c (Un)mute tests 2019-08-07 10:34:43 +02:00
Steven Schäfer d11344ce2e Add more tests for -Xassertions=jvm corner cases 2019-08-07 10:34:43 +02:00