Commit Graph

2876 Commits

Author SHA1 Message Date
Mikhail Zarechenskiy 4af8833f08 Render unwrapped suspend function in backend
Hierarchy of specially wrapped suspend function may have inconsistent
 overridden descriptors: some of them may be wrapped, some unwrapped.
 To mitigate this problem, currently it's proposed to render only
 unwrapped functions, which are always have stable overridden descriptors

 #KT-23809 Fixed
2018-04-17 16:24:13 +03:00
Alexander Udalov 30b9caeae6 Fix NPE in data class 'equals' codegen
Do not perform the optimization from 0a11385006 for data class
properties of nullable types
2018-04-12 22:19:30 +02:00
Dmitry Petrov 7cf6c70fbf Use NoScopeRecordCliBindingTrace as default trace in GenerationUtils
NB we use 'Intrinsics.areEqual(Double, Double)' and
'Intrinsics.areEqual(Float, Float)', because right now we take
nullability from the inferred type of the expression (which is 'Any?' in
the test cases).
We should probably reconsider this in case of more exact information
available from the data flow analysis, e.g., in case of

  fun test(x: Any?) =
    x is Serializable && x is Double? && x == 0.0

We statically know that 'x' is not null in 'x == 0.0' (although it's
neither nullability of it's numeric type 'Double?' nor the nullability
of the inferred type 'Any?').

There might be some edge effects in the performance related to byte code
size and preventive unboxing and so on.
2018-04-11 10:49:02 +03:00
Ilmir Usmanov 2cfe387bab Move coroutines to kotlin.coroutines package: compiler
Generate continuation type as kotlin.coroutines.Continuaion. This code will
fail at runtime since there is no stdlib backing this change yet.
However, in order to generate compatible stdlib we need a compiler, which
generates continuation type as kotlin.coroutines.Continuation.
Thus, firstly we support the change in the compiler, make it bootstrap
compiler and only then change stdlib and tests accordingly.
 #KT-23362
2018-04-10 22:51:46 +03:00
Anton Bannykh f8c0c54a66 Revert "Clean up test skips after KT-17137"
This reverts commit 715d5e9
2018-04-10 20:45:07 +03:00
Ilmir Usmanov eb3b9032d6 Add synthetic flag to generated private suspend functions
Private suspend functions need to be generated as package-local, since
they are called from their continuations.
However, this means that they can be called from Java, which breaks
their private visibility.
Adding synthetic to them fixes the issue.
 #KT-17584: Fixed
2018-04-10 17:25:12 +03:00
Yan Zhulanow 95684b9ecb Minor: Fix codegen tests for smap 2018-04-09 19:45:49 +03:00
Mikaël Peltier 0a11385006 KT-12330 Improve bytecode for data class equals/hashCode methods
- Do not longer call hashCode on java/lang/Object but do this
on statically checked type.
- Do not longer call Intrinsics.areEqual but use directly
equals method on statically checked type.

Fix of https://youtrack.jetbrains.com/issue/KT-12330
2018-04-09 14:16:02 +02:00
Ilmir Usmanov bd0ad26dcf Support local suspend functions
Treat them like lambdas. This means:
1) Like local suspend lambdas, which become "non-suspend" after creating
jvmSuspendView, they do this as well
2) They both are generated with the same codegen.
3) They are treated differently only on front-end side.
 #KT-20364: Fixed
2018-04-06 19:11:19 +03:00
Mikhael Bogdanov 08ff1de248 Update test data 2018-04-03 19:38:37 +02:00
Mikhael Bogdanov 38f8924ae3 Update test data. Use simple ''@JvmDefault' instead full qualifier 2018-04-03 19:18:15 +02:00
Mikhael Bogdanov 2a8041e77e Check method abstractness during bridge generation per method not interface 2018-04-03 19:18:14 +02:00
Mikhael Bogdanov f290b325ee Remove @JvmDefault members from delegation 2018-04-03 19:18:14 +02:00
Mikhael Bogdanov d84a15c0f6 Support inline for private @JvmDefault members 2018-04-03 19:18:13 +02:00
Mikhael Bogdanov 308283e52e Support synthetic accessors for @JvmDefault members 2018-04-03 19:18:12 +02:00
Mikhael Bogdanov fe45eb2a81 Initial support of @JvmDefault 2018-04-03 19:18:09 +02:00
Mikhael Bogdanov c143480727 Remove wrong directive
Similar test exists under 'defaults' foldes
2018-04-03 19:18:07 +02:00
Ilmir Usmanov eb81c205c7 Replace CHECKCAST kotlin/Unit with ARETURN for tail call optimization
Sometimes instead of {POP, GETSTATIC Unit.INSTANCE, ARETURN} sequence
the codegen emits {CHECKCAST Unit, ARETURN} sequence, which breaks tail
call optimization. By replacing CHECKCAST with ARETURN we eliminate
this issue.

 #KT-19790: Fixed
2018-04-03 20:04:18 +03:00
Ilmir Usmanov 7b2de2de5e Add regression test for KT-20744
#KT-20744: Obsolete
2018-04-03 20:02:02 +03:00
Yan Zhulanow eec9c6bffa Debugger: Fix breakpoints and stepping for inline-only function lambda arguments (#KT-23064) 2018-04-02 19:14:14 +03:00
Mikhail Zarechenskiy 0632bbbed0 Nullability of intersection type should be determined by supertypes
Intersection types cannot be nullable as is because of special rules for subtyping
2018-03-30 14:51:07 +03:00
Mikhail Zarechenskiy aebcb61402 Resolve elements in chain of qualifier expression without expected type
Consider call chain `foo.bar.baz()` which has expected type `Int`
Elements `foo` and `bar` doesn't have expected type `Int`,
this is especially important in NI, because we use expected type for
candidate applicability
2018-03-30 14:51:07 +03:00
Zalim Bashorov 9349b9bc67 [JS BE] Fix the crash on compound operations with a qualified call on left side
#KT-22001 Fixed
2018-03-28 22:49:09 +03:00
Ilmir Usmanov 4070f13e26 Do not generate beforeInlineMarker on tailrec jump
Before this change, the codegen used to generate beforeInlineMarker
in order to spill variables later. However, since the tailrec call
is replaced with jump, no afterInlineMarker is generated, leading to
inconsistency of these markers. Thus, the spilling fails.
This change disables generating of beforeInlineMarker.

 #KT-21521: Fixed
2018-03-28 15:50:24 +03:00
Ilmir Usmanov 58bac6882d Fix transforming of coroutine's create when it is suspend lambda with receiver
Unlike ordinary lambdas suspend lambdas has create method which invokes
the constructor of the lambda object (continuation).
The inliner could not cope with this.
The previous change fixed the case of suspend lambda without receiver.
This change adds support of suspend lambdas with receiver.

 #KT-21605: Fixed
2018-03-28 15:48:16 +03:00
Anton Bannykh d0e71acaa5 JS: fix NaN bug workaround 2018-03-26 20:07:00 +03:00
Anton Bannykh 3a7518cad2 Implemented equality comparison for primitive types 2018-03-26 20:07:00 +03:00
Mikaël Peltier 3a50d0d78f KT-22063 Add intrinsics for javaObjectType and javaPrimitiveType
Fix of https://youtrack.jetbrains.com/issue/KT-22063
2018-03-26 15:52:19 +02:00
Mikhail Zarechenskiy 3dde31729e [NI] Record information about delegated property as in old inference 2018-03-25 20:22:37 +03:00
Ilmir Usmanov 481dbee96a Do not ignore copy operations while finding source instructions
in redundant locals elimination.

Since IgnoringCopySourceInterpreter ignores ALOADs and ASTOREs,
the source instruction of ALOAD K in {ALOAD N, ASTORE K, ALOAD K}
sequence is not ASTORE K. In this case we cannot simply replace K
with N, since there can be multiple {ALOAD N, ASTORE K} sequences
in separate branches. After replacement we get different stack
frames.
This change resolves this.

However, in ReturnUnitMethodTransformer we want to ignore copies
of the same GETSTATIC kotlin/Unit.INSTANCE, since we do not mess
with local variables and just replace ASTORE with ARETURN to help
tail-call optimization.
 #KT-23373: Fixed
2018-03-23 14:32:48 +03:00
Ilmir Usmanov bd7ad8c9d5 Raise deprecation level to ERROR of coroutineContext
inside kotlin.coroutines.experimental.intrinsics package
 #KT-22400
2018-03-22 22:12:27 +03:00
Roman Artemev a121a4a6b2 Added test to check default params in declaration (issue KT-23239) 2018-03-21 12:44:24 +03:00
Ilmir Usmanov 826d667398 Remove redundant locals
Do not transform already transformed suspend lambdas
Ignore duplicates of continuation in local variable table during redundant locals elimination.
2018-03-16 16:26:14 +03:00
Ilmir Usmanov 81f3e39f29 Do not generate ACONST_NULL as continuation of crossinline suspend lambda 2018-03-16 16:26:13 +03:00
Ilmir Usmanov 6854135077 Support crossinline suspend lambda as parameter of inline function
Use fake continuation instead of ALOAD 0 while inlining
Do not generate state machine for inner lambdas and inner objects,
which capture crossinline suspend lambda.

 #KT-19159: Fixed
2018-03-16 16:26:11 +03:00
Ilmir Usmanov e6a353e590 Remove returns unit markers in suspend lambdas 2018-03-16 16:26:09 +03:00
Ilmir Usmanov e169383f76 Fix problem with transforming suspend lambda instantiation by itself
#KT-21605: Fixed
2018-03-16 16:26:09 +03:00
Mikaël Peltier d0ed0c4049 KT-14258 Optimize accesses to properties defined into companion
- Use direct access to property defined into companion object when
it is possible rather than always use an accessor to access the
property.
- Use direct access will speedup runtime performance.
- Avoid to generate useless accessors for companion properties.

Fix of https://youtrack.jetbrains.com/issue/KT-14258
2018-03-14 15:30:40 +01:00
Dmitry Petrov d38258d7a0 Use specified comparison generator for chars in optimized ranges
Otherwise if Char value is a result of some erased generic call,
coercing it to I (primitive int) causes CCE at run-time.

 #KT-23104 Fixed Target versions 1.2.40
2018-03-13 09:34:10 +03:00
Mikhael Bogdanov c1c8660e55 Don't try to transform sam wrappers in same module
#KT-22304 Fixed
2018-03-08 11:50:08 +01:00
Ilmir Usmanov 07ec704228 Fix modifiers generation for companion objects
when language verion is 1.3

 #KT-23002: Fixed
2018-03-01 20:03:26 +03:00
Egor Neliuba 715d5e90ba Clean up test skips after KT-17137
We need to clean these up since primitive array `is` checks work now

(cherry picked from commit b413e9ef51606c51ebfb21bd7ff646b0fb75470a)
2018-03-01 14:26:13 +03:00
Anton Bannykh ed80252ba8 JS: fix double compareTo behaviour for NaN and +-0 (KT-22723) 2018-02-28 15:01:58 +03:00
Dmitry Petrov 8fbdf52d34 Chars are not promoted to Int on comparisons 2018-02-27 10:09:17 +03:00
Denis Zharkov 5a591be25f Convert SwitchCodegen to Kotlin, prettify and optimize codegen 2018-02-22 11:42:18 +03:00
Ilmir Usmanov 9fdd34ce6e Minor. Add regression test for KT-15930
#KT-15930: Obsolete
2018-02-21 19:32:50 +03:00
Mikhail Zarechenskiy f23b5103ec Avoid non-null assertions for inline classes based on nullable types
Note that there are more places where assertions for inline classes should refined:
  - lateinit vars
  - values that come from Java
  - type casts (interfaces to inline class type)
2018-02-20 14:41:48 +03:00
Mikhail Zarechenskiy 413e2d7fa1 Fix KotlinType of constructor call for inline classes 2018-02-20 11:58:18 +03:00
Mikhail Zarechenskiy 530dd01ca6 Fix unboxing values of inline class type from type parameters 2018-02-20 11:45:49 +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