Commit Graph

88 Commits

Author SHA1 Message Date
Artem Kobzar 71486a321c [K/JS] Add support of compilation with ES-classes 2023-01-17 18:14:17 +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
Artem Kobzar 8a89b2f29f [K/JS] Remove the old interface runtime check because of bootstrapping
Merge-request: KT-MR-7457
Merged-by: Artem Kobzar <Artem.Kobzar@jetbrains.com>
2022-10-21 11:34:31 +00:00
Ilya Gorbunov 607f15b55b Sycnhronize docs of primitives in JS-IR, Wasm, Native sources 2022-10-02 19:04:37 +00:00
Artem Kobzar 73e7053c35 [K/JS] Use only single variant of default arguments function wrapper for exported and not-exported functions 2022-09-19 17:49:04 +00:00
Artem Kobzar d9c5f100db [K/JS] Use intrinsics instead of new functions in IR backend. 2022-09-19 13:04:16 +00:00
Artem Kobzar a368fc37c7 [K/JS] Make interface subtyping faster and lighter. 2022-09-19 10:26:11 +00:00
Ilya Gorbunov 203a00151d rangeUntil member operator in builtins #KT-52933 2022-08-24 22:22:53 +00:00
Artem Kobzar 87038e7d8a [K/JS] feat: add logic under the flag for strict implicit export generating inside d.ts files. 2022-08-09 16:48:59 +00:00
Ilya Gorbunov 000165b12b Fix incorrect conversion of Long to String in base 36 in JS KT-48924 2022-03-30 06:13:51 +00:00
Artem Kobzar 0153f5d92a chore: set isComplete flag also for interfaces that do not contain constructor fields. 2022-03-21 18:53:04 +00:00
Artem Kobzar ac542d4c01 feat(JS/IR isInterfaceImpl perf): improve isInterfaceImpl performance by memoize an result. 2022-02-28 20:28:10 +00:00
Artem Kobzar 804eb61bf0 feat: add polyfills insertion for ES Next used features 2022-02-16 10:49:11 +00:00
Alexander Korepanov 769fbcf3d0 [JS IR] Improve performance for runtime typecheck
This is a part of KT-42743
2022-01-31 09:15:58 +00:00
Sergej Jaskiewicz d5e46e0607 [JS IR] Introduce intrinsics for slicing array-like objects 2022-01-27 11:06:16 +00:00
Sergej Jaskiewicz 08e6116ecb [JS IR] Introduce jsArguments() intrinsic function
`jsArguments()` is lowered into a reference of the `arguments` object.

This is useful for extracting varargs, when calling Kotlin code from
JavaScript. For a concrete example, see KT-15223.
2022-01-27 11:06:16 +00:00
Dmitriy Dolovov 3ec4a8d6f3 [IR] Rename LinkageError symbol to IrLinkageError
This is needed to 1) avoid ambiguity about the type of linkage used in Kotlin/Native compiler, 2) have the same exception name in JS and Native backends.

^KT-50775
2022-01-26 13:36:24 +03:00
Sergej Jaskiewicz ceb744b53b Revert "[JS IR] [runtime] Remove valueOf method from Long"
This reverts commit e13b6b2a90.

The significance of the breakage caused by the removal of `valueOf`
was underestimated.

#KT-50202 Open
2022-01-18 10:33:54 +00:00
Sergej Jaskiewicz 86cabf3bb7 [JS IR] Use Uint16Array as CharArray's storage 2021-12-02 12:39:41 +00:00
Sergej Jaskiewicz 67dfe7bed1 [JS IR] Make Char a value class (again)
#KT-35100 Fixed
2021-12-02 12:39:40 +00:00
Sergej Jaskiewicz e13b6b2a90 [JS IR] [runtime] Remove valueOf method from Long
This method was used for coercing `Long` values to JavaScript
`number`. However, it caused issues when `Long` values were
concatenated to a string (see KT-8666, KT-26706).
2021-12-01 12:36:34 +00:00
Artem Kobzar 08b0e17d47 feat(polyfills): use stdlib for js polyfills. 2021-11-26 08:14:34 +00:00
Roman Artemev 7f27ebc589 [JS IR] Add API to js runtime to throw linkage errors 2021-11-19 01:16:35 +03:00
Anton Bannykh ee6d3ea281 [JS IR] mark coroutine intrinsics as inline
They are de-facto inlined, but their bodies don't get
loaded when using the "no bodies except for inline functions"
deserializtion mode.
2021-11-19 00:39:06 +03:00
Svyatoslav Kuzmich a6afb7cb41 [JS IR][Wasm] Preload (Suspend)FunctionN needed in lowerings
This reverts commit 15d178d850d15675ee39cbd833d13f4c8aed83ff.
2021-10-12 08:42:01 +03:00
Svyatoslav Kuzmich 3bce0cc055 [Wasm] Support coroutines
- Reuse JS IR Suspend function lowering
  - Fix types
  - Disable reinterpretCast-based optimization for inline
    classes
- Add basic support to Wasm stdlib
- Explicitly transform suspend functions into regular functions
  with continuations
- Clean suspend function handling from JS IR codegen
2021-10-12 08:42:01 +03:00
Ilya Goncharov b5fb0d9f33 [JS IR] Deprecate safeProperty(Get|Set) methods from stdlib 2021-10-01 13:21:19 +00:00
Ilya Goncharov 42e8017cc7 [JS IR] Revert removing of safeProperty(Get|Set) 2021-09-24 07:07:12 +00:00
Ilya Goncharov 064744fae7 [JS IR] Remove redundant legacy property access property 2021-09-24 07:07:12 +00:00
Ilya Goncharov a28138eb72 [JS IR] Change js function on Kotlin code
^KT-46204 fixed
2021-08-10 07:24:49 +00:00
Ilya Goncharov 3c9dcdbbee [JS IR] Generate suspend function as invoke
[JS IR] Fix type check utils to work with array of arities

[JS IR] Store multiple arities for suspend functional interface implementers

^KT-46204 fixed
2021-08-10 07:24:46 +00:00
Ilya Goncharov 82f979b11f [JS IR] Add property name to boolean in externals diagnostic 2021-06-29 10:12:55 +00:00
Ilya Goncharov 21a3494bca [JS IR] Add test with boolean in external interface
[JS IR] Add possibility to safely access Boolean in external declaration

[JS IR] Add diagnostic for booleans in externals
2021-06-29 10:12:54 +00:00
Alexander Udalov f430d569d0 Fix warnings in js-ir/runtime/jsIntrinsics.kt
Suppress "UNUSED_PARAMETER" to fix compilation warnings. Also suppress
"unused" to make the file less yellow in the IDE.

Also enable `-Werror`, unless Gradle property
`kotlin.build.disable.werror` is set to true.
2021-06-28 12:19:35 +02:00
Anton Bannykh 48fe46303d JS IR: declare intrinsics for lowerings in stdlib
- simplifies lowered IR serialization
- removes some hacks in jsOperators.kt
- intrinsics can be directly invoked in stdlib
2021-06-18 15:26:52 +03:00
Anton Bannykh 6633a9edc0 [JS IR] add a flag which enable safe property access
If an accessor is not available at runtime we fall back
to the property access.

This is useful in cases when JS objects are casted to Kotlin
classes implicitly. This pattern did work in the old BE, which
lead to a significant amount of code which doesn't work anymore.
2021-05-20 16:37:34 +03:00
Ilya Gorbunov ce7092a638 More efficient Char(Int) in common, JS, and JS-IR 2021-04-16 03:58:34 +03:00
Abduqodiri Qurbonzoda 98d31a1813 Expand KDoc of inc() and dec() operators #KT-43701 2021-04-10 03:23:04 +03:00
Ilya Gorbunov b64b96eee6 Deprecate Char-to-Number conversions in stdlib (JVM and JS)
- Int.toChar was left non-deprecated because the replacement is not intrinsic yet.
- Number.toChar was left non-deprecated because otherwise the deprecation propagates to the override, Int.toChar.

KT-23451
2021-04-07 18:30:20 +03:00
Ilya Gorbunov d70edeb38b Hide deprecated JS Math object from public API and rename to JsMath
KT-41318

- Rename Math to JsMath and remove unused functions
- Fix return types, remove duplicating JsMath from longjs.kt

Co-authored-by: Abduqodiri Qurbonzoda <abduqodiri.qurbonzoda@jetbrains.com>
2021-04-07 00:39:47 +03:00
Ilya Gorbunov 7e2c365b79 Generate docs for floorDiv and mod and improve docs for div and rem
Refactor operator documentation generation for primitives and unsigned
types so that it is easier to specialize it.

Manually sync docs of numeric types in js-ir stdlib.

 KT-26234
2021-03-05 07:32:16 +03:00
Ilya Goncharov bd2601f289 [JS IR] Extract adding of function call to another function
[JS IR] Add option for dce mode

[JS IR] Add logging to non useful declarations if appropriate dce mode

[JS IR] Add mode with throwing exception

[JS IR] unreachableDeclaration method is in rootDeclarations

[JS IR] Add js extra help arg with dce mode and include debug.kt to compile unreachableMethod

[JS IR] unreachableDeclaration as internal to not reproduce stdlib api

[JS IR] Fix description of dce mode argument

- Use console.error instead of console.log
- Use JsError instead Kotlin exception for lightweight

[JS IR] Remove body for throwing exception

[JS IR] Remove default parameter in unreachableDeclaration

[JS IR] Process without removing fields and declaration containers

[JS IR] Rename dce mode on dce runtime diagnostic

[JS IR] Use console.trace instead of console.error

[JS IR] Extract JsError

- Fix naming in prependFunctionCall
- Fix description on runtime diagnostic argument
- Using message collector instead of throwing exception

[JS IR] Distinguish unreachableMethods for log and exception

[JS IR] Extract checking of Kotlin packages of IrField

^KT-45059 fixed
2021-02-20 12:05:06 +03:00
Svyatoslav Kuzmich 218c246111 [JS] Fix extra js function capturing 2021-02-04 15:41:21 +03:00
Svyatoslav Kuzmich cb3b1f8ae2 [JS IR] Fix referencing Kotin variables in inline JS code
Fixed by outlining JS code that uses Kotlin variables making usages of
these locals explicit and preventing bugs due to one-sided variable renaming.

This prevents using Kotlin variables as lvalue in JS code.
2021-01-25 19:18:44 +03:00
Roman Artemev c16b11a124 [JS IR BE] Fix throwable stuff to make exceptions similar to JVM 2020-10-12 15:22:43 +03:00
Roman Artemev ff093d363a [JS IR BE] Fix Throwable ancestor transformation
Make sure that `message` and `cause` are properly configured

 - synchronize IR BE and Legacy behaviour
 - fix corresponding IR lowering
 - fix JS IR core runtime
 - add test
 - fix KT-39964
2020-10-12 15:22:43 +03:00
Abduqodiri Qurbonzoda 36e6247125 Add more details about bit shift operations #KT-41112 2020-09-16 04:05:12 +03:00
Roman Artemev 8a810e2a5e [JS IR] Add runtime API to throw ISE in case of compiled code with errors 2020-09-01 14:53:07 +03:00
Alexander Udalov da6d904c6e Suppress code warnings in kotlin-stdlib 2020-08-20 20:30:34 +02:00
Svyatoslav Kuzmich 6792779281 [JS IR] Fix stack trace capturing in secondary constructors (KT-37563)
Call captureStack in primary constructors and generated factories
2020-06-22 11:50:14 +03:00