Commit Graph

32 Commits

Author SHA1 Message Date
Zalim Bashorov 179ec41a6b [JS BEs] Generate tests for whole "codegen/boxInline" 2020-03-12 17:22:33 +03:00
pyos 82fb5c4d19 JVM_IR: move lambda captures to end of signature when inlining
For example, a lambda `{ param -> captured }` of type `E.(T) -> U` will
be transformed by LocalDeclarationsLowering into a private static method

    fun f$lambda-0($this: E, $captured: U, param: T) = $captured

The reason for such an ordering is that a lambda looks the same as a
local function, and local function can have default arguments, and those
arguments can reference captured variables; thus, captured variables
must come before actual declared arguments.

However, this is not the order that the inliner wants. Moreover, since
it was written to handle lambdas represented as `invoke` methods of
anonymous objects, it does not expect the actual callable method to have
any parameters corresponding to captured variables at all. This results
in it attempting to generate a temporary node with descriptor

    (LE;LU;LT;LU;)LU;

while still using locals 1 and 2 as `param` and `$captured` respectively.
In the example above, this is not critical, as they both have reference
type and the lambda will eventually be pasted into a different node
anyway; however, if it happens that one of them is a primitive, or both
are primitives of different types, the bytecode will use incorrect
instructions, causing verification errors. The correct descriptor is

    (LE;LT;LU;)LU;
2019-11-11 13:46:42 +01:00
Mikhael Bogdanov 1eda42cb88 JVM_IR. Generate SMAP information for anonymous classes
#KT-28092 Fixed
2019-08-08 12:02:50 +02:00
pyos 6d19eb1853 JVM_IR: sidestep defective getMethodAsmFlags when inlining lambdas
It uses isStaticMethod to determine whether to set ACC_STATIC, which is
not correct (see PR #2341). This results in using incorrectly typed
opcodes (as all arguments are shifted by 1) when modifying the inlined
lambda's bytecode. For example, in the test added by this commit, these
opcodes are inserted to spill the stack into locals before calling
another inline function.

Because getMethodAsmFlags is used by the non-IR backend (see PR #2341
again for why changing stuff might not be a good idea), the proposed
solution is to ditch it completely and override generateLambdaBody in
IrExpressionLambdaImpl to use FunctionCodegen's IR-based flag
computation logic.
2019-05-28 08:38:16 +02:00
Mikhael Bogdanov 2a3a9bb5fc Support properties reificaton 2019-04-08 13:10:25 +02:00
Mikhael Bogdanov 8fb2633bf4 Minor. Patch test to avoid failing in Native 2019-01-18 09:52:56 +01:00
Mikhael Bogdanov 02d9c526e2 Proper resort variables on inlining lowered ir closures
Original problem is that lowered ir closures doesn't meet inliner expectations
 about captured variable position in inlining method.
 E.g.: Call 'foo(valueParam) { capturedParam }' to
  inline function 'foo' with declaration

      inline fun foo(valueParam: Foo, inlineParamWithCaptured: Bar.() ->) ....

 is reorganized through inlining to equivalent call foo(valueParam, capturedParam1, cp2 ...).
 But lowered closure for lambda parameter has totally different parameters order:

     fun loweredLambda$x(extensionReceiver, captured1, cp2..., valueParam1, vp2...)

 So before inlining lowered closure should be transformed to

     fun loweredLambda$x(extensionReceiver, valueParam1, vp2..., captured1, cp2..)

 #KT-28547 Fixed
2019-01-03 07:57:36 +01:00
Mikhael Bogdanov e0bcba5c0e Add test for obsolete KT-17431 issue
#KT-17431 Obsolete
2019-01-02 12:37:07 +01:00
Mikhael Bogdanov 1217d3591b Specify JVM target backend for test with '::class.java' usage 2018-12-21 16:09:04 +01:00
Mikhael Bogdanov 357359b1dd Unmute ir-tests after CR support 2018-08-09 14:22:50 +03:00
Mikhael Bogdanov 9ccb25789b Unmute jvm-ir inline tests 2018-08-02 13:19:24 +02:00
Mikhael Bogdanov e149cbe852 Mute failed jvm ir tests 2018-06-28 12:26:41 +02:00
Ilya Matveev a5e4e0284e Mute some box tests for native backend
This patch mutes the following test categories:
   * Tests with java dependencies (System class,
     java stdlib, jvm-oriented annotations etc).
   * Coroutines tests.
   * Reflection tests.
   * Tests with an inheritance from the standard
     collections.
2017-03-10 19:59:37 +03:00
Denis Zharkov 4793f71da2 Properly generate indices for destructured parameters in inline case
#KT-14399 Fixed
2016-10-19 16:05:50 +03:00
Michael Bogdanov abc7d5101d Fix for KT-12106: import static of reified companion object method throws IllegalAccessError
#KT-12106 Fixed
2016-06-27 12:31:31 +03:00
Michael Bogdanov f5166b7aef Support test directives in inline tests 2016-04-04 12:07:46 +03:00
Alexander Udalov cc84aabdcf Migrate boxInline tests to new multi-file framework 2016-02-27 15:40:05 +03:00
Ilya Gorbunov 25c4453dc5 Cleanup deprecated symbol usages in testData 2016-01-22 05:54:38 +03:00
Michael Bogdanov 3da463be27 Fix for KT-10137: Internal error: couldn't inline method call on lambda taking extension function parameter
#KT-10137 Fixed
2015-11-24 16:32:06 +03:00
Denis Zharkov 098f5462eb Drop inlineOptions and fix forgotten usages 2015-09-23 12:18:12 +03:00
Denis Zharkov 9dada595b6 Replace deprecated annotations with modifiers in testData 2015-09-18 10:14:41 +03:00
Denis Zharkov 9adde77c47 Replace inlineOption(ONLY_LOCAL_RETURN) with crossinline in testData 2015-09-18 10:14:33 +03:00
Denis Zharkov c9f79c2d05 Adjust testData: get rid of obsolete annotations 2015-06-12 09:23:31 +03:00
Michael Bogdanov 7a1625fc9e Support extension lambda inlining
#KT-7962 Fixed
2015-06-08 16:07:38 +03:00
Michael Bogdanov e20a5121c7 Support private package properties in inline functions 2015-05-27 18:09:40 +03:00
Michael Bogdanov 7025a4f933 Test framewrk update: check lambda inlining 2015-04-13 16:11:21 +03:00
Stanislav Erokhin 3de0dff575 Migrate testdata to new lambda syntax 2015-04-07 13:08:53 +03:00
Pavel V. Talanov 06916d98c6 default -> companion: replace all mentions of default and default object 2015-03-17 15:47:39 +03:00
Pavel V. Talanov 59f192ef90 Replace 'class object' with 'default object' in renderers and test data
Includes changes to decompiled text
Old syntax is used in builtins and project code for now
2015-03-06 19:36:54 +03:00
Michael Bogdanov 59917f3727 Fix for KT-6154: Inlining a private class function accessing a private val member throws exception at runtime in accessing the val getter
#KT-6154 Fixed
2014-10-30 19:02:03 +03:00
Michael Bogdanov ce71c5abde Test update for new ONLY_LOCAL_RETURN diagnostic 2014-07-07 10:51:46 +04:00
Mikhael Bogdanov 02c6bdeaa3 Inline test data structure changed 2014-07-07 10:51:46 +04:00