Commit Graph

77 Commits

Author SHA1 Message Date
Dmitry Petrov
8b446a1649 Use correctElementType to determine array element type for withIndex
Rather unkind "gotcha" in ASM API.
2018-04-23 17:56:16 +03:00
Dmitry Petrov
99cea07bf4 Correctly map container element type in intrinsic for withIndex
In case of arrays, we couldn't distinguish array of boxed Ints
from array of primitive Ints.

 #KT-22904 Fixed Target versions 1.2.40
2018-02-20 09:18:25 +03: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
ef6b6cd261 Fix NPE into isArraySizeAccess 2018-02-15 12:41:33 +03:00
Mikaël Peltier
3c2f137fd5 Exclude tests from JS backend due to a bug into it 2018-02-15 12:41:33 +03:00
Mikaël Peltier
be07a348ea Reformat tests 2018-02-15 12:41:33 +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
Dmitry Petrov
72ffbb9825 Add test for array modification within for-in-array-withIndex loop body 2018-01-23 10:55:24 +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
Dmitry Petrov
3d473f608e Add more tests for for-in-array
#KT-21354 Fixed Target versions 1.2.20
 #KT-21321 Fixed Target versions 1.2.20
2017-12-05 15:45:20 +03:00
Denis Zharkov
ff0736f09e Fix exception after combination of while (true) + stack-spilling
FixStack transformation divides on phases:
- Fixing stack before break/continue
- Fixing stack for inline markers/try-catch blocks

After the first stage all ALWAYS_TRUE markers are replaced
with simple GOTO's and if we're skipping break/continue edges
we won't reach the code after while (true) statement.

At the same time it's fine to not to skip them in the second phase
as the stack for them is already corrected in the first phase

 #KT-19475 Fixed
2017-08-08 18:52:21 +07:00
Mikhail Zarechenskiy
39349abd39 [NI] Preserve name of parameters for functional types 2017-08-07 18:01:07 +03:00
Igor Chevdar
d7e4350d42 Ignored/fixed some tests for Kotlin/Native 2017-06-28 12:54:32 +03:00
Dmitry Petrov
fe571a7dfa Normalize local returns before other inlining transformations
Local returns normalization can generate POP instructions.
These POP instructions can drop functional parameters, as in KT-17590,
and should be processed in markPlacesForInlineAndRemoveInlinable just
as other POP instructions.

KT-17590 conditional return in inline function parameter argument causes compilation exception
2017-04-26 12:42:33 +03:00
Dmitry Petrov
e1731373d8 Do not restore stack in default handler for try-finally
It never terminates, so the corresponding value on stack can't be used.
However, if this happens in an inlined lambda argument, the inliner is
unable to remove the corresponding ALOAD instruction (because default
handler never terminates, and thus corresponding ALOAD is not used for
lambda invocation).

KT-17573 try-finally expression in inlined function parameter argument fails with VerifyError
2017-04-26 12:42:33 +03:00
Dmitry Petrov
08fb9c2122 Traverse multiple store-load chains for inlined lambda parameters
When a try-catch expression is passed as an argument to the inline
lambda parameter, lambda variable on stack is spilled and restored in
several different locations (1 for try-block, 1 for each catch-blocks).
So it's possible that lambda to be invoked comes from multiple loads,
all of which should have the same "root" lambda parameter.
2017-04-26 12:42:33 +03:00
Dmitry Petrov
441be56a40 During inlining, remove POP instructions popping inlined lambdas
In cases like KT-17384, where 'break' or 'continue' happens in an argument
to an inlined lambda call, fix-stack transformation sees corresponding
ALOAD for lambda, and inserts corresponding POP instruction before jump.
However, this ALOAD is later removed during inlining.
So, we should also remove the related POP instructions.
2017-04-26 12:42:33 +03:00
Dmitry Petrov
1ee337d976 Optimize iteration over CharSequence's on JVM
KT-7931 Optimize iteration over strings/charsequences on JVM
2017-04-25 10:07:05 +03: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
Dmitry Petrov
11caa03427 KT-16713 Insufficient maximum stack size
1. Analyze method node with fake jumps for loops to make sure that
all instructions reachable only through break/continue jumps are processed.
2. Fix stack for break/continue jumps.
3. Drop fake jumps for loops, analyze method node again.
4. Fix stack for try/catch and beforeInline.
2017-03-08 09:56:08 +01:00
Mikhael Bogdanov
ab464ea86e Fix for KT-15726: Kotlin can't compile nested try-catch with return
#KT-15726 Fixed
2017-01-27 14:09:13 +01:00
Dmitry Petrov
ba933fa887 KT-15112, KT-15631
Revert changes for "tolerant to uninitialized values" in OptimizationBasicInterpreter:
this approach doesn't converge for some specific cases where local variable is reused
(e.g., in several inlined functions - see https://youtrack.jetbrains.com/issue/KT-15112).

Instead, treat fake always-false conditional jump in the beginning of the post-condition loop as a "reference point" for stack on loop break / continue.
This requires an extra abstraction layer in FixStackAnalyzer, since we can't perform fine-grain manipulations on Frames
(such as "combine frame C from local variables of frame A and stack of frame B").

NB additional NOPs will be generated for post-condition loops.
Should make a separate bytecode postprocessing pass to get rid of unnecessary NOPs
(several YT issues for perceived quality of the generated bytecode are about such NOPs).
2017-01-13 10:31:07 +03:00
Alexey Andreev
10a3fbf53f JS: disable TemporaryAssignmentElimination, fix KT-15512 2017-01-12 18:12:39 +03:00
Alexey Andreev
ee74342fbe JS: fix compiler crash when optimizing JS AST with empty do..while statement. See KT-15513 2017-01-12 18:12:37 +03:00
Ilya Gorbunov
62fe89b536 Make several tests running on JS backend. 2016-11-21 18:20:33 +03:00
Ilya Gorbunov
0899a0fdda Make some tests JVM only 2016-11-21 18:20:33 +03:00
Ilya Gorbunov
38840bb529 Do not reference java.util in tests that run on JS backend. 2016-11-21 18:20:33 +03:00
Dmitry Petrov
8b99141030 KT-14839 Do not coerce after remapped variable store. 2016-11-18 09:35:31 +03:00
Alexey Andreev
b5358122e2 JS: unmute shared box tests 2016-11-16 19:50:10 +03:00
Dmitry Petrov
b429f7bc86 KT-14581 Make FixStackAnalyzer tolerant to uninitialized values 2016-11-11 13:30:15 +03:00
Zalim Bashorov
596f3364c6 Automatically mute failed tests 2016-11-09 21:41:12 +03:00
Michael Bogdanov
486aa5675f Fix for KT-12908: Variable initialization in loop causes VerifyError bad local variable type
#KT-12908 Fixed
2016-07-09 07:45:57 +03:00
Michael Bogdanov
dec53c8d6c Fix for KT-11762: "VerifyError: Bad local variable type" caused by explicit loop variable type
#KT-11762 Fixed
2016-04-05 13:37:10 +03:00
Mikhail Glukhikh
b7e8f71367 Fix of getCorrespondingLoop for complex loop / try-finally trees #KT-8246 Fixed 2016-03-30 18:49:23 +03:00
Alexander Udalov
bab127ad33 Remove some legacy codegen tests, move some to generated 2016-03-09 10:25:38 +03:00
Alexander Udalov
06a67e6602 Merge boxWithStdlib testData into box, delete BoxWithStdlib test 2016-03-09 10:25:38 +03:00
Ilya Gorbunov
4d5ec9be3f Drop identityEquals from builtins, compiler and tests. 2016-01-22 05:54:38 +03:00
Ilya Gorbunov
b97e436a50 Fix deprecated Range and Progression usages in testData 2016-01-22 05:54:38 +03:00
Dmitry Petrov
b736880787 KT-6646, KT-10482:
when a method (or a property getter) returns Nothing, emit
  ACONST_NULL
  ATHROW
after a call so that class files verifier knows that this is an exit point in a method.
Note that if an inline method returning Nothing throws an exception explicitly
(or via a chain of inline methods), this code will be deleted by DCE.
2015-12-31 11:07:56 +03:00
Yan Zhulanow
9d1af5a17e Fix tests: "infix modifier required" and "operator modifier required" errors 2015-11-27 15:51:11 +03:00
Michael Bogdanov
3f995935d3 Fix for KT-9022: Wrong result when use break in if condition
#KT-9022 Fixed
2015-11-13 10:14:00 +03:00
Ilya Gorbunov
5e6d16103e Remove deprecated ranges from tests and take into account that Byte and Short rangeTo now returns IntRange. 2015-11-11 03:53:31 +03:00
Dmitry Petrov
ccad435850 KT-9644: override default behavior for non-local return in FixStackAnalyzer 2015-10-26 15:56:57 +03:00
Yan Zhulanow
e14c9645dc Error on 'if' without an 'else' branch when used as an expression 2015-10-19 03:56:15 +03:00
Denis Zharkov
bd37a10677 Transform *Array.size to properties 2015-10-16 18:16:02 +03:00
Denis Zharkov
17c906658d Transform Throwable members to properties 2015-10-14 20:39:59 +03:00
Denis Zharkov
f0e3fd617d Adjust testData to CharSequence.length transformation 2015-10-14 20:39:35 +03:00