Commit Graph

465 Commits

Author SHA1 Message Date
Jinseong Jeon 82ef6bf96c FIR2IR: honor user-contributed members in data class if any 2020-06-18 14:23:52 +03:00
Dmitry Petrov 4739adb6dc KT-36992 Do not generate annotations on synthetic accessors
Also, do not generate nullability annotations on synthetic methods.
2020-06-17 23:54:51 +03:00
Victor Petukhov 447308dcfc Revert "Revert "Revert "Completely rewrite reifiedIntTypeAnalysis, making it more streamline"""
This reverts commit 5567033b
2020-06-17 13:02:40 +03:00
Ilmir Usmanov 1cccceabb9 Revert "Fix merging two reference values"
This reverts commit 85e2392f
2020-06-17 13:02:40 +03:00
Ilmir Usmanov 85e2392fef Fix merging two reference values
In this case, make the result of value type Object instead of unknown.
2020-06-09 20:52:29 +02:00
Ilmir Usmanov 5567033b33 Revert "Revert "Completely rewrite reifiedIntTypeAnalysis, making it more streamline""
This reverts commit 822c14814b.
2020-06-09 20:52:24 +02:00
Mark Punzalan 802beb49a6 Use TypeSubstitutor to get the substituted underlying type for inline
classes, instead of MemberScope.

The primary motivation was to fix issues around type-mapping for inline
classes in FIR, which uses wrapped descriptors that have empty
MemberScopes.
2020-06-04 17:03:55 +03:00
Ilmir Usmanov 822c14814b Revert "Completely rewrite reifiedIntTypeAnalysis, making it more streamline"
This reverts commit 1ed4324613.

Otherwise, bootstrap is broken.
2020-06-03 19:43:59 +02:00
Ilmir Usmanov 1ed4324613 Completely rewrite reifiedIntTypeAnalysis, making it more streamline
and easy to understand and optimize if it would be a bottleneck.
Use LVT to get information of refined int type in one specific case

 #KT-38925 Fixed
2020-06-03 16:03:50 +02:00
Mikhail Glukhikh 85760770a8 [FIR2IR] Initialize built-in symbols at start of conversion 2020-05-28 22:18:20 +03:00
Steven Schäfer dc0ef996b7 JVM IR: Implement the new inline class ABI 2020-05-28 18:00:35 +03:00
Vitaly fe047f9b47 [JS BE] mutes tests for JS_IR_ES6, which muted for JS_IR 2020-05-27 00:32:56 +03:00
Mikhail Zarechenskiy 8bdc4d34f7 [NI] Commonize type-conversions (SAM/Suspend)
- Allow participating subtypes of functional types in conversions
 - Fix several subtle inconsistencies
 - Place logic about conversions at one place

 Now conversions operations have two stages: before usual subtyping
 check and after one. This is needed to support conversions of
 subtypes (of functional types, for example). First, the compiler
 checks if it possible to resolve an argument without conversion and
 only then it tries to perform conversion.
 Note that it'd be incorrect to perform conversion eagerly as it can
 change resolve (Runnable & () -> Unit <: KRunnable), plus we can't
 guess whether conversion is needed at all as it's important not to
 look into supertypes if resolution doesn't actually needed it

 #KT-36448 Fixed
 #KT-37574 Fixed
 #KT-38604 Fixed
2020-05-20 15:30:14 +03:00
Dmitry Petrov 16e7a42aea JVM: Fix line numbers in test 2020-05-20 07:19:30 +03:00
Dmitry Petrov e625bb375f Temporarily mute unsigned tests in JVM_IR and FIR 2020-05-20 07:19:30 +03:00
Mikhail Glukhikh cdac6157a9 [FIR2IR] Force loading Java SAM from external classes 2020-05-14 14:07:40 +03:00
Mikhail Glukhikh e7e80be34a [FIR2IR] Populate overridden symbols even for !isOverride
Before this commit we considered !isOverride as a sign that
function / field / accessor has no overridden symbols.
However, it's false for deserialized, because isOverride
is always false there.

This commit fixes 68 BB tests but breaks 25 BB tests (not yet muted)
2020-05-14 13:40:36 +03:00
pyos 8809abdbac JVM_IR: do not handle Nothing in suspend tail call bridges
Else they wouldn't be tail call, would they?
2020-05-13 05:54:37 -07:00
Ilmir Usmanov 0acaedef92 Fix attribute clash between STATIC_INLINE_CLASS_REPLACEMENT and original
Attributes are used to name continuation classes and are generated
before inline classes processing. During the processing, for override
functions in inlined classes, the compiler generates
STATIC_INLINE_CLASS_REPLACEMENT function with body of the override.
The override's body is replaced with delegating call to
STATIC_INLINE_CLASS_REPLACEMENT. However, since we need to keep the name
of the continuation class, we copy attributes from the override to
STATIC_INLINE_CLASS_REPLACEMENT. This leads to attribute clash during
AddContinuationLowering.
So, to fix the issue, do not use the attribute of
STATIC_INLINE_CLASS_REPLACEMENT in original->suspend map.
As an optimization, do not generate continuation for the override
function.
2020-05-13 14:53:37 +02:00
Jinseong Jeon fd584e6f13 FIR2IR: fix offsets for calls. 2020-05-09 21:11:40 +03:00
Mikhail Glukhikh f3e2dbf360 [FIR2IR] Add conversion of function annotations 2020-05-08 17:30:19 +03:00
Mikhail Glukhikh d8f9643650 [FIR2IR] Use intersection type approximation for receivers 2020-05-07 15:27:17 +03:00
Jinseong Jeon 0c7ed04260 FIR: make (K)SuspendFunctionX derived from (K)Function 2020-05-06 13:09:32 +03:00
Jinseong Jeon 9a561f4a7c FIR2IR: generate synthetic members for inline class 2020-04-30 13:09:53 +03:00
Jinseong Jeon a084c5bf7d FIR2IR: populate overriddenSymbols for overriding properties 2020-04-30 12:25:48 +03:00
Dmitry Petrov d9fd51c608 JVM_IR: basic suspend conversion on argument test passed 2020-04-29 18:28:05 +03:00
Mikhail Glukhikh c6c848f929 Introduce & use FirJvmSerializerExtension & FirBasedClassCodegen
#KT-38156 In Process
2020-04-28 07:34:56 +03:00
Jinseong Jeon ef09850df8 FIR2IR: set superQualifierSymbol for super call 2020-04-27 11:50:26 +03:00
Jinseong Jeon 57fe01c375 FIR2IR: populate overriddenSymbols for overriding functions
#KT-38416 Fixed
2020-04-27 11:50:24 +03:00
Jinseong Jeon 39e1635c41 [FIR2IR] Pre-cache original function type parameters for fake overrides 2020-04-23 17:19:44 +03:00
Mikhail Glukhikh 4bb6410ce3 [FIR TEST] Temporary ignore overrideDefaultArgument test (KT-38416)
This test enters an infinite loop and can't finish
2020-04-20 17:05:35 +03:00
Mikhail Glukhikh aada7bfe51 FIR: handle suspend functions in callable reference resolve properly 2020-04-20 17:05:31 +03:00
Jinseong Jeon c26adf53dd FIR: resolve suspend lambda properly 2020-04-20 17:05:30 +03:00
Dmitry Petrov 9615b20e5d Box inline class return value in lambdas (including suspend lambdas) 2020-04-08 19:56:26 +03:00
Dmitry Petrov 0c21d63290 Box inline class return value in covariant override of suspend fun 2020-04-08 10:50:58 +03:00
pyos 82899e6243 JVM_IR: reuse MethodNodes for inline functions in same module
This fixes the weird cases when a class gets overwritten by an imperfect
copy, reduces the number of classes in the output if an inline function
contains an inline call that causes it to have regenerated anonymous
objects, and makes inlining of same module functions a bit faster in
general. On the other hand, this may increase memory footprint a bit
because classes cannot be flushed to the output jar, as the inliner
would not be able to locate classes for anonymous objects if they have
already been unloaded from memory.
2020-04-08 07:04:16 +02:00
pyos c650c9570f JVM: use conditional suspension point markers 2020-04-07 15:42:41 +02:00
pyos 5ed845d0b4 JVM_IR: reuse same bodies for suspend funs and $$forInline versions 2020-04-03 19:51:45 +02:00
Mikhail Zarechenskiy 38a719cb22 [NI] Fix trace manipulations for builder inference and ::-expressions
For a class literal Type::class we are resolving Type as a constructor,
 getting all diagnostics (about missing arguments, for example) and then
 just not committing this trace with errors

 #KT-37626 Fixed
2020-03-31 15:50:58 +03:00
Dmitry Petrov 042424d599 KT-27524 Don't box (some) inline classes in suspend fun return
If an inline class is mapped to a reference type (or an array), it's Ok
to treat JVM view on a suspend function as returning a value of
corresponding inline class (although in reality it returns 'Any?'
because of COROUTINE_SUSPENDED).
2020-03-27 18:29:36 +03:00
pyos ac6036f366 JVM_IR: move state machine generation to ClassCodegen 2020-03-23 12:23:17 +01:00
Georgy Bronnikov 4742057b51 IR: generate lambdas in place in Psi2Ir
even when arguments are to be rearranged.
Lambdas have no side effects, and storing them in temporary variables
prevents processing in the backend
(such as inserting continuation parameter in AddContinuationLowering).
2020-03-23 11:09:30 +03:00
Mikhail Bogdanov bc214868ef Minor. Clean tests 2020-03-19 16:45:10 +01:00
Mikhail Glukhikh 0f0e5e603d [FIR2IR] Use IR built-in types, their symbols & constructors directly 2020-03-18 17:09:36 +03:00
pyos 2c06503311 JVM_IR: partially fix inline methods using captured crossinline lambdas
The fields containing crossinline lambdas should be package-private to
avoid generating synthetic accessors, which break object regeneration.

Note that the inline methods cannot actually be called, as call sites
will attempt to read the captured lambda from a field through a *copy*
of the local containing the object, so these reads will not be inlined,
causing an exception at runtime:

    inline fun f(crossinline g: () -> Unit) = object : I {
        inline fun h() = g()
        // effectively `val tmp = this; return tmp.$g()`:
        override fun run() = h()
    }

    f {}.run() // NoSuchFieldError: $g

This particular example can be fixed by reusing locals for receiver
parameters in IrInlineCodegen, but explicitly assigning `this` to
another variable and calling an inline method on it will break it again.
(This is only applicable to the JVM_IR backend, as the non-IR one fails
to generate `f` at all for some other reason.)
2020-03-18 13:13:54 +01:00
Mikhail Glukhikh 20c4a7b244 [FIR2IR] Introduce staged transformation (first step)
Now FE IR -> BE IR transformation is performed in multiple stages
controller by Fir2IrConverter. Stages are
 * files & classes registration
 * supertypes & type parameters handling
 * functions & properties signature generation
 * body generation

After each step we have guarantee (with exception of local classes &
type inference combination, and external symbols) that required symbols
(class/function/property/variable/type parameter)
are already bound to real declarations and have correct parents.

This commit also fixes incorrect parents for local classes
2020-03-13 12:18:02 +03:00
pyos 735fae0e5a JVM_IR: apply TailCallOptimizationLowering to all suspend functions
Even if a function is known to be tail call because it's a compiler
generated bridge, the tail return might still need to be added in case
of Unit return type.
2020-03-09 19:21:32 +01:00
Steven Schäfer bb5a639153 JVM IR: Turn static callable references into singletons 2020-03-05 22:19:53 +03:00
Ilmir Usmanov 354fb3c4ba JVM_IR: Generate fake continuations and their constructors as public
#KT-37093 Fixed
2020-03-04 21:32:35 +01:00
Ilmir Usmanov c94f8d3767 JVM_IR: Do not generate nullability annotation for synthetic result field
of continuation class.
 #KT-37084 Fixed
2020-03-04 21:32:34 +01:00