Commit Graph

75 Commits

Author SHA1 Message Date
Artem Kobzar 2530cba82a [K/JS] Compile Kotlin coroutines as JS generator ^KT-63038 Fixed 2023-12-18 17:13:07 +00:00
Artem Kobzar 6615b77213 [K/JS] Rework symbol hash calculation to make IC works with @JsExport and @JsName changes 2023-11-27 13:49:56 +00:00
Artem Kobzar ff50d40b32 [K/JS] Rework kotlin tests compilation to make it works with per-file granularity ^KT-61525 Fixed 2023-11-16 19:02:04 +00:00
Alexander Korepanov 0d7de87e2e [JS IR test] Add a test for invalidation with a src name chash 2023-10-30 09:14:16 +00:00
Alexander Korepanov 73bf7fa506 [JS IR test] Add a simple multiplatform invalidation test 2023-10-30 09:14:15 +00:00
Alexander Korepanov 91edbeb747 [JS IR] Add tests for checking constant inlining with JS IR IC
^KT-62425
2023-10-26 19:22:14 +00:00
Alexander Korepanov 188cdf2f98 [JS IR] Allow constant inlining in JS IR
Fixed the incremental compilation issue,
which had prevented enabling const inlining during constant
evaluation and folding a constant expression with JS code.

^KT-62425
2023-10-26 19:22:14 +00:00
Artem Kobzar 6cd42eeb71 [K/JS] Fix reexport with CommonJS and incremental compilation 2023-10-26 09:58:35 +00:00
Artem Kobzar 4a042dafef [K/JS] Fix nameBindings for ES-modules after the ES-modules external declarations optimization 2023-10-20 14:04:39 +00:00
Artem Kobzar eef57f216c [K/JS] Rework main function call to support it in per-file 2023-10-04 12:13:20 +00:00
Artem Kobzar 878452bd2b [K/JS] Implement file merging for clashed file during per-file compilation 2023-09-14 13:14:15 +00:00
Artem Kobzar bff433f4e9 [K/JS] Support eager initialization for per-file granularity 2023-09-06 09:27:28 +00:00
Alexander Korepanov 7a31167e0b [Common IR] Do not add internal methods to overrides
[JS IR] Use a module name in JsFunctionSignature for internal methods

^KT-60635 Fixed
2023-08-09 16:35:59 +00:00
Artem Kobzar 12715c062d [K/JS] Reexport exported declarations in a proxy module file with per-file compilation 2023-08-01 09:42:33 +00:00
Artem Kobzar 044c0adae7 [K/JS] Implement an incremental compilation for the per-file granularity 2023-07-19 15:57:56 +00:00
Artem Kobzar 966a342bf1 [K/JS] Migrate invalidation tests to ES modules 2023-06-30 16:13:35 +00:00
Dmitriy Dolovov f2f935846c [JS] Fix IC tests to reflect changes in signature rendering
^KT-59486
2023-06-26 15:59:31 +00:00
Artem Kobzar 64158a8a2f [K/JS] Add file-to-file compilation ^KT-6168 Fixed 2023-06-22 18:23:45 +00:00
Alexander Korepanov 82a1242f22 [JS IR] Add tests for JS IR IC + PL
^KT-57347 related
2023-06-06 09:27:57 +00:00
Alexander Korepanov 97620030c6 [JS IR] Rollback PL hacks from JS IR IC infra
^KT-57347 related
2023-06-06 09:27:57 +00:00
Alexander Korepanov 8066f1b7d2 [JS IR] Do not copy interface method if base class inherits it
^KT-58599 Fixed
2023-05-30 08:22:43 +00:00
Alexander Korepanov 2aea5822b2 [JS IR] Unmute all fir invalidation tests 2023-05-01 12:56:12 +00:00
Alexander Korepanov 9da9c95105 [JS IR] Add IC test for interface with default implementation 2023-05-01 12:49:07 +00:00
Alexander Korepanov 81b591ed21 [JS IR IC] Interface default implementations affect IC hash
Adding or removing a method or property with
a default implementation to an interface should
invalidate all children: we must regenerate JS code for them

^KT-56237 Fixed
2023-04-25 15:34:22 +00:00
Alexander Korepanov 980d83eccd [JS IR IC] Drop incremental cache after updating a klib set
Enabled Partial Linkage may replace entire IR expressions with a stub
during klib linking and loading. This may break the incremental cache
dependency graph. Dropping incremental cache files after updating klibs
(e.g. update klib version) covers almost all cases which
could not be tracked due to a broken dependency graph.

This patch could be reverted after fixing KT-57347
2023-04-18 09:06:07 +00:00
Artem Kobzar 5dc6da2b33 [K/JS] Add serialization/deserialization for JsImport/JsExport nodes 2023-04-13 12:58:46 +00:00
Dmitriy Dolovov 66c278ff8d [JS][IC][test] Remove testBreakKlibBinaryCompatibilityWithVariance test
#KT-57078 Fixed
2023-03-23 10:24:28 +00:00
Dmitriy Dolovov 153aed29ba [JS][IC][test] Fix step numbers in tests 2023-03-23 10:24:28 +00:00
Artem Kobzar 484e5afb59 [K/JS] Remove unused Unit_getInstance import into generated code 2023-03-09 16:51:07 +00:00
Alexander Korepanov f82d3e63a2 [JS IR] Use a backing field initializer for js() code folding
During a translation of the code from js() call to statement list,
 the compiler folds the code string. For that it uses property bodies.
 However the bodies can not be loaded in an incremental rebuild.
 The patch uses the backing field initializers of constant properties.
 The initializers are always loaded.

^KT-57002 Fixed
2023-03-08 16:56:05 +00:00
Alexander Korepanov 3c9d653595 [JS IR] Ignore unbound symbols in IC infrastructure
The IR linker is responsible for detecting unbound symbols,
 if it skips them for some reason, IC infrastructure must not fail
 with unbound symbols exceptions. Anyway, the IR validator
 verifies later if there are unbound symbols in
 reachable IR and generates the corresponding error.

^KT-56602 Fixed
2023-02-21 14:46:44 +00:00
Alexander Korepanov 43cef114c6 [Compiler CLI] Sort flags and features before appending them to string
JS IR BE incremental compilation infrastructure uses
 LanguageVersionSettings::toString method to detect if any
 compiler features or flags were enabled or disabled.
 It is important that the features and flags order are stable
 in the result string.

^KT-56580 Fixed
2023-02-15 13:24:11 +00:00
Alexander Korepanov 121c920099 [JS IR IC] Load only top level signatures for function type interfaces
The dependency signature may refer to function type interface properties
 (e.g. name) or methods. It is impossible to detect (without hacks)
 which binary symbol for loading is required. However, when loading
 a property or a method the entire function type interface is loaded.
 And vice versa, a loading of function type interface loads
 properties and methods as well. Therefore, load the top level signature only,
 it must be the signature of function type interface.

^KT-56582 Fixed
2023-02-14 13:25:19 +00:00
Alexander Korepanov f367541393 [JS IR] Rename functionalInterface -> functonTypeInterface 2023-02-14 13:25:19 +00:00
Alexander Korepanov 9324cf3360 [JS IR] Support function type interfaces in incremental cache infrastructure
The patch removes logic of generating extra IrFiles (fake file) into
 IrModuleFragment for the function type interfaces during klib deserialization,
 because IC infrastructure can not process files which do not exist in klib.

 Instead of adding extra IrFiles during deserialization, the empty files
 with required packages are added into Kotlin/JS stdlib physically.
 These files are used as containers for function type interface declarations.

 Since Kotlin/WASM uses the same klib loading infrastructure as Kotlin/JS,
 the the empty files are added into Kotlin/WASM stdlib as well.

 The patch also adds a check that IrModuleFagment has files only from klib.

^KT-55720 Fixed
2023-02-03 12:23:48 +00:00
Alexander Korepanov edbd05ba47 [JS IR] Hack IC invalidation test so it works with ES6 classes
Hack the IC invaliadtion test so the cross module references
 are invalidated in the same way as with ES6 classes and without.
2023-01-24 09:35:16 +00:00
Artem Kobzar 71486a321c [K/JS] Add support of compilation with ES-classes 2023-01-17 18:14:17 +00:00
Alexander Korepanov c502cae437 [JS IR IC] Calculate symbol hashes on demand
Optimization: often we don't need all hashes for all available symbols.
 This patch allows the calculation of the symbol hash only on demand.

 This patch also allows cycles for the inline function dependency
 graph in the IC infrastructure. Note that the inline function cycles
 may crash the inliner, however it is not the IC infrastructure
 responsibility to check the cycles.
2023-01-17 15:48:36 +00:00
Alexander Korepanov 5f10e605a9 [JS IR] Don't check an interface method default impl during JS translation
We do not need to check a default implementation of the interface during
 the translation to JS because it must be checked before.

 Moreover, this check breaks the produced JS code
 if IR is partial loaded, e.g. during the incremental rebuild.

^KT-55716 Fixed
2023-01-09 09:46:17 +00:00
Alexander Korepanov 48daf0befe [JS IR] Take into account file annotations for calculating symbol hashes
^KT-55367 Fixed
2022-12-20 16:04:14 +00:00
Alexander Korepanov 4136189114 [JS IR] Check all signatures of dependent file in IC graph
It is important to check all signatures, because signatures
 can be simultaneously moved between files and modified.
2022-12-20 16:04:14 +00:00
Alexander Korepanov 9edaebf235 [JS IR] Enable DTS generation in IC
^KT-54398 Fixed
2022-12-07 18:05:53 +00:00
Alexander Korepanov d21cbfe02e [JS IR] Take into account the declaration annotations in IC hash
So the annotation modifications invalidate the caller.
2022-12-07 18:05:53 +00:00
Alexander Korepanov d8ab9498ab [JS IR] Fix inline functions call graph in IC
Add a dependency for inline function references,
 because in some cases the references may be inlined.

^KT-55144 Fixed
2022-12-02 13:50:37 +00:00
Alexander Korepanov c31705240a [JS IR] Support a module friendship in IC infrastructure
^KT-55097 Fixed
2022-12-02 13:50:36 +00:00
Alexander Korepanov 693258ae91 [JS IR] Invalidate all klib dependencies after removing it
Without the invalidation, broken JS code
 (with broken cross-module references) may appear.

 ^KT-54911 Fixed
2022-11-28 20:46:40 +00:00
Alexander Korepanov ca19d71a00 [JS IR] Commit cache header after lowering
Commiting cache header before lowering may
 break caches in case of lowering errors.

^KT-54912 Fixed
2022-11-28 20:46:40 +00:00
Alexander Korepanov 8cde0a81bc [JS IR] Use topological order for loading klibs in JS IR IC
Generally, the library order doesn't matter.

 However, after lowering we need to post process
 lowered klibs in topological order:
  - commit incremental cache artifacts,
  - produce JS AST.

 The patch uses an ability of the Kotlin library resolver to load klibs
 in topological order and drops its reimplementation from IC infrastructure.

 There is one side effect:
   klibs which are not reachable from the main module, will produce their JS.
   This should be more correct than just ignoring them.
2022-11-28 20:46:39 +00:00
Alexander Korepanov f4b5f5ff5d [JS IR] Take default params into account for calculating an IC hash
^KT-54895 Fixed
2022-11-16 12:25:11 +00:00
Alexander Korepanov f7063555ca [JS IR] Fix the instability of LoweredDeclarationSignature
A suspend stub for the abstract function
 may be created in the context of the child function.
 If on an incremental rebuild the stub is created from
 the parent context (e.g. a file with the child is not modified),
 the resulting LoweredDeclarationSignature will be different.
 It will lead to a broken cross-module reference and broken JS code.
 Therefore it is required to wrap the creation routine
 into StageController::restrictTo() explicitly.

^KT-54934 Fixed
2022-11-16 12:24:48 +00:00