Commit Graph

5160 Commits

Author SHA1 Message Date
Artem Kobzar 3dbf996ec6 fix(KT-49225): remove unnecessery boxing. 2021-10-21 06:38:42 +00:00
Sergej Jaskiewicz 9e5520bba8 [JS IR & WASM] Fix executing init blocks for enums with nested objects 2021-10-18 13:37:16 +00:00
Anton Bannykh 283e37c741 [JS IR] fix warnings 2021-10-15 20:14:54 +03:00
Anton Bannykh c2f7ed2fff [JS IR] added a directive to skip IC checks in IR 2021-10-15 20:14:53 +03:00
Anton Bannykh 94ed6a1dbd [JS IR] bring back old ir2js to work alongside with the new one
Should be removed when we're sure the new one is OK
2021-10-15 20:14:53 +03:00
Anton Bannykh 1d42b6cb3f [JS IR] make InnerClassesLowering.kt work with abscent bodies 2021-10-15 20:14:52 +03:00
Anton Bannykh 546ce501cb [JS IR] run IC box tests 2021-10-15 20:14:51 +03:00
Anton Bannykh b1b88a0d11 [JS IR] JS AST serialization 2021-10-15 20:14:50 +03:00
Anton Bannykh 95ab5e1b7e [JS IR] generate JS separately for each file and link at the end
Name clashes are handled as a post-processing step
2021-10-15 20:14:50 +03:00
Anton Bannykh 936383254a [JS IR] explicitly mark JsName's temporary or not 2021-10-15 20:14:49 +03:00
Anton Bannykh 7e7c84fcfb [JS IR] move fragment generation closer to the beginning 2021-10-15 20:14:48 +03:00
Anton Bannykh b1b263615c [JS IR] handle exports per-file 2021-10-15 20:14:47 +03:00
Anton Bannykh aec743d7a6 [JS IR] handle tests per-file 2021-10-15 20:14:47 +03:00
Anton Bannykh 9f2762cfa6 [JS IR] handle main function per-file 2021-10-15 20:14:46 +03:00
Anton Bannykh 1af1d13cf3 [JS IR] split resulting code into fragments 2021-10-15 20:14:45 +03:00
Anton Bannykh d595264cc8 [JS IR] move JsGenerationContext towards it's use 2021-10-15 20:14:43 +03:00
Svyatoslav Kuzmich 0f66f85cf9 [Wasm] Support main function 2021-10-15 13:58:55 +03:00
Dmitry Petrov af18b10da9 JVM_IR KT-49203 generate stubs for not found classes 2021-10-15 12:15:49 +03:00
Igor Laevsky 50ca86838f [WASM] Fix build 2021-10-14 17:24:07 +03:00
Igor Laevsky bede039c08 [Wasm] Add compiler support for the kotlin.test library 2021-10-14 17:24:05 +03:00
Igor Laevsky 049e48e780 [Wasm] Keep error message for the IAE exception 2021-10-14 17:24:03 +03:00
Sergej Jaskiewicz 55ae6d1f3e [JS IR] Optimize pattern-matching of enums into comparing their ordinals
For this code:
```
enum class Season {
    WINTER,
    SPRING,
    SUMMER,
    AUTUMN
}

fun bar1(x : Season) : String {
    return when (x) {
        Season.WINTER, Season.SPRING -> "winter_spring"
        Season.SUMMER -> "summer"
        else -> "autumn"
    }
}
```

previously we generated this:
```
function foo(x) {
    var tmp0_subject = x;
    return (tmp0_subject.equals(Season_WINTER_getInstance())
        ? true
        : tmp0_subject.equals(Season_SPRING_getInstance()))
            ? 'winter_spring'
            : tmp0_subject.equals(Season_SUMMER_getInstance())
                ? 'summer'
                : 'autumn';
}
```

And now we generated this:
```
function bar2(x) {
  var tmp0_subject = x;
  var tmp0 = tmp0_subject._get_ordinal__0_k$();
  var tmp;
  switch (tmp0) {
    case 0:
    case 1:
      tmp = 'winter_spring';
      break;
    case 2:
      tmp = 'summer';
      break;
    case 3:
      tmp = 'autumn';
      break;
    default:
      noWhenBranchMatchedException();
      break;
  }
  return tmp;
}
```
2021-10-14 11:44:01 +00:00
Pavel Kunyavskiy e4a4cd3e16 [K/N] Transform constant varargs to ConstantValue 2021-10-14 11:22:25 +00:00
Pavel Kunyavskiy bf3c343ced Introduce new ir nodes for constant values 2021-10-14 11:22:21 +00:00
Pavel Kunyavskiy 2fe9420ca1 Compatibility hack for instantiating annotations from old klibs
^KT-49181
2021-10-14 11:03:17 +00:00
Dmitry Petrov 6f33259bc3 PSI2IR KT-49203 INVISIBLE_FAKE setter is non-referenceable 2021-10-13 18:38:23 +03:00
Dmitry Petrov 2a00def84e JVM_IR make proxy funs for inline and arrayOf funs non-synthetic 2021-10-13 16:07:53 +03:00
Artem Kobzar f645c89ebf fix(KT-43191): add static qualifier for Companion and non-inner objects. 2021-10-13 11:09:59 +00:00
Alexander Udalov 357f3184bf JVM IR: fix the type of IrGetField
The `irGetField` utility uses the field's own type as the type of the
resulting expression. But the field's type does not make sense outside
of the place of declaration of the field if it references a generic type
parameter of the containing class. Using this non-sensical generic type
led, for example, to an error in Ieee754 intrinsic (KT-48648).

The type of the expression should be kept as is in
JvmPropertiesLowering, i.e. taken from `expression` which the lowering
is replacing with the field access.

 #KT-48648 Fixed
2021-10-12 23:35:17 +02:00
Svyatoslav Kuzmich 3f8dce4b53 [JS IR] Support per-file mode and ES modules 2021-10-12 23:29:39 +03:00
Svyatoslav Kuzmich 5affd9d2f9 Visit declaration reference when visiting member access 2021-10-12 23:01:00 +03:00
Dmitry Petrov b946a284b0 JVM_IR move 'arrayOf' handling to JvmBuiltInsLowering
FunctionReferenceLowering creates calls to 'arrayOf' functions that
should be processed later.
2021-10-12 21:12:44 +03:00
Dmitry Petrov 27e5655480 JVM_IR minor: more JvmIrBuilder helpers 2021-10-12 21:12:43 +03:00
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