Commit Graph

2834 Commits

Author SHA1 Message Date
Ilya Goncharov 7ae85ed68e [JS IR] Module descriptors depends on each other 2023-01-23 16:16:48 +00:00
Roman Efremov 14b4cdc7c4 Write "hasEnumEntries" flag into metadata when feature enabled
^KT-53929 Fixed
2023-01-23 12:53:04 +01:00
Sergey Bogolepov c22285f824 [IR] Remove unused Ir.irModule property
It is required for the Native backend refactoring
where `Context` does not contain a reference for any
particular IrModuleFragment.
2023-01-20 13:33:06 +00:00
Artem Kobzar 71486a321c [K/JS] Add support of compilation with ES-classes 2023-01-17 18:14:17 +00:00
Alexander Korepanov a4192c38f2 [JS IR IC] Remove JS files of the deleted modules from the out directory 2023-01-17 15:48:37 +00:00
Alexander Korepanov 75931fb9c8 [JS IR IC] Do not read non modified JS into memory
Optimizaion: instead of reading all non modified JS files
 from the cache into the memory at once, the patch allows
 copying non-modified JS files from disk one by one
 during the compilation output writing routine.
2023-01-17 15:48:36 +00:00
Svyatoslav Kuzmich d14d4c8510 [Wasm] Support JsModule and JsQualifier 2023-01-13 21:58:34 +00:00
Svyatoslav Kuzmich fd67464d14 [Wasm] Test infra: support _commonFiles and additional .mjs
Use custom `evalToBoolean` as `eval` and `unsafeCast` are not
 available in Wasm stdlib
2023-01-13 21:58:33 +00:00
Svyatoslav Kuzmich 80e07d628b [Wasm] Use ModuleKind.ES
As the only JS-interop module kind Wasm supports
2023-01-13 21:58:32 +00:00
Anton Bannykh 698be0fddd JS IR: custom JS AST serialization 2023-01-11 15:56:57 +00:00
Nikolay Lunyak 5ae9444745 [FIR JS] Add a test runner for FIR JS with old diagnostic tests 2023-01-09 08:57:07 +00:00
Svyatoslav Kuzmich dd53998c2d [Wasm] Add uninstantiated MJS wrapper
It allows

* Custom imports
* Ability to skip initializer
2022-12-28 12:13:52 +01:00
Svyatoslav Kuzmich 3bbd8c291a [Wasm] Add @WasmImport annotation
Imports top-level function from given module
2022-12-28 12:13:18 +01: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
Dmitriy Novozhilov 5d6cb2b691 [Test] Use IrPluginContext for searching declarations for DUMP_EXTERNAL_CLASS check 2022-12-09 12:02:07 +00:00
Zalim Bashorov 49c3ba33f1 [Wasm] Add a basic end-to-end sourcemap generation in wasm backend
More constructions/instructions will be supported separately.
2022-12-08 12:44:26 +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 0a35d84193 [JS IR] DTS generation refactoring
Keep a DTS fragment in JsIrProgramFragment
 for each file and build the module DTS from them.
2022-12-07 18:05:52 +00:00
Zalim Bashorov fb4dcc6a6a [Sourcemap] Introduce getCurrentColumn and stop using TextOutput directly
The general goal is remove dependency on TextOutput and
make it simpler to use for wasm backend.
2022-12-07 12:03:54 +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
Sergej Jaskiewicz 1539d7ef1a [klib] Bring package names in sync with the directory layout
Basically, some package names were Native-specific, whilst the packages
themselves were not Native-specific at all. This was already reflected
in the directory layout, but not in the package names.
This is fixed here.

NFC, just an automatic rename of packages with fixes of imports.
2022-12-01 21:46:43 +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 ec6a7094e6 [JS IR] Manage cache root dir from IC cache updater
- pass cache root directory instead of dir list
 - manage klib cache dirs from cache updater
2022-11-28 20:46:39 +00:00
Anton Bannykh e42385dfb0 JS tests: split fir, ir, and legacy tests
Also split write FIR output to separate folders
2022-11-23 11:01:13 +00:00
Anton Bannykh f99d480bf8 JS: move DCE test output to build/ dir 2022-11-23 11:01:13 +00:00
Anton Bannykh 56765461a0 WASM: move output to build/ dir 2022-11-23 11:01:12 +00:00
Sergej Jaskiewicz 932e1a3c1d [JS] Re-run stepping tests if they fail because of a Node crash
KT-54283
2022-11-18 10:37:58 +00:00
Anton Bannykh e6801abce8 JS IR: move IC tests output to build/ dir 2022-11-17 09:24:54 +00:00
Svyatoslav Kuzmich 78bd6dbdcd [Wasm] Allow implementing function interfaces 2022-11-14 11:23:18 +01:00
Ilya Chernikov b28dd95621 FIR JS: rename test classes for uniformity 2022-11-12 16:28:25 +01:00
Ilya Chernikov 78ca733c38 FIR JS: add K2 variants of all other JS tests
except tests that are not possible to add without some modifications in
the test infra. See todos on the commented-out test declarations
2022-11-12 16:28:24 +01:00
Ilya Chernikov 5baf4a55c1 FIR JS: fix nodejs box tests infrastructure 2022-11-12 16:28:24 +01:00
Ilya Chernikov fa0cda6236 FIR JS: enable full JS box tests with FIR 2022-11-12 14:34:07 +01:00
Ilya Chernikov 8bf108dc17 FIR JS: Prepare JS/KLib infrastructure for FIR integration
rearrange declarations, abstract things that should be done differently
with FIR, etc.
2022-11-12 14:34:07 +01:00
Zalim Bashorov 89ba1b515e [Wasm, test] Use "dynamic import" to catch exception thrown during JS & Wasm modules initialization 2022-11-11 16:22:10 +01:00
Zalim Bashorov 5511377c2c [Wasm, tests] Cleanup and improvements in wasm test infra
- Remove no longer necessary separate generation to run inside browsers
- Generate index.html in DEBUG mode instead of SUPER_DEBUG
- Print link to index.html using IDEA builtin server (0.0.0.0:63342)
- Small improvements in generated index.html
2022-11-11 16:21:54 +01:00
Sergej Jaskiewicz 6d58d9cb8d [JS] Attempt to fix OOM in Node.js
But there are still segfaults, see
https://github.com/nodejs/node/issues/45410
2022-11-10 23:17:42 +00:00
Hung Nguyen cdbbead157 Handle changes to inline functions/property accessors with @JvmNames
If we detect a change in an inline function `foo` with @JvmName
`fooJvmName`, we have two options:
   1. Report that function `foo` has changed
   2. Report that method `fooJvmName` has changed

Similarly, if we detect a change in an inline property accessor with
JvmName `getFoo` of property `foo`, we have two options:
   1. Report that property `foo` has changed
   2. Report that property accessor `getFoo` has changed

The compiler is guaranteed to generate `LookupSymbol`s corresponding to
option 1 when referencing inline functions/property accessors, but it is
not guaranteed to generate `LookupSymbol`s corresponding to option 2.
(Currently the compiler seems to support option 2 for *inline*
functions/property accessors, but that may change.)

Therefore, we will choose option 1 as it is cleaner and safer.

^KT-54144 In progress

Small cleanup in IncrementalCompilerRunner

 - Add comment for closing caches
 - Rename providedChangedFiles to changedFiles
 - Tiny clean up in `performWorkBeforeCompilation`
 - Count directories to delete in debug logs

^KT-53015 In progress

Extract KotlinClassInfo to a separate class

to reduce the size of IncrementalJvmCache and prepare for the next
change.

^KT-54144 In progress

Ignore inline functions that are not found in the bytecode

^KT-54144 In progress

Add unit test for handling `@JvmName`s

Test: KotlinOnlyClasspathChangesComputerTest
             #testFunctionsAndPropertyAccessorsWithJvmNames
^KT-54144 Fixed

Update unit tests for handling `@JvmName`s

In a previous commit, we made a behavior change for inline property
accessors: The existing behavior is that if the implementation of an
inline getter has changed, only usages of the getter will be impacted
but not usages of the setter (and vice versa).

After that previous commit, usages of *both* the getter and setter will
now be impacted (i.e., we might compile slightly more files). This is
because a change to either the getter or the setter will now be
considered a change to the property, which will help simplify our change
analysis.

This commit updates the relevant unit tests to reflect the new behavior.

Test: Updated Incremental*TestGenerated.PureKotlin#testInlinePropertyInClass
      and Incremental*TestGenerated.PureKotlin#testInlinePropertyOnTopLevel

^KT-54144 Fixed
2022-11-10 10:03:55 +01:00
Zalim Bashorov ff2d3d0bdb [Wasm] Remove unnecessary --experimental-wasm-eh option while running d8 and nodejs
The support for Exception Handling proposal is turned on by default everywhere.
2022-11-09 13:44:38 +01:00
Sergej Jaskiewicz 7b7c517dbb [JS IR] Emit original names for local vars to sourcemaps
#KT-35655 Fixed
2022-11-09 12:35:44 +00:00
Alexander Korepanov c0a1fa6f98 [JS IR] Move the JS AST serialization right before the IC data committing
It allows not to keep the binary representation in memory
2022-11-08 15:18:44 +00:00
Alexander Korepanov 731dd9c3e8 [JS IR] More detailed time measurement for the IC infrastructure 2022-11-08 15:18:43 +00:00
Alexander Korepanov cb7df4d428 [JS IR] IrModuleToJsTransformerTmp.kt -> IrModuleToJsTransformer.kt 2022-11-07 17:57:41 +00:00
Alexander Korepanov 041e755c70 [JS IR] Cleanup BackendContext flags 2022-11-07 17:57:41 +00:00
Alexander Korepanov d17794481d [JS IR] Replace IrModuleToJsTransformer with IrModuleToJsTransformerTmp 2022-11-07 17:57:38 +00:00
nataliya.valtman 9b212cfa86 Revert "Extract KotlinClassInfo to a separate class"
This reverts commit ec3da62672.
2022-11-07 13:59:32 +01:00
Hung Nguyen ec3da62672 Extract KotlinClassInfo to a separate class
to reduce the size of IncrementalJvmCache and prepare for the next
change.

^KT-54144 In progress

Handle changes to inline functions/property accessors with `@JvmName`s

If we detect a change in an inline function `foo` with @JvmName
`fooJvmName`, we have two options:
   1. Report that function `foo` has changed
   2. Report that method `fooJvmName` has changed

Similarly, if we detect a change in an inline property accessor with
JvmName `getFoo` of property `foo`, we have two options:
   1. Report that property `foo` has changed
   2. Report that property accessor `getFoo` has changed

The compiler is guaranteed to generate `LookupSymbol`s corresponding to
option 1 when referencing inline functions/property accessors, but it is
not guaranteed to generate `LookupSymbol`s corresponding to option 2.
(Currently the compiler seems to support option 2 for *inline*
functions/property accessors, but that may change.)

Therefore, we will choose option 1 as it is cleaner and safer.

^KT-54144 In progress

Ignore inline functions that are not found in the bytecode

^KT-54144 In progress

Add unit test for handling `@JvmName`s

Test: KotlinOnlyClasspathChangesComputerTest
             #testFunctionsAndPropertyAccessorsWithJvmNames
^KT-54144 Fixed

Small cleanup in IncrementalCompilerRunner

 - Add comment for closing caches
 - Rename providedChangedFiles to changedFiles
 - Tiny clean up in `performWorkBeforeCompilation`
 - Count directories to delete in debug logs

^KT-53015 In progress

Small cleanup in IncrementalCompilerRunner

 - Add comment for closing caches
 - Rename providedChangedFiles to changedFiles
 - Tiny clean up in `performWorkBeforeCompilation`
 - Count directories to delete in debug logs

^KT-53015 In progress
2022-11-07 13:10:02 +01:00
Dmitriy Novozhilov 097a86deb5 [Test] Check that FIR tree does not contain stub types and type variable types after resolution 2022-11-03 08:30:08 +00:00