Commit Graph

1070 Commits

Author SHA1 Message Date
Dmitry Petrov d559212d70 Optimize out trivial INSTANCEOF checks
#KT-18157 Fixed Target versions 1.1.4
2017-05-31 16:48:14 +03:00
Alexey Andreev e6b0cc64bd Fix copying of non-abstract functions of interfaces in JS BE
Fix copying of non-abstract functions of interfaces to implementing
classes when implementing class inherits interface via 2+ paths.

See KT-18187
2017-05-31 11:21:13 +03:00
Alexey Andreev 24c0a1e7ce Fix translation of delegated functions with default params in JS BE
See KT-17285
2017-05-29 15:30:28 +03:00
Alexey Andreev 383e273fed In LightAnalysisModeTestGenerated skip tests ignored in JVM
When a test is marked as ignored in JVM BE (i.e. IGNORE_BACKEND: JVM)
it's ignored in LightAnalysisModeTestGenerated. This means that
this tests is expected to fail. However, often tests that fail
in JVM blackbox tests, don't fail in LAMTG, therefore it's reasonable
to skip these tests in LAMTG at all.
2017-05-29 15:30:27 +03:00
Denis Zharkov 2c98bd053a Fix super calls to suspend functions in abstract classes 2017-05-29 10:58:18 +03:00
Alexey Andreev dde50a34db Fix comparison of boolean values in JS BE
See KT-16984
2017-05-26 18:26:08 +03:00
Denis Zharkov 52b2e632df Simplify generated code for rangeTo/concat intrinsics
The main reason is avoiding complicated operations like
dup + dup_x2 + pop2 for instances obtained by NEW instruction.

Otherwise it leads to problems in performRefinedTypeAnalysis
because code there has a sensible assumption that NEW instances
can be only dupped or stored into a local (rare cases)

 #KT-17457 Fixed
2017-05-22 14:51:04 +03:00
Dmitry Petrov e1b41eee15 Specialize Comparable#compareTo for boxed primitives
Support Comparable#compareTo for boxed primitive in redundant
boxing/unboxing analysis, along with CHECKCAST to java.lang.Comparable.

Note that we can do that for Float and Double, too, because
Float#compareTo(Float) and Double#compareTo(Double) are delegated to
Float#compare(float, float) and Double#compare(double, double),
respectively.

Fuse specialized comparison for integers with conditional jumps
if possible (both for Comparable#compareTo and Intrinsics#areEqual).

 #KT-11959 Fixed
2017-05-22 11:57:20 +03:00
Mikhael Bogdanov 47fec6c9d5 Wrap captured local delegated property into Delegate
#KT-16864 Fixed
2017-05-19 09:53:19 +02:00
Alexander Udalov 52237ce77f Fix KClass.java intrinsic for stack values of type Unit
#KT-17692 Fixed
2017-05-18 13:29:04 +03:00
Denis Zharkov 49453ca705 Avoid dependency on coroutine-related public API changes
These changes has been introduced in c3a032ea0b
to support new scheme for named functions

At the same time they can be avoided by generating some additional
code/accessors in the anonymous classes for coroutine state

Now we cannot simply remove introduced API because of bootstrap problems

 #KT-17898 Fixed
2017-05-18 12:42:12 +03:00
Dmitry Petrov 495fba43c0 Fuse primitive equality with safe call to avoid boxing
In code like 'a?.b == 42', we can immediately generate equality
comparison result when receiver is null (false for '==', true for '!='),
since the primitive value is definitely non-null.
Otherwise unnecessary boxing/unboxing is generated to handle possibly
null result of 'a?.b'.
2017-05-16 17:28:43 +03:00
Denis Zharkov d24d3a73d7 Support open suspend members and super-calls
The problem was that the resume call (from doResume) for open members
was based on common INVOKEVIRTUAL to the original function
that lead to the invocation of the override when it was expected
to be the overridden (after super-call being suspended)

The solution is to generate method bodies for open members into
the special $suspendImpl synthetic function that may be called
from the doResume implementation

 #KT-17587 Fixed
2017-05-16 11:38:59 +03:00
Denis Zharkov e75b6c8404 Perform fix-stack transformation before method analysis
Otherwise it might fail on an "invalid" bytecode
2017-05-16 11:38:59 +03:00
Anton Bannykh e098de5e33 JS: fix char boxing in elvis expressions (#KT-17700 fixed) 2017-05-11 21:31:38 +03:00
Alexey Andreev 1900b20e6e Implement inlining of Array constructor in JS BE
See KT-15456
2017-05-11 17:10:45 +03:00
Denis Zharkov 7c6a15ddfe Treat inline suspend functions as inline-only
Now their bodies don't have real state machines, thus they cannot
be called correctly from Java

 #KT-17585 In progress
 #KT-16603 In progress
2017-05-05 14:14:38 +03:00
Denis Zharkov 5b5f612a7c Support new strategy for suspend inline functions
The main idea is to leave all the inline functions as is, without
state machines (but keeping suspend-calls markers) and
determine whether we need a state machine from the bytecode
after inlining into a non-inline function

 #KT-17585 In Progress
 #KT-16603 In Progress
 #KT-16448 Fixed
2017-05-05 14:14:00 +03:00
Denis Zharkov d92c403f9e Move helpers for coroutine tests in separate package
It will help to skip their content when rendering bytecode listing
for box tests
2017-05-05 14:01:50 +03:00
Anton Bannykh 2e9a59819a JS: support internal visibility from friend modules
Friend modules should be provided using the -Xfriend-modules flag
in the same format as -libraries. No manual configuration required for
JPS, Gradle and Maven plugins.

Friend modules could be switched off using the -Xfriend-modules-disabled
flag. Doing that will
  * prevent internal declarations from being exported,
  * values provided by -Xfriend-modules ignored,
  * raise a compilation error on attemps to use internal declarations from other modules

Fixes #KT-15135 and #KT-16568.
2017-05-04 21:44:17 +03:00
Anton Bannykh 7503376731 JS: unmute box/test/coroutinessuspendFunctionAsCoroutine/inlineTwoReceivers.kt 2017-05-04 16:47:00 +03:00
Dmitry Petrov 506941e7e0 Optimize range operations for 'until' extension from stdlib (KT-9900)
NB: for-in-until loop is generated as precondition loop, because the
corresponding range is right-exclusive (and thus we have no problems
with integer overflows).
2017-05-04 10:09:42 +03:00
Igor Chevdar 962bce19a2 Enabled tests on coroutines for native 2017-05-03 10:42:07 +03:00
Alexey Andreev c8c3d24b45 Fix non-suspending labeled loop in suspend function
Fix bug when labeled loop, which does not contain suspend calls
in its body, was losing its label
2017-04-28 10:52:14 +03:00
Mikhail Zarechenskiy a0d7b703f4 Align generic signature for inner classes to work as in Java
#KT-10397 Fixed

According to JVMS (p. 4.3.4) inner classes should be separated with `$` in generic signature.

Note that in Java, inner types separated with `.` after first parameterized type, and now we preserve the same behaviour. See tests for clarification.
2017-04-27 15:47:28 +03:00
Ilya Matveev 935d42f8ac Ignore explicitEqualsOnDouble.kt box-test for native backend 2017-04-27 14:55:32 +07:00
Zalim Bashorov fb1c4320b6 KJS: check hashCode property only for objects to avoid extra boxing for primitive values
Also in Nashorn everything has hashCode including primitive types,
so the result can be different at Nashorn and at other engines.
2017-04-26 13:07:34 +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
Mikhael Bogdanov b9409523b0 Fix for KT-17588: Compiler error while optimizer tries to get rid of captured variable
#KT-17588 Fixed
2017-04-25 15:06:41 +02:00
Mikhail Zarechenskiy 63d015ec70 Merge pull request #1055 from JetBrains/rr/matveev
Ignore native backend in some box tests
2017-04-25 11:42:51 +03:00
Mikhael Bogdanov 9d021ee1ac Add infrastructure to run codegen test on jdk 6
Perform actual codegen test execution in separate process.
One server process is used to run all codegen tests
through socket connection.
2017-04-25 09:31:17 +02: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 629be10a53 Ignore native backend in some box tests 2017-04-24 17:43:14 +07:00
Ilya Gorbunov 4a5d8534c1 Fix array iterators to adhere to Iterator contract
#KT-17453 Fixed

Change expected exceptions in tests.
2017-04-18 18:51:20 +03:00
Alexey Andreev 7e6df03421 Fix improper handling of coroutine interceptors
Don't use coroutine facade in following cases:
* When calling coroutine functions in non-suspend mode (i.e.
  suspend flag is either false or skipped).
* When passing continuation from suspend function to suspend function.

Use facade only for corresponding intrinsics.
Reason: interceptor should not be called on each suspend function
invocation, it should be called after resume from innermost
suspend function.

Fix KT-17067. The example provided with the issue is very similar to
dispatchResume.kt which passes after these changes.

Add test to prove that KT-17446 is no more reproducible.
2017-04-18 11:22:18 +03:00
Mikhael Bogdanov 708bfdbd5f Generate line numbers for function call parameters
Before this fix line numbers for function call arguments were not generated,
 so if argument was on another line than function call it was
 impossible to stop on argument line during debugging.
 Now line number for each argument is generated if necessary
 (another line than function call line).

 #KT-17144 Fixed
2017-04-17 16:09:59 +02:00
Mikhail Zarechenskiy b17b3f4c63 Resolve local function parameters with function inner scope
This allows to use type parameters and value paramters in default value expressions

 #KT-7984 Fixed
 #KT-7985 Fixed
2017-04-17 16:21:06 +03:00
Mikhail Zarechenskiy e86d52b681 Fix return type of private members that return anonymous object
#KT-16813 Fixed

Anonymous objects returned from private-in-file members should behave as for private class members
2017-04-17 16:21:05 +03:00
Mikhail Zarechenskiy 1fbd8f3f53 Support automatic labeling for infix calls
#KT-8877 Fixed
2017-04-17 16:21:03 +03:00
Mikhail Zarechenskiy 6a352bccb6 Resolve control label locally when label name clashes with fun name
#KT-5354 Fixed
 #KT-15085 Fixed
2017-04-17 16:21:02 +03:00
Alexey Andreev 5c1882bfcc Unmute test that passes 2017-04-13 17:33:15 +03:00
Alexey Andreev 43c084fde3 Simplify coroutine generation in JS backend
Stop making aliasing suspend function descriptor with reference to
instance of state machine. This may cause problems in some cases,
for example, when compiling recursive suspend function. See KT-17281.
Instead, make alias for synthetic continuation parameter. This
additionally required some refactoring, e.g. *always* generating
continuation parameter during codegen.
2017-04-13 12:56:34 +03:00
Mikhael Bogdanov b51cb9a911 Delete clean reference instructions on dereferencing captured variables
Codegen generates clean instructions for ref values (captured vars)
on block exit so we should delete them on dereferencing captured values.

  #KT-17200 FIXED
2017-04-10 16:35:03 +05:00
Mikhail Zarechenskiy 682fe9e9ca Don't forget to resolve annotations from constructor parameter
#KT-12245 Fixed
2017-04-10 12:48:10 +03:00
Mikhail Zarechenskiy c9b468581a Fix type checking of local return inside return expression
#KT-16426 Fixed
2017-04-10 12:48:09 +03:00
Mikhail Zarechenskiy 9fdd5fe5e8 Allow to import private members if they are in the same file
#KT-7724 Fixed
2017-04-05 21:35:06 +03:00
Alexander Udalov 93d5f6e635 Fix NPE on equals/hashCode of local function references
Anonymous classes for local function references implement their
getOwner() as "return null" currently (KT-14291). To avoid NPE in this
case, we now consider two local functions the same if their name and
signature are equal. This is incorrect in general, but unlikely to cause
major problems and is going to be fixed by KT-14291 eventually anyway

 #KT-17055
2017-04-03 18:05:04 +03:00