Commit Graph

283 Commits

Author SHA1 Message Date
Alexander Shabalin 49814ecb8a [K/N] Remove std_support allocation code ^KT-59008 2023-09-07 09:32:00 +00:00
Alexander Shabalin f47a09e55e [K/N] Move allocator-specific data into allocators. ^KT-60928 2023-09-06 14:18:08 +00:00
Alexander Shabalin 958d613911 [K/N] Remove code for deprecated targets from runtime ^KT-59008 2023-09-01 10:48:07 +00:00
Alexander Shabalin 1fa0ef6f56 [K/N] Refactor allocator modules ^KT-60928
- Move std_alloc, opt_alloc and custom_alloc into alloc/std,
  alloc/mimalloc and alloc/custom to mirror convention of gc,
  gcScheduler modules.
- Add alloc/common with common allocator API
- Add alloc/legacy with common implementation details of alloc/std and
  alloc/mimalloc. alloc/custom does not depend on alloc/legacy.
- Removes experimental_memory_manager_custom as it's now unused
- Additionally, renames experimental_memory_manager module into mm
2023-08-30 17:07:21 +00:00
Aleksei.Glushko 4eac193463 [K/N] Generalize GC-assistance pause logic
Merge-request: KT-MR-11790
Merged-by: Alexey Glushko <aleksei.glushko@jetbrains.com>
2023-08-29 19:31:02 +00:00
Abduqodiri Qurbonzoda 84c6333b23 Introduce Common String.toCharArray(destination) #KT-60657
Merge-request: KT-MR-11340
Merged-by: Abduqodiri Qurbonzoda <abduqodiri.qurbonzoda@jetbrains.com>
2023-08-25 03:11:13 +00:00
Alexander Shabalin deb13257c2 [K/N] Make Any.equals simpler 2023-08-22 17:16:43 +00:00
Alexander Shabalin e380610ab0 [K/N] Add a note to identityHashCode() 2023-08-16 14:23:07 +00:00
Alexander Shabalin 431cc9e672 [K/N] Add division to kotlin::saturating
Additionally refactor unit tests.
2023-08-15 13:33:37 +00:00
Aleksei.Glushko 00d6ced263 [K/N] Add the license file for BoundedQueue.hpp
Merge-request: KT-MR-11619
Merged-by: Alexey Glushko <aleksei.glushko@jetbrains.com>
2023-08-14 14:47:07 +00:00
Alexander Shabalin 83a70ddf8b [K/N] Decouple ObjectFactory from concrete ObjectData ^KT-60928
* Use type_layout to declaratively express heap object headers in both
  custom allocator and ObjectFactory.
* Invoke constructor (w/o invoking Kotin constructors) for created
  objects and arrays from both custom allocator and ObjectFactory.
  Previously:
  - custom allocator only checked body for nullability (now this is
    performed in body constructor)
  - ObjectFactory only constructed ObjectData
* In each GC have a AllocatorImpl.hpp and ObjectData.hpp headers
  the first encapsulating allocator-specific types, the second
  containing specific ObjectData implementation.
* In each GC have a separate ObjectFactoryTraits that does not
  actually depend on the specific GC anymore.
* Each GC now expose ObjectData (as undefined type) and its descriptor,
  the latter being used by the custom allocator and ObjectFactory.
* Descriptors for ObjectBody and ArrayBody now live in Memory.h and the
  code calculating size is now shared. Their constructors check that the
  memory is zeroed (Kotlin constructors will expect this).
2023-08-10 07:58:27 +00:00
Alexander Shabalin d956a5504d [K/N] Add a helper for objects with custom layout ^KT-60928 2023-08-10 07:58:27 +00:00
Aleksei.Glushko f1efeff21b [K/N] GC: parallel mark with work balancing ^KT-57771
Merge-request: KT-MR-11460
Merged-by: Alexey Glushko <aleksei.glushko@jetbrains.com>
2023-08-03 16:25:19 +00:00
Mads Ager f0f1dc15c3 [K/N] Reduce frame size by removing unused arena field. 2023-08-03 15:32:08 +00:00
Abduqodiri Qurbonzoda 0f33d71de3 Migrate Vector128 from kotlin.native to kotlinx.cinterop #KT-58402
Make kotlin.native.Vector128 a typealias for kotlinx.cinterop.Vector128
Choose source compatibility over binary compatibility.
2023-07-31 19:38:05 +00:00
Alexander Shabalin 220ecc4788 [K/N] Track memory in big chunks ^KT-57773
Additionally removed testFixtures{} and test{} in gcScheduler/common runtime module,
because that source set became empty.
2023-07-27 21:27:30 +00:00
Alexander Shabalin fd522ea756 [K/N] Add condition_variable that spins on atomics 2023-07-27 21:27:30 +00:00
Aleksei.Glushko 1eda35a59c [K/N] Process objc run loop on the finalizer thread ^KT-58851
Merge-request: KT-MR-11024
Merged-by: Alexey Glushko <aleksei.glushko@jetbrains.com>
2023-07-27 14:17:48 +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
Aleksei.Glushko 96b44e0ad8 [K/N] concurrent weak sweep ^KT-57772 2023-07-04 13:42:59 +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 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
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
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
Pavel Kunyavskiy 2f36886bac [K/N] Rewrite AtomicReference using intrinsics
^KT-59120
2023-06-15 13:53:13 +00:00
Alexander Shabalin 43a7711fcc [K/N] Add CallsCheckerIgnoreGuard 2023-06-15 13:16:08 +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 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
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
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
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
Aleksei.Glushko 8173091fee [K/N] print thread id in assertion failed
Merge-request: KOTLIN-MR-668
Merged-by: Aleksej Glushko <aleksei.glushko@jetbrains.com>
2023-05-02 10:23:38 +00:00
Alexander Shabalin cd93100148 [K/N] Fix sleeping in RWSpinLockTest ^KT-56233 2023-04-27 16:49:30 +00:00
Alexander Shabalin 82f94015f1 [K/N] Dispose ObjC objects from main thread on main thread. ^KT-56402
Merge-request: KT-MR-9515
Merged-by: Alexander Shabalin <Alexander.Shabalin@jetbrains.com>
2023-04-26 07:35:44 +00:00
Abduqodiri Qurbonzoda e20b1239fe [K/N] Remove Char.isIdentifierIgnorable() function
As a part of efforts to stabilize K/N stdlib.
2023-04-19 20:20:43 +00:00
Alexander Shabalin cb7698a8c2 [K/N] Track current heap size ^KT-55364 2023-04-18 12:08:01 +00:00
Alexander Shabalin f4c89148b8 [K/N] Tweak runtime logging ^KT-55364
Print thread id and process uptime.
2023-04-18 12:08:00 +00:00
Alexander Shabalin 4cd1f2ff82 [K/N] Fix a race in MemorySharedRefs ^KT-56233 2023-04-06 11:40:47 +00:00
Alexander Shabalin 8a8aeed998 [K/N] Handle permanent objects in new MM MemorySharedRefs ^KT-56233
Do not create a foreign ref to the permanent objects. There's no need to
do it, and, moreover, this ref would have leaked.
2023-04-06 11:40:45 +00:00
Alexander Shabalin 1f1b26f2a5 [K/N] Split Weak and MemorySharedRefs between mm implementations ^KT-56233
* A separate RegularWeakReferenceImpl for the new mm. Name is chosen for
  better consistency with other WeakReferenceImpl implementations.
* KRefSharedHolder and BackRefFromAssociatedObject implementations are
  independent between the legacy and the new mm.
* Better support for WeakReference in runtime unit tests.
2023-04-06 11:40:45 +00:00
Alexander Shabalin dbe14a0a90 [K/N] Make gc::SweepExtraObjects similar to gc::Sweep. ^KT-56233 2023-04-06 11:40:44 +00:00
Alexander Shabalin eec3987e85 [K/N] Fix RunFinalizerHooks ^KT-56233 2023-04-06 11:40:43 +00:00
Alexander Shabalin aad6d2c8f8 [K/N] Add kotlin::ManuallyScoped<T> ^KT-56233
kotlin::ManuallyScoped<T> is a wrapper over T that pins T in place
and has a trivial constructor and destructor. Creation and destruction
of T must be carried out manually by construct and destroy methods.
2023-04-06 11:40:43 +00:00
Alexander Shabalin 6a0e6b11bd [K/N] Add kotlin::RWSpinLock ^KT-56233
Trivially constructible and destructible std::shared_mutex
implementation with additional guarantee that try_* methods fail only if
the mutex is locked.
2023-04-06 11:40:42 +00:00
Alexander Shabalin 9e5a2efb03 [K/N] Add kotlin::raw_ptr<T> helper class ^KT-56233
kotlin::raw_ptr<T> is exactly T* but with the default constructor
setting value to nullptr and with destructive move.
2023-04-06 11:40:42 +00:00
Pavel Kunyavskiy dc2e072af2 [K/N] Make exception handling in initializers more consistent with jvm
^KT-57091
2023-03-14 12:59:14 +00:00