Commit Graph

345 Commits

Author SHA1 Message Date
Svyatoslav Kuzmich 384c700a85 [Wasm] Fix access to WebIDL dictionary members
Evaluate external interface companion objects as an empty JS object
instead of null due to null checks on interop boundary.

^KT-59082 Fixed
2023-07-25 15:27:22 +00:00
Igor Yakovlev e8e8a26cd1 [Wasm] Fixed invalid delegated property getters lowering
#Fixed KT-58941
2023-07-24 18:15:16 +00:00
Shagen Ogandzhanian eb7805baf9 [KT-59294] [wasm] Resolve undefined to null for any nullable types in external functions 2023-07-21 19:13:57 +00:00
Zalim Bashorov 5d1379ead1 [Wasm] Optimize when using br_table only if all conditions read and compare the same variable
#KT-60212 Fixed
2023-07-21 17:27:16 +00:00
Zalim Bashorov 8d440a61e2 [Wasm] Make types for none and noextern consistent with the spec 2023-07-20 11:49:28 +00:00
Ivan Kylchik ca8db7d0b8 [IR] Move toIrConst method into common IrUtils file
This method is used not only in IR interpreter, so it makes sense to
move it.
2023-07-19 15:12:54 +00:00
Artem Kobzar 41f27d19b5 [K/JS, K/Wasm] Generate star imports for external objects with the @JsModule annotation for ES modules 2023-07-18 15:36:19 +00:00
Dmitriy Novozhilov 8ad202eb8b [IR] Remove descriptor-related methods from SymbolTable
Replace them with calls to SymbolTableExtension
2023-07-17 21:02:39 +00:00
Igor Yakovlev b5eafb9eb7 [Wasm] WasmExport implementation 2023-07-07 20:45:51 +00:00
Sergei Kharitontcev-Beglov 34c6afec5e [Wasm] A name cache to distinguish same named declarations in DCE dump 2023-07-07 17:42:00 +00:00
Sergei Kharitontcev-Beglov 55bfd3efcb KT-52178: Argument propagation into IR backend & lowering dump action 2023-07-06 10:55:26 +00:00
Sergej Jaskiewicz 0ae95b39c3 [IR] Reorder parameters in IrFactory#createConstructor
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-22 16:31:17 +00:00
Sergej Jaskiewicz 0b7db067e6 [IR] Reorder parameters in IrFactory#createField
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-22 15:55:02 +00:00
Ilya Goncharov d865202bd5 [Wasm] Inline _importModule
^KT-59556 fixed
2023-06-22 13:56:47 +00:00
Abduqodiri Qurbonzoda 295fdc36ce Enum.valueOf throws inconsistent exception across multiple platforms #KT-35116 2023-06-16 22:18:20 +00:00
Ivan Kylchik b9856320cf [IR] Rename fqName to packageFqName for IrPackageFragment 2023-06-02 16:38:04 +00:00
Artem Kobzar bfd57fd2df [K/JS, K/Wasm] Optimize simple objects declaration and usage ^Fixed KT-58797 2023-06-02 14:23:40 +00:00
Igor Yakovlev 53783daeaf Codereview 2023-05-31 10:46:24 +00:00
Igor Yakovlev 39c8d5759b Codereview 2023-05-31 10:46:24 +00:00
Igor Yakovlev c71a2c6dd3 Codereview 2023-05-31 10:46:24 +00:00
Igor Yakovlev 78b72efd32 [Wasm] Make Arrays' constructors with size and lambda inline
Fixed #KT-58746
2023-05-31 10:46:24 +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
Igor Yakovlev 1749bafc30 [Wasm] Rename dateref to structref 2023-05-19 15:50:07 +00:00
Igor Yakovlev 1e0be4e0af [Wasm] Fix null constant typed with external class upperbound 2023-05-19 15:50:06 +00:00
Igor Yakovlev 6adfd91169 Revert "[Wasm] Revert a7ed496a and few fixes to make Kotlin/Wasm compatible with Firefox"
This reverts commit 1d793f7bec.
2023-05-19 15:50:06 +00:00
Igor Yakovlev 6437d0919c [Wasm] Replace deprecated cast instructions 2023-05-19 15:50:06 +00:00
Evgeniy.Zhelenskiy bf5fa61ffb [IR] Unify MFVC bridge redirection, fix related bugs, support MFVC overriding functions with default parameters
#KT-1179
2023-05-04 16:44:18 +00:00
Pavel Kunyavskiy f55fd481e9 [K/N] Refactor default argument lowering to avoid boxing
Current inline classes API is not compatible between different backends.
So implementing common function required for this optimization
was not possible in Native backend.

So, common default arguments lowering was refactored to make bigger
piece of code replaceable in backends.

^KT-57860
2023-05-01 13:04:21 +00:00
Zalim Bashorov 62b21ac078 [Wasm] Add an option to dump reachability info to file 2023-04-25 19:44:02 +02:00
Zalim Bashorov a9683bd4a8 Wasm: temporary force keeping Unit_getInstance in DCE 2023-04-22 17:41:23 +00:00
Artem Kobzar 33c5068b79 [K/JS] Rework IR deserialization and lowering phases to consume less memory 2023-04-19 13:10:19 +00:00
Dmitriy Dolovov 87125d0703 [PL] Fix: Don't run partial linkage on early stages when no external dependencies have been loaded yet 2023-04-18 09:22:54 +00:00
Zalim Bashorov c114afb55d [Wasm] export __callFunction_* only when a respective closure/lambda converter is used 2023-04-17 16:15:21 +00:00
Igor Yakovlev 49beec33b4 [Wasm] Replace ClassId and InterfaceId with single TypeId 2023-04-04 18:39:18 +00:00
Igor Yakovlev b8f797af00 [Wasm] Support for Associated Objects feature 2023-04-04 18:39:17 +00:00
Igor Yakovlev 993334e5e4 [Wasm] Support feature InstantiationOfAnnotationClasses 2023-04-04 18:39:17 +00:00
Dmitriy Dolovov 2a4d880037 [PL] Deep rework of the partial linkage
1. Leaving no unbound symbols in the IR tree, KT-54491:
   - All unbound symbols are bound to synthetic stub declarations
   - Improved detection of the root cause for every partially linked classifier
   - Improved error messages

2. Visibility valiation, KT-54469

3. Always check deserialized symbols:
   If the deserialized symbol mismatches the symbol kind at the call site in the deserializer then generate and reference another symbol with the same signature. In case PL is off, just throw IrSymbolTypeMismatchException.

4. Handle class inheritance violation:
   - Detect illegal inheritance (ex: inheriting from a final class)
   - Detect invalid constructor delegation (ex: delegating to another class than the direct superclass)
   - Simplification: Reduce the number of PartialLinkageCase subclasses
   - Reworked error message generation to have shorter and clearer messages

5. Handle class transformations and all known side-effects, examples:
   - nested <-> inner
   - class <-> enum/object
   - adding/removing subclasses of sealed class
   - adding/removing enum entries

6. Check direct instantiation of abstract class.
   Such instantiation could be possible if a class was non-abstract in the previous version of a library.

7. Handle unlinked annotations on declarations.
   Such annotations are removed from the IR. The appropriate compiler error message is produced for every individual case.

8. Handle value argument count mismatch at call sites

9. Handle calling suspend function from non-suspend context.
   This could happen if a suspen function was non-suspend in the previous version of a library.

10. Handle overriding inline callables.
    Only the leaf final callable can be marked with `inline`.

11. Detect illegal non-local returns from noinline/crossinline lambdas.
2023-03-23 10:24:27 +00:00
Dmitriy Dolovov eec511a767 [PL] Fix line/column numbers in error messages 2023-03-23 10:24:25 +00:00
Svyatoslav Kuzmich 1b7c63bd49 [Wasm] Fix js interop closure signature
Before we used IrType.render() which is not unique.
This changes adds a proper serialization of adapter signature to string.
2023-03-20 15:16:00 +00:00
Vsevolod Tolstopyatov 33d13474c5 Make EnumEntries implementation eager
* Addresses the recent design changes of the corresponding language feature
* Also rework JS/Wasm enumEntries implementation with the function that accepts array instead of fabric function


^KT-57318


Co-authored-by: Artem Kobzar <Artem.Kobzar@jetbrains.com>

Merge-request: KT-MR-9204
Merged-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
2023-03-20 10:18:28 +00:00
Svyatoslav Kuzmich 1208a26fc4 [Wasm] Use JsAny, JsHandle and other Js* types in stdlib and kotlin-test 2023-03-16 09:12:07 +00:00
Svyatoslav Kuzmich d6886d69ec [Wasm] Add internal JsPrimitive annotation
Before external classes could only represent JS object types and are
type-checked with `instanceof`.
@JsPrimitive allows external classes to represent primitive types with
`typeof` checks.
2023-03-16 09:12:07 +00:00
Svyatoslav Kuzmich a99ea1d3ce [Wasm] Support enumValues and enumValueOf functions
^KT-57276 Fixed

Merge-request: KT-MR-9169
Merged-by: Svyatoslav Kuzmich <svyatoslav.kuzmich@jetbrains.com>
2023-03-13 14:13:31 +00:00
Svyatoslav Kuzmich d5b958f744 [Wasm] Support default parameter values in functions with js(code) 2023-03-09 12:50:14 +00:00
Svyatoslav Kuzmich 71e6b19760 [Wasm] Support restricted version of js("code") (KT-56955) 2023-03-03 19:39:09 +00:00
Svyatoslav Kuzmich 3c35328c09 [Wasm] Fix overriding external fun with default parameters (Fix KT-56976) 2023-03-03 12:33:53 +00:00
Svyatoslav Kuzmich 26c1098a4f [Wasm] Fix inliner issues (KT-56584)
* Fix objects in inline functions and lambdas:
  * Add common lowerings used in K/JS and K/Native
* Fix inline lambda call detection logic in presence of additional casts


Merge-request: KT-MR-8791
Merged-by: Svyatoslav Kuzmich <svyatoslav.kuzmich@jetbrains.com>
2023-02-13 13:14:43 +00:00
Zalim Bashorov f3e022e4ca [Wasm] Print an instruction if CompileError was thrown while instantiating a module
#KT-56160 Fixed
2023-02-03 14:06:32 +01:00
Svyatoslav Kuzmich 2e26b0956e [Wasm] Improve stability of wasm import names across compiler runs
Remove code generation for external fake overrides
Fake overrides are resolved to real declaration on call sites
This also removes generation of unused
"equals", "hashCode" and "toString" methods.
Avoid using hashes of IrType in generated code
because they are unstable

Merge-request: KT-MR-8658
Merged-by: Svyatoslav Kuzmich <svyatoslav.kuzmich@jetbrains.com>
2023-02-03 06:55:59 +00:00
Zalim Bashorov 885381dd63 [Wasm] Change externRefToAny to make it compatible with SpiderMonkey and V8
It's hard to achieve that without implementing part of `externRefToAny` using an intrinsic. It should be rewritten when all VMs and tools update to the latest spec.

Also, stop using (deprecated) instructions unsupported by SpiderMonkey.

#KT-56166 In-Progress
2023-01-27 17:57:50 +01:00