Commit Graph

652 Commits

Author SHA1 Message Date
Roman Efremov 8ce1417621 [Stdlib] Fix reports of MPP annotation checker
^KT-58551
2023-07-24 09:48:49 +00:00
mvicsokolova 298c4f8c32 [K/N] Introduce atomic arrays in K/N stdlib
This commit introduces API for AtomicIntArray, AtomicLongArray and AtomicArray<T>.

The current set of functions is implemented via atomic arrays intrinsics (see KT-58360) and provides sequentially consistent memory ordering guarantees and no spurious failures in compareAndSet/compareAndExchange operations.

For details see: KT-60608

Merge-request: KT-MR-11071
Merged-by: Maria Sokolova <maria.sokolova@jetbrains.com>
2023-07-21 15:30:20 +00:00
Svyatoslav Scherbina f18c6755cc Native: fix runtime compilation against older glibc versions
Replace `#include <inttypes.h>` with `cinttypes`.
Improve other includes in the same file.

^KT-58864


Co-authored-by: Alexander Shabalin <Alexander.Shabalin@jetbrains.com>
2023-07-19 14:41:51 +00:00
Abduqodiri Qurbonzoda fed453fdea Provide Common StringBuilder.append/insert with primitive type arguments #KT-57359
Merge-request: KT-MR-10892
Merged-by: Abduqodiri Qurbonzoda <abduqodiri.qurbonzoda@jetbrains.com>
2023-07-13 11:52:14 +00:00
mvicsokolova d9fa9c1b3b [K/N] Introduce intrinsics that atomically update array elements
Supported atomic update of elements for IntArray, LongArray and Array<T>
See KT-58360

Merge-request: KT-MR-11020
Merged-by: Maria Sokolova <maria.sokolova@jetbrains.com>
2023-07-12 14:32:36 +00:00
Abduqodiri Qurbonzoda f152fa537d Collection.toString() should not throw if it contains itself
Merge-request: KT-MR-10591
Merged-by: Abduqodiri Qurbonzoda <abduqodiri.qurbonzoda@jetbrains.com>
2023-07-11 09:58:38 +00:00
Aleksei.Glushko 96b44e0ad8 [K/N] concurrent weak sweep ^KT-57772 2023-07-04 13:42:59 +00:00
Abduqodiri Qurbonzoda aae8a687a4 [K/N] Internalize Retain and RetainForTarget annotations #KT-57710
As a part of efforts to stabilize Native stdlib.
2023-06-30 15:27:08 +00:00
Abduqodiri Qurbonzoda f665388704 Advance ExperimentalNativeApi opt-in requirement level to ERROR #KT-57838
As a part of efforts to stabilize Native stdlib.
2023-06-30 15:27:08 +00:00
Abduqodiri Qurbonzoda ba6ee484b8 Advance NativeRuntimeApi opt-in requirement level to ERROR #KT-57720
As a part of efforts to stabilize Native stdlib.
2023-06-30 15:27:08 +00:00
Abduqodiri Qurbonzoda 00abbc5cfe Advance ObsoleteNativeApi opt-in requirement level to ERROR #KT-57088
As a part of efforts to stabilize Native stdlib.
2023-06-30 15:27:08 +00:00
Aleksei.Glushko 5618ee84f8 [K/N] try to reimplement safe points with a load-branch-call 2023-06-30 14:12:17 +00:00
Alexander Udalov ab195b68a5 Build: remove explicit enabling of RangeUntilOperator
This feature is enabled by default since 1.8. Using the `-XXLanguage`
compiler argument leads to big warnings which are distracting during the
build.
2023-06-22 18:55:56 +00:00
Alexander.Likhachev 9d128c8d0d [Build] DeclarewriteStdlibVersion as an explicit dependency of K/N stdlib
#KTI-1221 In Progress
2023-06-22 15:16:08 +00:00
Alexander Shabalin 63e65a482c [K/N] Move GC schedulers into modules
Additionally,
- rename disabled into manual
- rename with_timer into adaptive
- remove on_safepoints
- store schedulers in GlobalData, ThreadData directly
2023-06-21 12:16:09 +00:00
Abduqodiri Qurbonzoda 1be0e3f70e Document that arrayOfNulls throws RuntimeException on negative size 2023-06-20 16:31:59 +00:00
Abduqodiri Qurbonzoda da8f9fbd04 Document that array constructor throws RuntimeException on negative size 2023-06-20 16:31:59 +00:00
Alexander Shabalin db2475f41e [K/N] Make STMS use separate threads for GC and finalizers.
Moves GC into a separate thread, and finalizers processing into yet
another thread. This makes STMS more similar to CMS.
2023-06-20 10:08:25 +00:00
Alexander Shabalin 6996e03bc9 [K/N] Build new MM only for targets with threads
Targets without threads are disabled already.
2023-06-20 10:08:25 +00:00
Abduqodiri Qurbonzoda 4ae19b2b44 [K/N] Deprecate SharedImmutable annotation #KT-57837
As a part of efforts to stabilize Native stdlib.
2023-06-19 11:35:32 +00:00
Abduqodiri Qurbonzoda 0cfb80144a [K/N] Throwable.printStackTrace() should print to the stderr output
Aligns with the JVM behavior.

As a part of efforts to stabilize Native stdlib.
2023-06-19 11:30:13 +00:00
Abduqodiri Qurbonzoda e6633d3d92 [K/N] Document that Throwable.stackTraceToString format is unstable
As a part of efforts to stabilize Native stdlib.

Merge-request: KT-MR-10637
Merged-by: Abduqodiri Qurbonzoda <abduqodiri.qurbonzoda@jetbrains.com>
2023-06-17 20:15:55 +00:00
Abduqodiri Qurbonzoda 295fdc36ce Enum.valueOf throws inconsistent exception across multiple platforms #KT-35116 2023-06-16 22:18:20 +00:00
Abduqodiri Qurbonzoda d6867917c9 Enum entry hashCode() should return identity hash code #KT-59223 2023-06-16 22:18:20 +00:00
Pavel Kunyavskiy 2f36886bac [K/N] Rewrite AtomicReference using intrinsics
^KT-59120
2023-06-15 13:53:13 +00:00
Alexander Shabalin 00fd0a421f [K/N] Remove runtime tests for legacy MM 2023-06-15 13:16:08 +00:00
Alexander Shabalin 43a7711fcc [K/N] Add CallsCheckerIgnoreGuard 2023-06-15 13:16:08 +00:00
Abduqodiri Qurbonzoda 193aa0f935 Align the Boolean.hashCode() value across platforms
Boolean.hashCode() should return 1231/1237 for true/false correspondingly.

As a part of efforts to stabilize Native stdlib.
2023-06-14 08:19:46 +00:00
Troels Bjerre Lund fffc921d42 [K/N] custom_alloc: fix race on extraobject ^KT-55364
This avoids that the thread sweeping the base object can get stale
locals, in the case that the finalizer thread unlinks the extraobject at
the same time. This is done by moving the responsibility of unlinking
the extraobject to the sweeping of the base object.


Co-authored-by: Troels Bjerre Lund <troels@google.com>

Merge-request: KT-MR-10518
Merged-by: Alexander Shabalin <Alexander.Shabalin@jetbrains.com>
2023-06-09 13:01:00 +00:00
Svyatoslav Scherbina 063e7258ee Native: don't dispatch release for null Obj-C refs to the main thread
Currently, if a Kotlin object happens to have null for an associated
object but FLAGS_RELEASE_ON_MAIN_QUEUE flag set, GC will dispatch
Kotlin_ObjCExport_releaseAssociatedObject(null) to the main thread
anyway.

This couldn't happen before, but can now, with disposeObjCObject.
The commit prevents this, by moving the null check out from
Kotlin_ObjCExport_releaseAssociatedObject to call sites.

^KT-59134
2023-06-07 11:57:54 +00:00
Svyatoslav Scherbina 1bf3d55bdf Native: add detachObjCObject internal function for Obj-C objects
For a Kotlin wrapper of an Objective-C object, this functions zeroes
and releases the strong reference from the Kotlin wrapper to the
Objective-C object.
Usually, such a release happens only when the Kotlin wrapper is GCed.
So using this function can help that happen sooner.

^KT-59134
2023-06-07 11:57:54 +00:00
Abduqodiri Qurbonzoda 0f4cca6877 [K/N] Throw OutOfMemoryError when String + String overflows 2023-06-06 18:11:57 +00:00
Abduqodiri Qurbonzoda 3917ec94ab [K/N] Use AbstractList.checkIndex() functions instead of custom check functions 2023-06-06 18:11:57 +00:00
cristiangarcia 46d113605b Adopt configuration-avoidance where possible
Before this change `./gradlew help` (with native enabled)
Created immediately: 1322
Created during configuration: 1541

after this change:
Created immediately: 596
Created during configuration: 1509

To know more about configuration avoidance: https://docs.gradle.org/current/userguide/task_configuration_avoidance.html
2023-06-06 14:27:42 +00:00
Abduqodiri Qurbonzoda e1b6f8198a [K/N] Make Sequence<T>.constrainOnce() multi-thread friendly 2023-06-01 19:40:03 +00:00
Abduqodiri Qurbonzoda 7d9ea28604 Deprecate lazy() that synchronizes on a given lock in non-JVM platforms
Because the overload has a meaningful implementation only in JVM.
In other platforms the specified lock object is ignored.
In K/N it throws UnsupportedOperationException.
2023-06-01 19:40:02 +00:00
Abduqodiri Qurbonzoda 9864402cf8 [K/N] Remove FixmeConcurrency annotation 2023-06-01 19:40:02 +00:00
Abduqodiri Qurbonzoda 7acaf6e473 [K/N] String.indexOf matches byte sequences not on the char boundary #KT-56637
If the found index is odd, retry search from index + 1.

Merge-request: KT-MR-10364
Merged-by: Abduqodiri Qurbonzoda <abduqodiri.qurbonzoda@jetbrains.com>
2023-06-01 12:56:32 +00:00
Troels Bjerre Lund 1ef3561caa [K/N] custom alloc: pre-fault OS pages ^KT-55364
On linux, some memory access patterns cause a cascade of page faults. By
asking mmap for MAP_POPULATE on linux, the page faults happen up front
in a much more efficient manner.


Co-authored-by: Troels Lund <troels@google.com>

Merge-request: KOTLIN-MR-697
Merged-by: Alexander Shabalin <alexander.shabalin@jetbrains.com>
2023-05-26 12:44:36 +00:00
Troels Bjerre Lund 99e4ca65be [K/N] Fix GC stats reporting sweep in wrong epoch ^KT-55364
Co-authored-by: Troels Lund <troels@google.com>

Merge-request: KOTLIN-MR-696
Merged-by: Alexander Shabalin <alexander.shabalin@jetbrains.com>
2023-05-25 12:48:30 +00:00
Igor Chevdar 55632f5df2 [K/N][runtime] Used internal isInstance 2023-05-22 12:49:58 +00:00
Igor Chevdar d1a3752626 [K/N][tests] Fixed lldb tests on arrays 2023-05-22 12:49:58 +00:00
Troels Bjerre Lund 20d8f54ea3 Unlink weakref objects on finalizer-enque ^KT-55364
Co-authored-by: Troels Lund <troels@google.com>

Merge-request: KOTLIN-MR-694
Merged-by: Alexander Shabalin <alexander.shabalin@jetbrains.com>
2023-05-22 12:16:48 +00:00
Ilya Gorbunov bbb36ce501 KT-58046 Promote time sources, time marks, measureTime to stable 2023-05-16 11:42:32 +00:00
Troels Bjerre Lund bc7b1094c3 K/N custom-alloc: Fix GC stats for NextFitPage ^KT-55364
Swept and kept objects in NextFitPages are double counted; first in
GCApi::SweepObject and then again inside NextFitPage::Sweep. This fix
removes the latter.


Co-authored-by: Troels Lund <troels@google.com>

Merge-request: KOTLIN-MR-691
Merged-by: Alexander Shabalin <alexander.shabalin@jetbrains.com>
2023-05-12 09:24:16 +00:00
Igor Chevdar 2f24c6df80 [K/N] Added isSubtype intrinsic 2023-05-11 09:30:18 +00:00
Troels Bjerre Lund 388634e47d [K/N] custom-alloc: Encode consecutive free blocks ^KT-55364
Co-authored-by: Troels Lund <troels@google.com>

Merge-request: KOTLIN-MR-662
Merged-by: Alexander Shabalin <alexander.shabalin@jetbrains.com>
2023-05-10 09:45:14 +00:00
Troels Bjerre Lund 918a247bcc [K/N] custom_alloc: sweep extraobjects outside stw ^KT-55364
Co-authored-by: Troels Lund <troels@google.com>

Merge-request: KOTLIN-MR-677
Merged-by: Alexander Shabalin <alexander.shabalin@jetbrains.com>
2023-05-09 16:37:58 +00:00
Aleksei.Glushko 57707180c6 [K/N] Cooperative intrusive list (in preparations for parallel mark)
Merge-request: KOTLIN-MR-670
Merged-by: Aleksej Glushko <aleksei.glushko@jetbrains.com>
2023-05-09 15:08:32 +00:00
Vsevolod Tolstopyatov f4e8ae5191 Explicitly declare stability levels of declarations in kotlinx.cinterop package
* @ExperimentalForeignApi for all declarations that operate on
    unmanaged memory (i.e. pointers and references)
* @BetaInteropApi for the rest of the interoperability declarations,
    namely Swift/CInterop-specific interfaces and convenience-functions

### Implementation details

* Some typealiases are not marked explicitly because it crashes the compiler,
    yet their experimentality is properly propagated
* License header is adjusted where it previously had been existing
* Deprecated with ERROR interop declarations that are deprecated for more than
    two years are removed
* WASM target interop declarations are deprecated
* Deliberately make Boolean.toByte and Byte.toBoolean foreign-experimental to scare
    people away

^KT-57728 fixed

Merge-request: KT-MR-9788
Merged-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
2023-05-04 13:52:21 +00:00