Commit Graph

3012 Commits

Author SHA1 Message Date
Georgy Bronnikov 89aa15c419 JVM_IR: implement isCompiledToJvm8OrHigher on IrClass 2020-06-13 12:45:00 +03:00
Georgy Bronnikov 8037baf307 IR: add SourceElement reference to IrClass 2020-06-13 12:44:59 +03:00
Georgy Bronnikov 811e8d0f24 JVM_IR: remove one usage of descriptors from AnnotationCodegen 2020-06-13 12:44:59 +03:00
Georgy Bronnikov 58a9c0c996 JVM_IR: remove descriptor usage from IrTypeMapper 2020-06-13 12:44:59 +03:00
Alexander Udalov 2bf31ae3c3 IR: minor reformat of IdSignature 2020-06-11 21:42:45 +02:00
Alexander Udalov d8aee421ac IR: don't store isPublic as field in IdSignature 2020-06-11 21:42:44 +02:00
Alexander Udalov 3154eca218 IR: use String instead of FqName in IdSignature.PublicSignature
FqName/FqNameUnsafe tend to eagerly compute things like
safe/parent/shortName which take a lot of space.

This change helps to lower strongly reachable memory just before codegen
in JVM IR by about 5% on a relatively big project.
2020-06-11 21:42:44 +02:00
Alexander Udalov d24e136ba8 Minor, make IdSignature.PublicSignature not a data class 2020-06-11 21:42:44 +02:00
Igor Chevdar 66bbd3e102 [IR] Improved tuning of SAM wrapper visibility 2020-06-11 23:00:32 +05:00
Ilya Chernikov c720fa5793 Optimize LazyScopeAdapter internals 2020-06-11 16:16:14 +02:00
Alexander Udalov 6e67e1e78d Replace appendln with appendLine in project 2020-06-11 13:01:30 +02:00
Vasily Levchenko 25f0e38c73 [inliner] parent fix after copy
this change fix issue with inlining lambda in inline function which(function) inlined from other library.
E.g.

> cat i-lib.kt
class _special_class(val v:Int)
class _special_class1(val v:Int)

class __helper(val v:Int)

inline fun foo(h: __helper): Int {
    val sum = h.op {
        _special_class(it.v)
    }.v
    return sum
}

inline fun __helper.op(block:(_special_class1) -> _special_class) = block(_special_class1(v))

> cat i-main.kt
fun main() {
    val h = __helper(42)
    println(foo(h))
}

Here how the incorrect parent affects debug information:

(lldb) target create "program.kexe"
Current executable set to '/Users/minamoto/ws/kotlin-native/program.kexe' (x86_64).
(lldb) command source -s 0 'i-test.lldb'
Executing commands in '/Users/minamoto/ws/kotlin-native/i-test.lldb'.
(lldb) b i-lib.kt:8
Breakpoint 1: where = program.kexe`kfun:#main(){} + 435 [inlined] foo + 98 at i-main.kt:3, address = 0x00000001000540e3
(lldb) r
Process 70550 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x00000001000540e3 program.kexe`kfun:#main(){} [inlined] foo at i-lib.kt:9:7
   6       inline fun foo(h: __helper): Int {
   7           val sum = h.op {
   8               _special_class(it.v)
-> 9           }.v
              ^
   10          return sum
   11      }
   12
Target 0: (program.kexe) stopped.

the parent of lambda is i-main.kt instead of i-lib.kt, and offsets calculated against wrong file.
Here is behaviour with fix:

(lldb) target create "program.kexe"
Current executable set to '/Users/minamoto/ws/.git-trees/minamoto/debug-info/subprograms-with-missed-scopes/program.kexe' (x86_64).
(lldb) command source -s 0 '/Users/minamoto/ws/kotlin-native/i-test.lldb'
Executing commands in '/Users/minamoto/ws/kotlin-native/i-test.lldb'.
(lldb) b i-lib.kt:8
Breakpoint 1: where = program.kexe`kfun:#main(){} + 337 [inlined] <anonymous>_2 at i-lib.kt:14, address = 0x0000000100054bb1
(lldb) r
Process 70560 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x0000000100054bb1 program.kexe`kfun:#main(){} [inlined] <anonymous>_2 at i-lib.kt:8:24
   5
   6       inline fun foo(h: __helper): Int {
   7           val sum = h.op {
-> 8               _special_class(it.v)
                               ^
   9           }.v
   10          return sum
   11      }
Target 0: (program.kexe) stopped.
2020-06-10 14:29:13 +02:00
Mads Ager dc34d355bc [JVM_IR] Generate line numbers and nops for init blocks.
This seems to be what JVM does and it allows you to set a
breakpoint on the init line.
2020-06-10 08:05:52 +02:00
Alexander Udalov 6adad1055b JVM IR: generate delegates to DefaultImpls for fun interfaces 2020-06-09 11:49:45 +02:00
Alexander Udalov 77e479fda8 JVM IR: generate InnerClasses attribute for nested classes in annotation arguments
#KT-38853
2020-06-09 11:33:27 +02:00
Alexander Udalov 2793187bda Handle IllegalArgumentException in trimMargin intrinsics on JVM
#KT-38537 Fixed
2020-06-09 11:11:06 +02:00
Mikhail Glukhikh 261ed46341 IR metadata source: do not require descriptor in property metadata 2020-06-09 11:40:26 +03:00
Mikhail Glukhikh 5c6f40b34a IR metadata source: extract & use declaration name 2020-06-09 11:40:26 +03:00
Alexander Gorshenev ce1ef6c159 Fixing a bug with private accessors in IR fake override construction 2020-06-08 17:07:06 +03:00
Mikhail Glukhikh 6eab6a96cb [FIR2IR] Support type aliases properly 2020-06-08 16:19:37 +03:00
Mikhail Glukhikh 538535c3b7 [FIR2IR] Introduce & use declaration-based SymbolTable.enter(leave)Scope 2020-06-08 12:11:34 +03:00
Mikhail Glukhikh e593c7270f [FIR2IR] Use specific symbols for enum entries 2020-06-08 12:11:34 +03:00
Mikhail Glukhikh 7bd872b264 [FIR2IR] Restore container source related logic 2020-06-08 12:11:33 +03:00
Mikhail Glukhikh dc660e72e5 [IR] Don't store descriptor in IR function to allow lazy initialization 2020-06-08 12:11:32 +03:00
Mikhail Glukhikh de2980e9e5 [FIR2IR] Use specific symbols for class declarations 2020-06-08 12:11:32 +03:00
Mikhail Glukhikh 85801ea62c [FIR2IR] Use specific symbols for callable declarations 2020-06-08 12:11:32 +03:00
Roman Artemev 311b2d7969 [PLUGIN API] Make context provide information about target platform 2020-06-05 17:14:33 +03:00
Steven Schäfer 3291cf7a6e JVM IR: Mark lateinit fields as NotNull
This is needed for compatibility with the JVM backend.
2020-06-04 17:52:56 +02:00
Alexander Udalov 5647a935a2 JVM IR: do not generate DefaultImpls delegate for collection fake overrides
In the newly added test, prior to this change, JVM IR was generating
DefaultImpls classes with calls to things like
`kotlin/collections/MutableList$DefaultImpls.spliterator` and other
default methods present in JDK 8+. This obviously didn't make much
sense. Although these weren't explicitly mentioned anywhere in the
bytecode, they caused some validation tools to report errors (e.g.
animalsniffer used in arrow).
2020-06-04 14:27:46 +02:00
Georgy Bronnikov 0db02926f5 JVM_IR: remove descriptors from MethodSignatureMapper 2020-06-03 22:42:02 +03:00
Georgy Bronnikov 77c20066a8 JVM_IR: implement getJvmModuleNameForDeserialized in MethodSignatureMapper 2020-06-03 22:42:02 +03:00
Georgy Bronnikov 80afe42d17 JVM_IR: implement getJvmNameIfSpecial in MethodSignatureMapper 2020-06-03 22:42:02 +03:00
Roman Artemev 5eae262264 [PLUGIN API] Implement custom linkage for plugin extensions 2020-06-03 12:17:14 +03:00
Roman Artemev a401374ed4 [PLUGIN API] Add extension point to customize linkage process 2020-06-03 12:17:14 +03:00
Roman Artemev f9c2c846f7 [IR] Move IrProvider and 'IrDeserializer' into separate package 2020-06-03 12:17:14 +03:00
Svyatoslav Kuzmich e9e850ad8f [JS IR] Fix findInterfaceImplementation
isOrOverridesSynthesized uses descriptors which does not work with
wrapped descriptors
2020-06-03 10:47:15 +03:00
Svyatoslav Kuzmich f8fdb0dc7e [JS] Add ; after functions in .d.ts
Fixes nit from KT-37752
2020-06-03 10:33:46 +03:00
Svyatoslav Kuzmich 2ca751a9fc [JS] Prevent default class constructors in d.ts files.
Generate private TypeScript constructor for classes without public
primary Kotlin constructor.
2020-06-03 10:33:45 +03:00
Svyatoslav Kuzmich 695d383ed1 [JS] Support secondary constructors in JsExport 2020-06-03 10:33:45 +03:00
Mads Ager f128e5222a [JVM_IR] Fix line number information for try-catch.
In particular, the current line numbers could lead to stepping
into the catch handler even when the code in the try did not
throw an exception.

This was caused by the code materializing the final value having
the catch line number. This patch delays the materialization
until the line number of the usage has been emitted.
2020-06-03 07:33:21 +02:00
Dmitry Petrov 5efbe6ae15 PSI2IR: SAM conversion in varargs 2020-06-02 23:53:47 +03:00
Mikhail Glukhikh 8c422fbfc7 [FIR2IR] Use signature composer to read external callables 2020-06-02 18:47:58 +03:00
Mikhail Glukhikh a239604c24 Rename & make public: Collection.collect -> collectForMangler 2020-06-02 18:43:16 +03:00
Mikhail Glukhikh 05d160b130 Revert "IR linked: introduce IrElement.isExpectMember instead of descriptor use"
This reverts commit 4b47eb35
2020-06-02 16:14:27 +03:00
Igor Chevdar e41b5fc1c6 [IR] Turned on a test for K/N + minor refactoring
NothingValueException has already been supported in K/N
2020-06-02 14:50:17 +05:00
Leonid Startsev 02bd8cbd6b Use SYNTHETIC_OFFSET instead of UNDEFINED
because Native's debug information does not accept undefined offsets
2020-06-01 17:48:17 +03:00
Leonid Startsev 7c8c5b057f Extensible mechanism for plugin metadata during descriptor serialization
A mechanism that allows kotlinx.serialization plugin to preserve the
correct (program) order of properties after serializing/deserializing
descriptors to kotlin metadata, which is needed for correct and stable
json serialization of class hierarchies in incremental/multi-module scenario.
It uses protobuf extensions.
2020-06-01 17:48:16 +03:00
Dmitry Petrov 246c68b0a9 PSI2IR: Don't generate IMPLICIT_INTEGER_COERCION
Generate integer coercion function calls and properly typed constant
expressions instead.
2020-06-01 16:51:47 +03:00
Mikhail Zarechenskiy 0ab9b3639b Approximate types for lambda literals before serialization 2020-05-31 17:38:18 +03:00
Alexander Gorshenev a112f8acb6 Moved symbol table emptiness assertion to later places,
so that the assert doesn't trigger in the plugin context
2020-05-31 06:00:33 +03:00