Commit Graph

4068 Commits

Author SHA1 Message Date
Mikhael Bogdanov f795f2777c Rename FieldRemapper.java to FieldRemapper.kt 2017-05-17 10:19:58 +02:00
Mikhael Bogdanov e86e128c8a Code clean after convertion 2017-05-17 10:19:58 +02:00
Mikhael Bogdanov fcd76e6dec Convert InlinedLambdaRemapper to Kotlin 2017-05-17 10:19:57 +02:00
Mikhael Bogdanov d1fdfd484b Rename InlinedLambdaRemapper.java to InlinedLambdaRemapper.kt 2017-05-17 10:19:56 +02:00
Mikhael Bogdanov 05d2aa700b Support default property reference inlining 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 81c2e1dd8c Code clean after convertion 2017-05-17 10:19:53 +02:00
Mikhael Bogdanov 6373c3115a Convert LocalVarRemapper to Kotlin 2017-05-17 10:19:52 +02:00
Mikhael Bogdanov c6189076cc Rename LocalVarRemapper.java to LocalVarRemapper.kt 2017-05-17 10:19:51 +02:00
Mikhael Bogdanov 6730fa2bbf Support default inline lambda reification 2017-05-17 10:19:51 +02:00
Mikhael Bogdanov 9e8495dc3d Clean code 2017-05-17 10:19:50 +02:00
Mikhael Bogdanov 45bfb2075d Move reifiedTypeInliner to root context 2017-05-17 10:19:49 +02:00
Mikhael Bogdanov da13ea4a8a Move all InliningContext's to one place 2017-05-17 10:19:48 +02:00
Mikhael Bogdanov 9fdd4c647a Clean code. Add LambdaInfo to InliningContext 2017-05-17 10:19:48 +02:00
Mikhael Bogdanov 9dae183e3a Convert RootInliningContext.java to Kotlin 2017-05-17 10:19:47 +02:00
Mikhael Bogdanov 8b2164e2b8 Code clean after transformation 2017-05-17 10:19:46 +02:00
Mikhael Bogdanov fcbd27fdc4 Convert InliningContext.java to Kotlin 2017-05-17 10:19:45 +02:00
Mikhael Bogdanov 04cf5d49d6 Rename InliningContext.java to InliningContext.kt 2017-05-17 10:19:45 +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
Pavel V. Talanov 798c80ed07 Use wrappers around java.util.* to emulate kotlin.collection.* behaviour
Backend: If kotlin class extends kotlin.collection.List
    write it as it's super interface (light class mode only)
IDE: Provide wrapper classes to java resolve
    that try to emulate backend behaviour

For example if kotlin class implements kotlin.collections.Map,
    we provide a superinterface that has abstract 'getEntries' method
    and 'entrySet' method that is considered default.
In reality all those methods are generated in the class itself.

In IDE supporting this case without hacks is not feasible performance-wise
    since kotlin.collection.* may not be an immediate supertype and we need
    to compute all supertypes just to calculate own methods of the class
2017-05-16 22:01:03 +03:00
Pavel V. Talanov c56f74cc81 Do not generate bridge and stub methods in light class mode 2017-05-16 22:01:02 +03:00
Pavel V. Talanov 4bdfb8c646 Jvm backend: specify declaration origin of generated methods
Allow to distinguish collection stub methods and augmented kotlin api methods
2017-05-16 22:01:01 +03:00
Pavel V. Talanov eb3c20d630 Refactor constructing KOTLIN_MARKER_INTERFACES map 2017-05-16 22:01:00 +03:00
Pavel V. Talanov 40561dabed J2K JavaToKotlinClassMap 2017-05-16 22:00:58 +03: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 793fb65666 Introduce AbstractForInExclusiveRangeLoopGenerator 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 fe7870a1cd Minor: RedundantCoercionToUnit -> PopBackwardPropagation
It is actually more meaningful than just "coercion to unit elision":
it removes instructions without side effects with results that are
unused (popped from the stack).
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
Dmitry Petrov 55498b7f63 Minor: move around some optimization-related classes 2017-05-16 17:28:43 +03:00
Dmitry Petrov 847f889a0a Allow merging tracked values in ReferenceTrackingInterpreter subclasses
This is required for things like detupling.
2017-05-16 17:28:43 +03:00
Dmitry Petrov b445e0a049 Drop old null check optimizer 2017-05-16 17:28:43 +03:00
Dmitry Petrov 689298b11f CompositeMethodTransformer 2017-05-16 17:28:43 +03:00
Dmitry Petrov 0dbf383ce8 OptimizationMethodVisitor: convert to Kotlin 2017-05-16 17:28:43 +03:00
Dmitry Petrov a3a60db926 OptimizationMethodVisitor: .java -> .kt 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
Denis Zharkov dcaad530ce Make code generation in method transformer more stable
Do not mix references to label nodes and common ASM labels
as it may lead to different LabelNode instance (not defaultLabel)
being inserted into insns list

It's been working before because there was no `resetLabels` call
on insnList, and label/label nodes were bound to each other
2017-05-16 11:38:59 +03:00
Denis Zharkov 4033786902 Minor. Drop always-false parameter in fix-stack utils 2017-05-16 11:38:59 +03:00
Denis Zharkov d362fa6eea Minor. Use trailing lambda syntax in FixStackMethodTransformer 2017-05-16 11:38:59 +03:00
Mikhael Bogdanov 97bcf9f538 Add default lambda inlining prototype 2017-05-11 11:06:47 +02:00
Mikhael Bogdanov daf6768181 Add proper DefaultLambda initialization,
patch lambda related instructions in default method

Remove default lambda linked instructions from default method
2017-05-11 11:06:46 +02:00
Mikhael Bogdanov ec066a06d8 Clean code after convertion to Kotlin 2017-05-11 11:06:45 +02:00
Mikhael Bogdanov 1e9ffe42b1 Convert MethodInliner.java to Kotlin 2017-05-11 11:06:44 +02:00
Mikhael Bogdanov e34f934aba Rename MethodInliner.java to MethodInliner.kt 2017-05-11 11:06:44 +02:00
Mikhael Bogdanov f915192827 Minor. Clean and refactoring after convertion 2017-05-11 11:06:43 +02:00
Mikhael Bogdanov 3fe152aad3 Convert AnonymousObjectTransformer.java to Kotlin 2017-05-11 11:06:42 +02:00
Mikhael Bogdanov 36c43b630e Rename AnonymousObjectTransformer.java to AnonymousObjectTransformer.kt 2017-05-11 11:06:41 +02:00