Commit Graph

2482 Commits

Author SHA1 Message Date
Alexey Andreev dde50a34db Fix comparison of boolean values in JS BE
See KT-16984
2017-05-26 18:26:08 +03:00
Mikhael Bogdanov 3f7bf8467a Process non-aload0 outer access in constructor during inline
#KT-17972 Fixed
2017-05-26 09:24:10 +02:00
Mikhail Zarechenskiy d0e26c6527 Support underscores in non local destructuring declarations 2017-05-25 16:46:06 +03:00
Mikhail Zarechenskiy 47f2386212 Generate non-local destructuring declarations as properties
#KT-5620 Fixed
 #KT-15810 Fixed
2017-05-25 16:46:05 +03:00
Alexey Andreev 0e31c14a86 Implement inlining of default parameters in JS BE
Fix KT-17910
2017-05-25 14:38:53 +03:00
Dmitry Petrov 7600b6de52 Allow top-level type aliases in scripts 2017-05-24 11:20:22 +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 39aa97eebf Use Intrinsics#compare when specializing compareTo for ints 2017-05-22 11:57:20 +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
Mikhael Bogdanov 511c9f86b1 Add new test on receiver clash during default lambda inlining 2017-05-18 18:18:15 +02:00
Mikhael Bogdanov ec23df1d29 Extract callable reference tests to separate directory 2017-05-18 18:18:15 +02:00
Mikhael Bogdanov f4a388cf71 Add new tests for default lambda inlining 2017-05-18 18:18:14 +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
Mikhael Bogdanov d9dc2bd443 Minor. Fix review remarks 2017-05-17 10:20:04 +02:00
Mikhael Bogdanov fd561c6cb9 Support default bound callable reference inlining
#KT-6884 Fixed
2017-05-17 10:20:03 +02:00
Mikhael Bogdanov 05d2aa700b Support default property reference inlining 2017-05-17 10:19:55 +02:00
Mikhael Bogdanov a96fada230 Switch tests for default lambda inlining on language level 1.2 2017-05-17 10:19:55 +02:00
Mikhael Bogdanov 0ac23c789e Add diagnostics for default lambda inlining 2017-05-17 10:19:54 +02:00
Mikhael Bogdanov 6730fa2bbf Support default inline lambda reification 2017-05-17 10:19:51 +02:00
Mikhael Bogdanov 309051bd21 Obtain reification marker on default lambda extraction.
Add reification tests.
2017-05-17 10:19:44 +02:00
Mikhael Bogdanov 3e50203283 Add source mapping tests for default lambda inlining 2017-05-17 10:19:42 +02:00
Dmitry Petrov 899ad7bb53 Generate for-in-indices as a precondition loop
Precondition loops are better optimized by HotSpot
(and, quite likely, by ART).
Also, we generate more compact bytecode that way.

KT-17903 Generate 'for-in-indices' as a precondition loop
2017-05-16 17:28:43 +03:00
Dmitry Petrov 84e54124a2 More aggressive DCE should honor debugger invariants
- A LINENUMEBER node is "dead" if the corresponding instruction interval
 contains at least one "dead" bytecode instruction
 and no live bytecode instructions

- Observable local variable lifetimes should be taken into account
 when determining if a NOP is required for debugger.
2017-05-16 17:28:43 +03:00
Dmitry Petrov 65799a5cb4 Fix debugger-related tests after dead code elimination improvements 2017-05-16 17:28:43 +03:00
Dmitry Petrov 1378b0cf05 Fix bytecode tests after new optimizations
- Turn some const conditions into non-const conditions
- Make sure inlined const values are used where required
(otherwise they are eliminated by POP backward propagation)
2017-05-16 17:28:43 +03:00
Dmitry Petrov 2051355d6a Optimize constant conditions
Using basic constant propagation (only integer constants, no arithmetic
calculations), rewrite conditional jump instructions with constant
arguments.

This covers problem description in KT-17007.
Note that it also works transparently with inline functions.
Partial evaluation is required to cover more "advanced" cases.

As a side effect, this also covers KT-3098:
rewrite IF_ICMP<cmp_op>(x, 0) to IF<cmp0_op>(x).
2017-05-16 17:28:43 +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
Mikhael Bogdanov 97bcf9f538 Add default lambda inlining prototype 2017-05-11 11:06:47 +02: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 b3f66c7641 Remove $ character from fake continuation parameter
The reason is that when it gets captured into the field
having name $$continuation inliner fails with an exception
as it skips fields starting with '$$'

At the same time it doesn't really matter how to call
that parameter because it's only visible in Java

 #KT-17585 In Progress
 #KT-16603 In Progress
2017-05-05 14:14:37 +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
Mikhael Bogdanov 84eeed51b1 Restore accidentally removed parameter index passing to call generator
Parameter index was removed in
 7690a8bc3e commit:
 "Get rid of redundant 'afterParameterPut' method from call generators"

  #KT-17653 Fixed
2017-05-03 12:56:15 +02:00
Igor Chevdar 962bce19a2 Enabled tests on coroutines for native 2017-05-03 10:42:07 +03:00
Mikhael Bogdanov a7c9e14805 Don't generate default arguments for inline call 2017-04-28 12:19:09 +02:00
Mikhael Bogdanov 02cc5f6bc1 Expand default parameters conditions on inlining default function
#KT-14564 Fixed
 #KT-10848 Fixed
 #KT-12497 Fixed
2017-04-28 12:19:07 +02: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
Ilya Gorbunov 99504eb753 Support rendering receiver parameters
Otherwise generated coroutine implementation class could not be rendered since one of its members corresponds to receiver parameter descriptor.
2017-04-27 16:38:25 +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