Commit Graph

45 Commits

Author SHA1 Message Date
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
Alexander Korepanov e2922219f2 [JS IR] Add more JS IC tests for top level properties 2022-10-26 10:54:36 +00:00
Alexander Korepanov 901ebcc043 [JS IR] Add JS IR IC tests about companion properties modifications
^KT-54479 Test
2022-10-17 18:59:40 +00:00
Alexander Korepanov 7b2c125754 [JS IR] Update IC depends graph after intrinsics loading
- Remove unused params from compilerWithIC wrapper.
- Move JsIrBackendContext creation logic into separate function
- Introduce and use compiler interface for IC infrastructure

On dirty rebuild we may reload IR from stdlib,
such reloading may affect files with intrinsics and builtins.
As soon as we load only exported symbols, we must track dependencies
for files with intrinsics or builtins as for others.
This patch implements the logic which updates dependencies for
the stdlib files after loading of intrinsics and builtins.

^KT-54323 Fixed
2022-10-12 22:14:15 +00:00
Alexander Korepanov 252dc01dd5 [JS IR] IC: Propagate dependencies from nested declaration to parent
JsIrLinker can't load nested declarations,
 therefore it is required to load their parent.
 This patch adds a dependency in the incremental cache graph
 between nested declaration user and nested declaration parent.

^KT-53931 Fixed
^KT-54120 Fixed
2022-09-27 15:27:20 +00:00
Alexander Korepanov ea7ce55082 [JS IR] Add a test with an object in inline function for JS IC 2022-09-19 16:54:14 +00:00
Alexander Korepanov 46afb46a6d [JS IR] Add IC test for local inline function
^KT-50739
2022-09-16 12:14:35 +02:00
Alexander Korepanov 47bbd5e8c1 [JS IR] Add work around in EnumEntriesList for JS IR to avoid name clashes
JS IR generates bridges with type checks for special class methods,
 however if parent and child type parameters are same,
 the JS signature for the generated brige will be clashed with
 the JS signature of original method.

 This patch changes type parameter name of EnumEntriesList to avoid the clash.

^KT-54011 Fixed
2022-09-16 07:19:20 +00:00
Alexander Korepanov 752ce887b2 [JS IR] Add IC test for JsModule annptation
^KT-43455
2022-09-15 11:02:46 +00:00
Alexander Korepanov 6525f7a7ac [JS IR] Fix a IC dependency building for class methods.
The patch fixes lost IC dependencies for inherited class or interface methods.
 Especially between a fake override function and its implementation.
 Since IrSymbolDeserializer doesn't provide all class methods,
 they are collected from the class definitions.

^KT-53063 Fixed
2022-07-28 12:39:39 +00:00
Alexander Korepanov 5b4e9e2966 [JS IR] Fix IC invalidation process when symbols are modified
The patch fixes the cases of IC invalidation when symbols are modified:
 adding and removing inline, data, in, out, suspend qualifiers.

 For that purpose an extra hash is used.
 It is written in a direct dependency graph into an IC cache metadata file.
 For inline functions a transitive hash is used.
 For non-inline functions, classes, and others a symbol hash is used.
 The invalidation routine marks the file as dirty
 (with 'updated imports' state) if hash is modified.

^KT-51083 Fixed
^KT-51088 Fixed
^KT-51090 Fixed
^KT-51099 Fixed
2022-07-05 12:45:43 +00:00
Alexander Korepanov 644447db84 [JS IR] Fix IC invalidation for fake override inline functions
The patch enables the direct dependency between
 fake override inline function and its implementation from the base class.

 Because klibs do not keep a signature of fake override implementation,
 incremental cache can not use the signature index,
 therefore the signature is serialized to a cache file as is.

^KT-51896 Fixed
2022-07-05 12:45:43 +00:00
Alexander Korepanov 9e780afdca [JS IR] Rework incremental cache invalidation
Replace loading the whole world IR with loading only exported (reachable) IR.

 For that purpose the direct and inverse dependency graph is used.
 It is stored in a cache directory and the cache updater keeps it up to date.
 If after loading it is found that other files must be also implicitly rebuilt
 (see rebuilt reasons below), IR for that files also will be loaded.
 This algorithm repeats until the number of implicitly rebuilt files is not 0.

 More rebuilt reasons (dirty state) have been added:
  - added file: this is a new file;
  - modified ir: ir of the file has been updated;
  - updated exports: exports from the file have been added or removed
    (e.g. a function has been used from another file);
  - updated inline imports: imported inline function has been modified
    (transitively);
  - removed inverse depends: a dependent file has been removed;
  - removed direct depends: a dependency file has been removed;
  - removed file: this file has been removed.

 Incremental cache tests has been refactored:
  - The supporting of all rebuilt reasons (dirty states) has been added;
  - New file name format "*.$suffix.kt" for the test steps has been allowed,
    so the syntax highlight works now;
  - Explicit stdlib dependency usage has been removed.
2022-06-13 20:04:05 +00:00
Artem Kobzar ccc2aae841 fix(KT-50270): inline properties accessor for child classes too. 2022-04-27 10:21:38 +00:00
Artem Kobzar 7327bc864e test(KT-31614): fixate behavior of serialization/deserialization of UTF characters. 2022-04-21 09:22:24 +00:00
Alexander Korepanov 2f3ad476be [JS IR] Ignore fake override calls in IC
Fake overrides don't have a signature and can't be assiciated with klib index,
therefore they can't be tracked with incremental cache invalidation logic.

Should be fixed after KT-51896.
2022-04-08 08:54:22 +00:00
Alexander Korepanov 9952d43252 [JS IR] IC improvements
- Reuse a built fragment
  - Use cache for saving built JS code
2022-04-04 17:42:04 +00:00
Alexander Korepanov 69295f2cf0 [JS IR] IC invalidation refactoring
- Huge refactoring for IC
  - Update hash combination logic
  - Introduce value class for IC hashes
  - Calc md5 directly by function IR
  - Split IC logic by classes
  - Move JsIrLinkerLoader into separate file
  - CacheUpdateStatus is a sealed class
  - Render TYPE_PARAMETER reified flag

^KT-51081 Fixed
^KT-51084 Fixed
2022-03-15 05:34:19 +00:00
Alexander Korepanov 43a0876c26 [JS IR] IC invalidation performance improvements
- Cache signature readers and deserializers
 - Cache inline function hashes
 - IC refactoring
 - [gradle] Use hash of module path for cache dir; Fix KT-51238

^KT-51238 Fixed
2022-02-16 13:41:53 +00:00
Alexander Korepanov 28b1f1c50f [JS IR] Add IC invalidation tests 2022-02-03 20:19:17 +00:00
Roman Artemev 702ab3408b [JS IC TEST] Add test case about renaming file in module 2021-12-21 18:07:57 +03:00
Roman Artemev 76b9167c15 [JS IC TEST] Add test case about moving file between modules 2021-12-21 18:07:57 +03:00
Roman Artemev 2dd519c91f [JS IC TEST] Add test case for moving inline functions between modules 2021-12-21 18:07:55 +03:00
Roman Artemev 2474702bef [JS IC TEST] Add test case for private top-level inline functions 2021-12-21 18:07:54 +03:00
Roman Artemev 312cbb6613 [JS IR IC] Add tests to check cache invalidation via fast path 2021-12-13 20:57:53 +03:00
Roman Artemev 979ddacd8c [JS IR] Add and generate IC invalidation tests 2021-11-25 11:22:52 +03:00