Commit Graph

5077 Commits

Author SHA1 Message Date
Ilmir Usmanov d0a70e5cc0 Minor. Use safe cast in isStaticInlineClassReplacementDelegatingCall 2021-10-12 15:09:07 +02:00
pyos 226306ac83 IR: check whether local declarations need to throw after Nothing return
^KT-48982 Fixed
2021-10-12 15:09:05 +02:00
Dmitry Petrov b184c72e3d JVM_IR make proxy funs synthetic, fix some typos 2021-10-12 15:56:35 +03:00
Dmitry Petrov e0c2a2efd7 JVM_IR Minor: remove outdated TODO 2021-10-12 15:56:34 +03:00
Dmitry Petrov 005d3b1f6f JVM_IR pass reified type parameters in indy SAM conversion proxy 2021-10-12 15:56:33 +03:00
Dmitry Petrov 40fe67880b JVM_IR wrap function into a proxy if indy SAM-conversion becomes valid 2021-10-12 15:56:31 +03:00
Svyatoslav Kuzmich a6afb7cb41 [JS IR][Wasm] Preload (Suspend)FunctionN needed in lowerings
This reverts commit 15d178d850d15675ee39cbd833d13f4c8aed83ff.
2021-10-12 08:42:01 +03:00
Svyatoslav Kuzmich 3bce0cc055 [Wasm] Support coroutines
- Reuse JS IR Suspend function lowering
  - Fix types
  - Disable reinterpretCast-based optimization for inline
    classes
- Add basic support to Wasm stdlib
- Explicitly transform suspend functions into regular functions
  with continuations
- Clean suspend function handling from JS IR codegen
2021-10-12 08:42:01 +03:00
Svyatoslav Kuzmich e3f826d1b9 [Wasm] Handle IrClass::thisReceiver receiver outside of constructors 2021-10-12 08:42:01 +03:00
Svyatoslav Kuzmich bcab78599f [Wasm] Fix result of statically-know type operators
- Use subclass with erased types to match runtime behavior
- Handle casting to Nothing
2021-10-12 08:42:01 +03:00
Sergej Jaskiewicz 9ee8f1e961 [JS IR] Enable StringTrimLowering for JS IR backend 2021-10-11 15:57:53 +00:00
Ilya Goncharov b0aefd543a [JS IR] Fix offsets and add new test
[JS IR] Use TypeSubstitutor for full substitution of types

- adding new tests

[JS IR] Commonize context and use in wasm

[JS IR] Add test with receiver with callable reference

[JS IR] Add prerequisites around inlining and callable references

[JS IR] Review fixes

- Add test with bounded type parameter
- Remove redundant casts
- Use offsets for synth function
- Correct traversing

[JS IR] Not use origin for not inlined function reference

[JS IR] Move util into common place

[JS IR] Fix offsets

[JS IR] Add type parameter argument and using value in test

[JS IR] Wrap inlined callable references with reified parameters

[JS IR] Add test on callable reference inlined fun

Merge-request: KT-MR-4722
2021-10-11 09:02:08 +00:00
Georgy Bronnikov a9ce25cf33 JVM_IR: only serialize inline functions themselves with -Xserialize-ir=inline 2021-10-11 11:53:30 +03:00
Georgy Bronnikov 4caa71538d JVM_IR: introduce modes for IR serialization
Instead of a Boolean flag -Xserialize-ir, use modes: none,inline,all.
In "inline" mode, only information needed to deserialize bodies of inline
functions is serialized.
In the "all" mode, all declarations are serialized completely.
2021-10-11 11:53:29 +03:00
Dmitry Petrov 146f0f4904 JVM_IR KT-41214 emit PermittedSubclasses on JDK17+ 2021-10-09 17:07:35 +03:00
Artem Kobzar dca4a8e722 fix(KT-45056, KT-47516): use enum as an IR class instead of enum entity class. 2021-10-08 16:21:49 +00:00
Roman Artemev 5a64f64ba3 [KLIB] Propagate default arguments in expect-actual resolution
- refactor code a bit
 - fix KT-45542
2021-10-08 16:07:04 +03:00
Ilya Goncharov 669965d56c [JS IR] Generate main method call only for main module 2021-10-08 10:08:57 +00:00
Dmitry Petrov 27860ef008 JVM_IR KT-49136 don't optimize null checks on fields and calls 2021-10-08 08:55:24 +03:00
Svyatoslav Kuzmich 9ef899ef10 [Wasm] Reuse Callable reference and SAM lowerings from JS 2021-10-08 07:24:41 +03:00
Svyatoslav Kuzmich fbbd436e54 [Wasm] Log interfaces implementations ids in type info logging 2021-10-08 07:24:41 +03:00
Svyatoslav Kuzmich 1ed2748334 [Wasm] Generate [K][Suspend]FunctionN on demand and support big arity 2021-10-08 07:24:41 +03:00
Roman Artemev e6de812788 [IR] Implement checker for friendship of modules in fake override builder
- pass corresponding information to FO builder
 - implement check
 - fix KT-47192 and KT-48673
2021-10-07 16:00:49 +03:00
Ilya Goncharov a0fb60f201 [JS IR] Use label for continue loop in tailrec
^KT-46218 fixed
2021-10-06 18:40:34 +00:00
Dmitry Petrov 3d64c91375 PSI2IR KT-49053 skip fake overrides with unresolved types in signature 2021-10-06 16:23:08 +03:00
pyos 1c3a20fab9 JVM_IR: generate $suspendImpl in interfaces as public
The visibility was the cause of KT-44533; not generating `$suspendImpl`
at all makes `super` calls impossible.

^KT-49106 Fixed
2021-10-06 15:03:51 +02:00
Ilmir Usmanov 27081231d9 Use original instead of lowered function to retrieve toString-impl
in string concatenation lowering. Otherwise, inliner tries to get
body of already lowered function, failing.
 #KT-48284 Fixed
2021-10-06 11:12:26 +00:00
Sergej Jaskiewicz b93e0181ca [JS IR] Enable directives for IR box tests 2021-10-06 09:23:48 +00:00
Roman Artemev ba759fb61b [IR] Fix compatibility mode
- pass corresponding flag to mangler
 - properly handle local declarations in field initializers
 - fix KT-48912
2021-10-06 03:47:20 +03:00
Ilya Goncharov 464331d196 rra/ilgonmic/lazy-init-with-js-fun
[JS IR] Use initializer of field to use in js fun

[JS IR] Use string folding to consider const-like string vals as pure

Merge-request: KT-MR-4677
2021-10-05 13:37:06 +00:00
Dmitry Petrov 1dae2aca4c JVM_IR KT-48954 prohibit indy reference creation in some cases 2021-10-05 15:38:46 +03:00
pyos 337cbeded1 JVM_IR: do not move receivers on functions with inline class parameters
^KT-48993 Fixed
2021-10-05 13:34:32 +02:00
Alexander Udalov b6ebed0c96 IR serialization: cleanup/optimize DescriptorExportCheckerVisitor
Check if visibility is public API first, then check if declaration is
annotated with `@PublishedApi`. This is needed because loading
annotations and iterating over them can be slow.
2021-10-05 12:18:07 +02:00
Alexander Udalov 4da4719246 IR: slightly optimize IdSignature calculation in SymbolTable
Do not compute IdSignature for descriptor a second time when adding a
new symbol. Instead, pass the calculated signature to the lambda in
declare/declareIfNotExists/referenced, and use it in `reference*`
methods.
2021-10-05 12:18:06 +02:00
Alexander Udalov 1c735948d1 IR: cleanup SymbolTable
Extract duplicated code, remove unused methods and unneeded OptIn.

Also, check original for descriptors only in case the symbol is not
computed yet. Checking it on every access is not needed.
2021-10-05 12:16:24 +02:00
Alexander Udalov eb28d662d4 IR: use HashMap instead of LinkedHashMap in SymbolTable
It's not important for these maps to be linked hash maps because they
are not iterated over.
2021-10-05 12:16:24 +02:00
Alexander Udalov 6e93006a94 JVM IR: slightly optimize keepTrackOfOverridesForPossiblyClashingFakeOverride
Collecting all outer classes into a hash set and looking up classifiers
in that set for each type of each fake override is noticeably slow.
Instead, check that function types reference any type parameter whose
container is a class; if the function is not local, it means such type
parameter belongs to one of the outer classes.

 #KT-42020
2021-10-05 12:16:24 +02:00
Igor Chevdar 0cece79856 [K/N][IR][codegen] Use LazyIr for cached libraries
It's not that simple because we still need inline functions bodies
and classes fields which aren't present in Lazy IR. To overcome this,
save additional binary info for a cached library and then use it when needed
2021-10-05 10:47:52 +05:00
Svyatoslav Kuzmich 4dd4853c31 [Wasm] Use common StringConcatenationLowering 2021-10-04 08:51:43 +00:00
Svyatoslav Kuzmich fa3e75463e [Wasm] Support throwIAE and throwNoBranchMatchedException
Add a couple of test stubs
Unmute tests
2021-10-02 06:14:36 +00:00
Georgy Bronnikov 41e38d5a1a JVM_IR: move serialized IR to a separate annotation 2021-10-02 00:56:46 +03:00
Roman Artemev d4ace2ffe8 [JS IR] Make sure TypeOperatorLowering is after Interop CR Lowering 2021-10-01 23:02:23 +03:00
Roman Artemev f3035ac78e [IR] Add descriptive error message instead of NPE 2021-10-01 23:02:22 +03:00
Roman Artemev fe4a25eba1 [JS IR] Use context-dependent names for lambdas
Partially fix KT-46525

Now the code like
```
fun foo(a: () -> Unit) {}
interface A {
    fun run()
}
fun main() {
    foo {
        println()
    }
    val a = object : A {
        override fun run() {
            TODO()
        }
    }
}
```

is being compiled into

```
  function foo(a) {
  }
  function A() {
  }
  A.$metadata$ = {
    simpleName: 'A',
    kind: 'interface',
    interfaces: []
  };
  function main() {
    foo(main$lambda());
    var a = new _no_name_provided_();
  }
  function main$lambda() {
    return function () {
      println();
    };
  }

  // TODO
  function _no_name_provided_() {
  }
  _no_name_provided_.$metadata$ = {
    kind: 'class',
    interfaces: [A]
  };
```
2021-10-01 23:02:21 +03:00
Roman Artemev 76e08356d8 [JS IR] Change logic of InteropCallableReferenceLowering a bit
Now it first transforms Lambda classes and after fixes the call sites
2021-10-01 23:02:12 +03:00
Roman Artemev 7ec593b22a [JS IR] Inline lambda class into its interop wrapper 2021-10-01 23:02:10 +03:00
Roman Artemev a1b223e33d [JS IR] Set proper statement origin for bound receiver save 2021-10-01 23:02:09 +03:00
Ilya Goncharov dedb9d9018 [JS IR] Fix assertion to enable early created declarations 2021-10-01 13:32:12 +00:00
Ilya Goncharov 4c0045b136 [JS IR] Add test on initialization calling only once 2021-10-01 13:32:11 +00:00
Ilya Goncharov c2cf221965 [JS IR] Add annotation for eager property initialization 2021-10-01 13:32:10 +00:00