Commit Graph

100 Commits

Author SHA1 Message Date
Artem Kobzar fdda394a77 [K/JS] Calculate generated function names based on signatures of argument types (instead of fqNames) ^KT-49077 Fixed 2023-07-11 13:14:45 +00:00
Alexander Korepanov 4695dca056 [JS IR] Keep box and unbox intrinsics in call args after decomposing
^KT-59717 Fixed
2023-07-05 07:33:03 +00:00
Artem Kobzar 039b5fca7a [K/JS] Use declared upper-bound types for parameters inside inlined functions body, instead of the provided types 2023-06-20 12:01:28 +00:00
Alexander Korepanov fc898c7620 [JS IR] Use type upper bounds for calculating function signatures
^KT-59239 Fixed
2023-06-14 14:57:15 +00:00
Artem Kobzar c695da1bed [K/JS] Allow declare inline functions inside external declarations with a million suppresses ^KT-48154 Fixed 2023-04-13 08:53:57 +00:00
Kirill Rakhman f9540d8f69 [JS] Remove non-functional IGNORE_FIR directive in js box tests 2023-04-06 08:03:12 +00:00
Artem Kobzar 71486a321c [K/JS] Add support of compilation with ES-classes 2023-01-17 18:14:17 +00:00
Alexander Korepanov a5c8e30bb1 [JS IR] Use a copy of an original inline function for inlining
If inline function A calls another inline function B,
 we must use the original version of inline function A for inlining,
 which doesn’t have inlined function B. Because during the inlining
 process, we remap all occurrences of inline function A
 to a temporary copy of function A, and if the function B
 somehow uses function A (e.g. callable reference),
 the built IR will have a reference to the temporary function,
 not the original one. All these things lead to broken cross-module references.

 This patch saves the original versions of all inline functions
 before inlining and provides them during the inline process.

^KT-55930 Fixed
2023-01-16 11:01:03 +00:00
Sergej Jaskiewicz a152bc2313 [JS IR] Don't parse/print JS code in js() call twice
#KT-51327 Fixed
2022-08-22 23:15:52 +00:00
Alexander Korepanov bb8da65188 [Common IR] Do inlining of callable references of inline functions
^KT-52805 Fixed
2022-08-08 17:40:45 +00:00
Nikolay Lunyak 994e2970c7 [FIR JS] Suppress EQUALITY_NOT_APPLICABLE 2022-06-02 13:47:30 +00:00
Nikolay Lunyak bdc3b5fe6f [FIR JS] Mute 170 failing multi-module tests 2022-06-02 13:47:24 +00:00
Artem Kobzar 333440dfc6 fix: function inlining without blocks for else statement. 2022-04-20 09:28:45 +00:00
Alexander Korepanov d908eb6e84 [JS IR] Fix callable references ignoring bound parameters
^KT-51102 Fixed
2022-04-14 13:48:19 +00:00
Artem Kobzar c724ca943d test: add labels and breaks count tests. 2022-04-11 10:37:21 +00:00
Sergej Jaskiewicz d7d86a0e95 [JS IR] Lift lambdas that capture no context
If a lambda expression does not capture any local variables, convert
it to a global free function and replace the lambda creation with
a reference to that function.

Example: for the following Kotlin code

```kotlin
fun foo(f: () -> Unit) = f()

fun bar() = foo { console.log("hello") }
```

before this patch, we generated:

```js
function foo(f) {
  return f();
}
function bar() {
  return foo(bar$lambda());
}
function bar$lambda() {
  return function () {
    console.log('hello');
  };
}
```

after this patch, we generate:

```js
function foo(f) {
  return f();
}
function bar() {
  return foo(bar$lambda);
}
function bar$lambda() {
  console.log('hello');
}
```
2022-04-07 10:31:35 +00:00
Ilya Goncharov c67c1a69b9 rra/ilgonmic/reducing-size
[JS IR] Fix review remarks

- Fix translation mode from flags calculation
- comment why not top level could be safely inlined

[JS IR] Add test on exportness of internal val

Revert "[Gradle, JS] Disable minimizing names in production by default"

This reverts commit 700ff8634a73f155a2f0eaf963778216d6877075.

[JS IR] Adopt reserved names

Revert "[JS IR] Reserve interop names"

This reverts commit 63f30becaf1a45750ff85aea3753aae9a85985f4.

Revert "[JS IR] Clear minimized namer states"

This reverts commit ef7f19fa8a928021e8bdfbee7fbb5285fc74b7ab.

[JS IR] Clear minimized namer states

[JS IR] Reserve interop names

[JS IR] Separate arguments for users

[JS IR] Minimized member names in tests

[Gradle, JS] Disable minimizing names in production by default

[JS IR] Fix extra helps

[JS IR] Move mangling of signatures to linking namer

[JS IR] Add key and minimized name generator

[JS IR] cross module dependencies minimized

[JS IR] Minimize names

[JS IR] Cross module by index

[JS IR] Fix warning

[JS IR] Fix inlining accessors

[JS IR] Bridges for property accessors

[JS IR] Special case of jsFunctionSignature with property accessors

[JS IR] Inline property accessor for non top level properties

[JS IR] Reduce crossModule size

Merge-request: KT-MR-5785
Merged-by: Ilya Goncharov <Ilya.Goncharov@jetbrains.com>

^KT-51735 fixed
^KT-50504 fixed
2022-03-28 10:39:15 +00:00
Artem Kobzar aa85b755c1 chore: remove unused break statements from inlined functions bodies. 2022-03-19 20:04:22 +00:00
Anton Bannykh aa628ae7b3 [JS IR] tests both per-module and regular mode 2021-12-22 10:14:08 +03:00
Alexander Korepanov 2ae10f4378 [JS IR] Optimize equals call for inline class instances.
Remove implicit boxing of inline class instances in equals call.
2021-12-02 11:00:02 +00:00
Anton Bannykh a76425a7ee [JS IR] update JS AST diagnostics 2021-12-01 16:50:28 +03:00
Anton Bannykh af134912be [JS IR] fix test data 2021-12-01 16:50:20 +03:00
Anton Bannykh 2259c6f75d [JS IR IC] assert cross-file tag are not null and fix tests 2021-11-29 21:09:35 +03:00
Ivan Kylchik 41547174a7 [JS TESTS] Enable directive processing for js ir 2021-11-12 21:24:32 +03:00
Artem Kobzar 979e9f94ef feat(Escaped Identifiers): add ability to use any symbol wrapped in back ticks. 2021-10-29 17:55:59 +00:00
Anton Bannykh c2f7ed2fff [JS IR] added a directive to skip IC checks in IR 2021-10-15 20:14:53 +03:00
Svyatoslav Kuzmich 279f184703 [JS] Remove failed checks based on unstable naming 2021-10-12 23:29:39 +03:00
Sergej Jaskiewicz 65d40c2253 [JS IR] Make tests that use directives pass with IR BE 2021-10-06 09:23:50 +00:00
Svyatoslav Kuzmich cb3b1f8ae2 [JS IR] Fix referencing Kotin variables in inline JS code
Fixed by outlining JS code that uses Kotlin variables making usages of
these locals explicit and preventing bugs due to one-sided variable renaming.

This prevents using Kotlin variables as lvalue in JS code.
2021-01-25 19:18:44 +03:00
Shagen Ogandzhanian 55a5695fc0 [JS] Forbid export of interfaces
With the only exception of external interfaces.

See https://youtrack.jetbrains.com/issue/KT-44099
2020-12-29 20:43:57 +01:00
Svyatoslav Kuzmich bbfc1a10ad [JS] Fix stack trace capturing from secondary constructors KT-37563 2020-06-22 12:03:59 +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
Svyatoslav Kuzmich 6e3d3831c2 [JS] JsExport diagnostics and legacy support
Account for JsExport in legacy backend namer. It means we
catch overloaded exported function conflicts for free!

Add error diagnostics:
* NESTED_JS_EXPORT (Fixes KT-36798)
* WRONG_EXPORTED_DECLARATION (Part of the fix for KT-37752)
* NON_EXPORTABLE_TYPE (Fixes KT-37771)
2020-05-22 10:50:22 +03:00
Abduqodiri Qurbonzoda dabf6376db Update js reachable nodes count after expanding StringBuilder api 2019-12-06 05:37:09 +03:00
Roman Artemev 9946feb66c [JS IR] Fix name clash between class members defined on prototype
- Fixes [KT-33327]
2019-11-25 20:22:03 +03:00
Svyatoslav Kuzmich 69962cbf8c [JS IR BE] Add JsExport annotations 2019-07-01 18:55:41 +03:00
Svyatoslav Kuzmich 0b19a4a32b [JS IR BE] Initial version of member namer 2019-06-21 17:02:01 +03:00
Ilya Gorbunov aa69933ee0 Update EXPECTED_REACHABLE_NODES
DCE doesn't remove DurationUnit and some other kotlin.time stuff in these cases
2019-06-18 04:02:36 +03:00
Svyatoslav Kuzmich 0f07209490 [JS IR BE] Remove unnecesary println from tests 2019-03-15 13:53:21 +03:00
Anton Bannykh 4e298ae5cb JS: Inlined local declarations should be positioned after imports 2019-02-14 15:14:28 +03:00
Anton Bannykh 0bfd332580 JS: improve a test (review fix) 2019-02-14 15:14:28 +03:00
Anton Bannykh 990ee849e2 JS: test local declaration deduplication with name clash; fix the test 2019-02-14 15:14:28 +03:00
Anton Bannykh 60aa6e4971 JS: a cross-module local declaration fake override test;
Also describe an alternative, more robust approach in a TODO comment
2019-02-14 15:14:28 +03:00
Anton Bannykh 2022a9c887 JS: fix inheriting fake overrides in inlined object literals 2019-02-14 15:14:28 +03:00
Anton Bannykh 9716abcc12 JS: inline private properties 2019-02-14 15:14:28 +03:00
Anton Bannykh cd0fd569b4 JS: visit tests and main in import remover; update line numbers 2019-02-14 15:14:28 +03:00
Anton Bannykh c65383fa3f JS: postpone JS AST merging 2019-02-14 15:14:28 +03:00
Svyatoslav Kuzmich aa811dcfb3 [JS IR BE] Add KJS_WITH_FULL_RUNTIME directive to compiler tests 2019-01-24 16:14:40 +03:00
Roman Artemev 4e05be9a96 Update tests 2018-12-07 17:58:20 +03:00
Svyatoslav Kuzmich 0210ec3114 [JS BE] Fix KT-26787: handle JsSwitch in LabeledBlockToDoWhileTransformation 2018-10-10 19:35:16 +03:00