Commit Graph

299 Commits

Author SHA1 Message Date
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
Zalim Bashorov d1855371a0 [Wasm] Don't wrap single null expression into composite in WasmNullCoercingLowering
Otherwise, it breaks check/assert inside DeclarationGenerator::visitField (DeclarationGenerator.kt:458)

#KT-56166 In-Progress
2023-01-27 17:57:50 +01:00
Zalim Bashorov ca79711610 [Wasm] Generate .mjs compatible with other standalone js & wasm VMs: SpiderMonkey and JavaScriptCore in addition to V8
#KT-56166 In-Progress
2023-01-27 17:57:50 +01:00
Zalim Bashorov 1d793f7bec [Wasm] Revert a7ed496a and few fixes to make Kotlin/Wasm compatible with Firefox
Revert changes as soon as the bug is fixed https://bugzilla.mozilla.org/show_bug.cgi?id=1811932

a7ed496a "[WASM] Use wasm bottom types for Nothing?"

#KT-56166 In-Progress
2023-01-27 17:57:49 +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
Zalim Bashorov ab1cbc49dd [Wasm] Minor: move buildUnreachable* helpers to more specific module 2023-01-17 19:37:05 +01:00
Zalim Bashorov 37879e18d9 [Wasm] Pass location instead of fileEntry to generateConstExpression 2023-01-17 19:37:05 +01:00
Zalim Bashorov aa8a0fd7d7 [Wasm] Remove LocationHolder and helper functions
It turned out that dedicated scoping function for locations are not so useful.
Now, if you want to scope a location use functions from stdlib, like `let`.
2023-01-17 19:37:05 +01:00
Zalim Bashorov 0d203d190e [Wasm] Remove buildInstr without location and fix usages 2023-01-17 19:37:05 +01:00
Zalim Bashorov 42f2edd282 [Wasm] Require location for buildThrow and fix all usages 2023-01-17 19:37:05 +01:00
Zalim Bashorov 1244cd1259 [Wasm] Require location for buildBr* and fix all usages 2023-01-17 19:37:05 +01:00
Zalim Bashorov 95c84d5d3f [Wasm] Require location for buildDrop and fix all usages 2023-01-17 19:37:05 +01:00
Zalim Bashorov 6eba0392db [Wasm] Require location for buildRefNull and fix all usages 2023-01-17 19:37:05 +01:00
Zalim Bashorov 12854af0a2 [Wasm] Require location for buildRefTestStatic and fix all usages 2023-01-17 19:37:05 +01:00
Zalim Bashorov 7bd92bc412 [Wasm] Require location for buildRefCastNullStatic and fix all usages 2023-01-17 19:37:05 +01:00
Zalim Bashorov 158a307334 [Wasm] Require location for buildStructSet and fix all usages 2023-01-17 19:37:05 +01:00
Zalim Bashorov e7dc443c18 [Wasm] Require location for buildStructGet and fix all usages 2023-01-17 19:37:04 +01:00
Zalim Bashorov 530438dfcb [Wasm] Require location for buildStructNew and fix all usages 2023-01-17 19:37:04 +01:00
Zalim Bashorov 3967bd2755 [Wasm] Require location for buildSetGlobal and fix all usages 2023-01-17 19:37:04 +01:00
Zalim Bashorov 65e1b53027 [Wasm] Require location for buildGetGlobal and fix all usages 2023-01-17 19:37:04 +01:00
Zalim Bashorov 00d0c38fc3 [Wasm] Require location for buildSetLocal and fix all usages 2023-01-17 19:37:04 +01:00
Zalim Bashorov 0b59ef58dc [Wasm] Require location for buildGetLocal and fix all usages 2023-01-17 19:37:04 +01:00
Zalim Bashorov e5e786c265 [Wasm] Use more specific types in generateExpression and generateStatement
Also, rename: `generateStatement` -> `generateAsStatement`
2023-01-17 19:37:04 +01:00
Zalim Bashorov ce265c049a [Wasm] Require location for buildUnreachable and fix all usages 2023-01-17 19:37:04 +01:00
Zalim Bashorov 36d4e29253 [Wasm] Require location for buildConstI32Symbol and fix all usages 2023-01-17 19:37:04 +01:00
Zalim Bashorov e69bbdd5b4 [Wasm] Require location for buildConstF32 & buildConstF64 and fix all usages 2023-01-17 19:37:04 +01:00
Zalim Bashorov 332aca10b0 [Wasm] Require location for buildConstI64 and fix all usages 2023-01-17 19:37:04 +01:00
Zalim Bashorov f2f4c63720 [Wasm] Require location for buildConstI32 and fix all usages 2023-01-17 19:37:04 +01:00
Zalim Bashorov cdc1d66b1f [Wasm] Require a description on each usage of SourceLocation.NoLocation 2023-01-17 19:37:04 +01:00
Zalim Bashorov 61440c74d5 [Wasm] Require location for buildCall and fix all usages 2023-01-17 19:37:03 +01:00
Svyatoslav Kuzmich d14d4c8510 [Wasm] Support JsModule and JsQualifier 2023-01-13 21:58:34 +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
Igor Yakovlev f7940a2d46 [Wasm] Fix invalid cast generation for inline classes 2023-01-04 17:16:04 +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
Igor Yakovlev fc80104d55 [Wasm] Fix external functions import clashing 2022-12-29 11:57:47 +00:00
Igor Yakovlev 4e24a9caa5 [Wasm] Cache down-casted dispatcher receiver in virtual functions 2022-12-29 11:57:46 +00:00
Igor Yakovlev 3be3ae4895 [Wasm] Fix invalid boxing for non-primitive typed vararg 2022-12-29 11:57:46 +00:00
Igor Yakovlev 1b2b7ce34c [Wasm] Support Number type for external functions 2022-12-29 11:57:45 +00:00
Igor Yakovlev 4dedd47172 [Wasm] Fix JsName external declarations 2022-12-29 11:57:45 +00:00
Svyatoslav Kuzmich 9d099348ba [Wasm] Disable interop adapters for WasmImport
Merge-request: KT-MR-8152
2022-12-28 17:33:51 +00:00
Svyatoslav Kuzmich 62217b39ec [Wasm] Rename WasmImportPair -> WasmImportDescriptor 2022-12-28 12:14:16 +01: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
Svyatoslav Kuzmich d788adcbb5 [Wasm] Move non-recursive function types out of rec group
This fixes linking with other wasm modules with non-rec types
2022-12-21 20:20:13 +00:00
Svyatoslav Kuzmich 62ac77ca39 [Wasm] Add comments to .wat files 2022-12-16 13:57:59 +00:00
Svyatoslav Kuzmich 777bb0f0cb [Wasm] Rename Wasm*CodegenContextImpl to Wasm*CodegenContext 2022-12-13 16:08:49 +01:00
Svyatoslav Kuzmich b9b2723b0a [Wasm] Remove Wasm*CodegenContext interfaces
Use classes instead
2022-12-13 16:08:48 +01:00