Commit Graph

1457 Commits

Author SHA1 Message Date
Artem Kobzar c4eca5f2df [K/JS] Exclude componentN methods from JsExport 2023-01-17 21:18:50 +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
Dmitriy Novozhilov 83cbd322fd [Test] Prohibit declaring dependency on the same module with different kinds in module structure 2023-01-17 14:51:27 +00:00
Svyatoslav Kuzmich 951b8026f5 [JS, Wasm] Don't generate unused constructors for interfaces 2023-01-17 09:14:57 +00:00
Abduqodiri Qurbonzoda dc03a03762 Introduce basic, url-safe and mime Base64 variants #KT-9823 2023-01-16 11:24:49 +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
Svyatoslav Kuzmich d14d4c8510 [Wasm] Support JsModule and JsQualifier 2023-01-13 21:58:34 +00:00
Svyatoslav Kuzmich 75d3ae4466 [Wasm] Don't try to lazy-initialize properties with 'definedExternally'
NFC for K/JS since externals live in a separate place
2023-01-13 21:58:33 +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
Artem Kobzar 6a6308bef2 [K/JS] add miss StartProjection for the substitution inside lowerings ^KT-55852 Fixed 2023-01-13 13:28:42 +00:00
Svyatoslav Kuzmich 1564de5859 [Wasm] Support external vararg
Initial implementation copies Wasm array to JS array and spreads it
2023-01-11 10:35:36 +00:00
Artem Kobzar 642bbd38ba [K/JS] Move global interface id state into an object to prevent interface ids reinitialization ^Fixed KT-55758 2023-01-09 20:56:19 +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
Nikolay Lunyak a20e29e8b7 [FIR JS] Implement FirJsExternalChecker
The JsAllowValueClassesInExternals feature is enabled explicitly,
because otherwise it's enabled
implicitly depending on the backend. See:
org/jetbrains/kotlin/test/builders/LanguageVersionSettingsBuilder.kt:90

A property may have a fake source return kind, while its accessor
has a real source kind. In this case we can't "just copy"
the property return type down to the accessor.
2023-01-09 08:57:11 +00:00
Artem Kobzar 97be632c9a [K/JS] Add @ts-ignore for the case when there is a class with a private primary constructor (or excluded from export) which has an exported subclass ^Fixed KT-52563 2023-01-04 15:21:40 +00:00
Svyatoslav Kuzmich 9bc6b420a9 [Wasm][Stdlib] Add public APIs for linear memory access
Needed for interop with APIs that use linear memory.
2022-12-29 19:25:23 +00:00
Artem Kobzar cd0ae20c38 [K/JS] Capture stackTrace before the init function call ^Fixed KT-55315 2022-12-20 18:15:02 +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
Steven Schäfer 6af616d3c3 FIR: make declarations marked with 'override' implicitly open
#KT-52236 Fixed
2022-12-14 21:46:41 +00:00
Dmitriy Novozhilov 3cffb33ab7 [FE] Drop ApproximateIntegerLiteralTypesInReceiverPosition language feature
This feature is not needed because it is unconditionally disabled for K1
  (because of not fully correct implementation) and unconditionally enabled
  in K2 (K2 does not support old behavior)

^KT-38895
2022-12-09 15:10:02 +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
Artem Kobzar 0f0421ea3d [K/JS] Generating TypeScript definitions for exceptions and rest of the types ^Fixed KT-53940 2022-12-01 15:01:24 +00:00
Artem Kobzar 67048151fb [K/JS] Change js-call inlining strategy and + ability to referencethis safely from the js call ^Fixed KT-54134 2022-11-30 11:43:22 +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
Artem Kobzar ad78f27cce [K/JS] Fix problem with dynamic return type inside coroutine 2022-11-23 21:33:56 +00:00
Artem Kobzar 725a224f74 [K/JS] Make available transitive reexport for ES modules 2022-11-18 16:54:10 +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
Ilya Chernikov c3197491a0 FIR JS: temporarily mute failing box tests 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 44cce3ad52 FIR JS: mute remaining tests for now 2022-11-12 16:28:23 +01:00
Ilya Chernikov 5b3816cce5 Test infra: refactor IGNORE_BACKEND directive
treat it as a general one, introduce *_K1 and *_K2 variants for
more specific ignoring
2022-11-12 16:28:23 +01:00
Ilya Chernikov e1d19516e8 [minor] fix import statement position in testdata
the import statement is (should be) ignored before FILE directive
2022-11-12 14:34:07 +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 31f3fbcd78 [JS, Wasm] Improve readability of the message printed for failed tests for kotlin.test 2022-11-11 16:22:10 +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
Ilya Goncharov 21991a70e0 [JS] Update npm dependencies in js tests 2022-11-04 15:52:19 +00:00
Sergej Jaskiewicz ba7f5afebe [JS IR] Generate debug info for catch parameters
We will need it to generate original names for catch parameters in
sourcemaps.

Also, don't generate redundant debug info for compiler-generated
exception handling control flow operators.

See the doc comment to the MultipleCatchesLowering class

#KT-46276
2022-11-02 13:14:01 +00:00
Sergej Jaskiewicz 4ae03ea74a [JS IR] Improve debug info for if and when statements
#KT-46276
2022-11-02 13:14:01 +00:00
Sergej Jaskiewicz ccbb2a08a0 [JS IR] Improve debug info for functions with default parameters
Don't generate unnecessary mappings so that the user doesn't need to
step in many times to get where they want

#KT-46276
2022-11-02 13:14:00 +00:00
Sergej Jaskiewicz 43c5c8b44f [JS IR] Fix debug info for Char, Long, and unsigned integer literals
Map class constructor calls to the literals they were generated
from.

#KT-46276
2022-11-02 13:13:59 +00:00
Sergej Jaskiewicz 512a2bfd7a [JS IR] Improve debug info for callable references and lambdas
#KT-46276
2022-11-02 13:13:59 +00:00