Commit Graph

67 Commits

Author SHA1 Message Date
Abduqodiri Qurbonzoda df16fa3306 [K/N] Regex matching zero length should split surrogate pairs #KT-57401
Merge-request: KT-MR-11110
Merged-by: Abduqodiri Qurbonzoda <abduqodiri.qurbonzoda@jetbrains.com>
2023-07-26 14:19:25 +00:00
Abduqodiri Qurbonzoda db908aefff Detect concurrent modification of the parent list in subList
As a part of efforts to stabilize Native stdlib.
2023-07-25 16:00:42 +00:00
Abduqodiri Qurbonzoda 92de137cd6 Deprecate HashSet.getElement() and document that it's for ObjC interop.
Will become HIDDEN eventually.

As a part of efforts to stabilize Native #KT-55765.
2023-07-25 15:01:49 +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
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
Abduqodiri Qurbonzoda 209c916a7e OptIn ExperimentalNativeApi 2023-06-30 15:27:09 +00:00
Abduqodiri Qurbonzoda bf1c9774aa Fix the ConcurrentModification test that fails in jdk9+
Modification registration seems to changed in Java 9. Now if the asked
capacity in `ensureCapacity` function is less than current capacity,
no modification is registered.
2023-06-28 19:00:46 +00:00
Vsevolod Tolstopyatov 175cf5e833 KT-53327 replace Enum.values() with Enum.entries in CharCategory
Also, replace it in stdlib tests where appropriate and disable already unsupported legacy JS tests


^KT-53327 fixed

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

Merge-request: KT-MR-10632
Merged-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
2023-06-21 14:40:16 +00:00
Abduqodiri Qurbonzoda af1630e270 [K/N] Catch concurrent modifications of HashMap
As a part of efforts to stabilize Native stdlib.
2023-06-20 18:35:39 +00:00
Abduqodiri Qurbonzoda 9d8d9d000f [K/N] Catch concurrent modifications of ArrayList
As a part of efforts to stabilize Native stdlib.
2023-06-20 18:35:39 +00:00
Abduqodiri Qurbonzoda e802ee05a7 [K/N] Do not override equals/hashCode for AbstractMutableMap.values collection 2023-06-19 11:41:10 +00:00
Abduqodiri Qurbonzoda 6015e12db8 [K/N] Remove redundant AbstractMutableMap.SimpleEntry 2023-06-19 11:41:10 +00:00
Abduqodiri Qurbonzoda 3be613ced8 [K/N] Use iterator in AbstractMutableList.indexOf/lastIndexOf
Instead of access by index. To avoid performance issues
when the subclass `get(index)` has non-constant time complexity.
It also aligns behavior with JVM.
2023-06-19 11:41:10 +00:00
Abduqodiri Qurbonzoda 60cafc6623 Document the exceptions Iterator throws 2023-06-19 11:41:10 +00:00
Abduqodiri Qurbonzoda 830c78773c Align behavoir of collection constructors across platforms #KT-59192
The initialCapacity should be non-negative and loadFactor should be positive.

As a part of efforts to stabilize Native stdlib.
2023-06-08 12:41:40 +00:00
Abduqodiri Qurbonzoda 0bef1533e2 Improve documentation of collection constructors #KT-59192 2023-06-08 12:41:40 +00:00
Abduqodiri Qurbonzoda 3917ec94ab [K/N] Use AbstractList.checkIndex() functions instead of custom check functions 2023-06-06 18:11:57 +00:00
Abduqodiri Qurbonzoda 89d1cfe05b [K/N] ArrayList.ensureCapacity() should ignore negative arguments 2023-06-06 18:11:57 +00:00
Abduqodiri Qurbonzoda ae394caf42 [K/N] Throw OutOfMemoryError when StringBuilder overflows 2023-06-06 18:11:57 +00:00
Abduqodiri Qurbonzoda af7965d996 [K/N] Use AbstractList.newCapacity in HashMap.ensureCapacity 2023-06-06 18:11:57 +00:00
Abduqodiri Qurbonzoda 2ef50f8c34 Move ArrayDeque.newCapacity to AbstractList 2023-06-06 18:11:57 +00:00
Abduqodiri Qurbonzoda d8cfc79d92 [K/N] Fix StringBuilder.setRange capacity expansion 2023-06-06 18:11:57 +00:00
Abduqodiri Qurbonzoda 21636efe38 [K/N] Small refactoring of StringBuilder 2023-06-06 18:11:56 +00:00
Filipp Zhinkin cadf4f63b0 KT-54739 Return single empty inst from collection builders(all src-sets)
Fixed remaining builders, added additional checks to a test.

^KT-54739 fixed
2023-04-26 12:05:15 +00:00
Ilya Gorbunov 2100f08655 Make subarrayContentToString internal 2023-04-26 10:44:52 +00:00
Abduqodiri Qurbonzoda 175566fe56 KT-51908 Common MatchGroupCollection.get(name) extension function 2023-04-26 10:44:21 +00:00
mvicsokolova 75b4469757 [K/N] Stabilization of Atomics API
`AtomicInt`, `AtomicLong`, `AtomicReference` and `AtomicNativePtr` classes were moved to `kotlin.concurrent` package. The corresponding classes from `kotlin.native.concurrent` were deprecated with warning since Kotlin 1.9.

In order to prepare for further commonization of Atomics API the following changes were made:
* `kotlin.concurrent.AtomicInt`: 
    * `increment(): Unit` and `decrement(): Unit` methods were deprecated with error
    * New methods were added: `incrementAndGet(): Int` , `decrementAndGet(): Int`, `getAndIncrement(): Int`, `getAndDecrement(): Int`, `getAndSet(newValue: Int): Int` 
* `kotlin.concurrent.AtomicLong`:
    * `increment(): Unit` and `decrement(): Unit` methods were deprecated with error
    * New methods were added: `incrementAndGet(): Long`, `decrementAndGet(): Long`, `getAndIncrement(): Long`, `getAndDecrement(): Long`, `getAndSet(newValue: Long): Long`
    * Deprecated `AtomicLong()` constructor with default parameter value
* For all atomic classes `compareAndSwap` method was renamed to `compareAndExchange`

See KT-58074 for more details.

Merge-request: KT-MR-9272
Merged-by: Maria Sokolova <maria.sokolova@jetbrains.com>
2023-04-25 16:55:42 +00:00
Filipp Zhinkin 50841e7cb0 KT-42589 Add listOf, setOf, mapOf overloads for a single value to common src-set
`listOf`, `setOf` and `mapOf` overloads were defined in some source-sets
but common source-set was missing it.
This change adds common definition of these methods and also add
declarations for source-sets that were previously
missing it.

^KT-42589 fixed
2023-04-20 08:42:15 +00:00
Abduqodiri Qurbonzoda da0cc2ea4d [K/N] Deprecate Char.MIN_RADIX and MAX_RADIX constants
As a part of efforts to stabilize Native stdlib.
2023-04-19 20:33:33 +00:00
Abduqodiri Qurbonzoda b25f3be81b [K/N] Experimental Char code point constants and functions
Internalize WASM Char code point functions.

As a part of efforts to stabilize Native stdlib.
2023-04-19 20:33:33 +00:00
Abduqodiri Qurbonzoda 954e11c265 [K/N] Mark MutableList.replaceAll with ExperimentalNativeApi
As a part of efforts to stabilize Native stdlib #KT-55765.
2023-04-19 20:32:55 +00:00
Abduqodiri Qurbonzoda 208b279d2b [K/N] Internalize CharCategory.value/valueOf
As a part of efforts to stabilize K/N stdlib.
2023-04-19 20:20:42 +00:00
Abduqodiri Qurbonzoda 0d31b0d12c [K/N] Internalize RegexOption.value/mask properties
As a part of efforts to stabilize K/N stdlib.
2023-04-19 20:20:42 +00:00
Abduqodiri Qurbonzoda 3a4a00ef84 [K/N] Fix MatchGroup.range documentation
As a part of efforts to stabilize K/N stdlib.
2023-04-19 20:20:41 +00:00
Abduqodiri Qurbonzoda b6c2ce2dc8 [K/N] Make assert functions experimental with ExperimentalNativeApi 2023-04-19 19:02:14 +00:00
Vsevolod Tolstopyatov af9252aa96 Mark all Worker-related API as obsolete.
* Explain what obsolete means and why workers are obsolete
* Add some documentation to workers to explain its common pitfalls

^KT-54702


Merge-request: KT-MR-9563
Merged-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
2023-04-19 09:28:23 +00:00
Abduqodiri Qurbonzoda 9076e5b112 [K/N] Mark BitSet usages in stdlib with @ObsoleteNativeApi 2023-03-23 14:48:23 +00:00
Abduqodiri Qurbonzoda ba2833b90f Mark Base64 API with ExperimentalEncodingApi 2023-01-16 11:24:50 +00:00
Abduqodiri Qurbonzoda dc03a03762 Introduce basic, url-safe and mime Base64 variants #KT-9823 2023-01-16 11:24:49 +00:00
Abduqodiri Qurbonzoda fff593492d Introduce Common AutoCloseable & use #KT-31066
Co-authored-by: Ilya Gorbunov <Ilya.Gorbunov@jetbrains.com>

Merge-request: KT-MR-8113
Merged-by: Abduqodiri Qurbonzoda <abduqodiri.qurbonzoda@jetbrains.com>
2022-12-27 11:50:22 +00:00
Abduqodiri Qurbonzoda fb31a29c39 [K/N] Fix stack overflow in regex when a quantifier is matched many times
Motivation:

Users often expect simple patterns, like `[a]+` or `[^a]+`, to work fast
and without any problems, even with long strings.
Char class from the first pattern matches only 'a' and gets wrapped into
LeafQuantifierSet, and works fine with long strings indeed.
Char class from the second pattern, however, matches any character
except 'a', including supplementary code points. So, the number of chars
it consumes is not known beforehand. There is no optimization for such
char classes, and if they are matched multiple times, the stack memory
gets exhausted.

Modification:

Introduce FixedLengthQuantifierSet node.
The node represents quantifier over constructs that consume a fixed
amount of characters for a given string and index. Such constructs don't
need backtracking to find a different match. Thus, it is possible for
the node to avoid recursion when matching multiple times.

Result:

Fixes KT-46211, KT-35508 and probably KT-39789. Reproducer for the
latter issue is no longer available, but error stacktrace resembles
those of the other issues.
2022-12-19 16:40:51 +00:00
Abduqodiri Qurbonzoda 6e50bbee3b [K/N] Set mayContainSupplCodepoints flag only when alt is updated
Motivation:

Calling AbstractCharClass.setNegative always leads to
mayContainSupplCodepoints being `true`, even when `alt` is already
equal to the argument. Given that CharClass always calls setNegative
with its constructor parameter - `negative`, mayContainSupplCodepoints
always gets set. i.e. `[a]` will have mayContainSupplCodepoints set.
mayContainSupplCodepoints affects what node (RangeSet or SupplementaryRangeSet)
wraps this char class. See Pattern.processRangeSet.
RangeSet is better optimized and avoids recursion when it is quantified.

Modification:

Set `mayContainSupplCodepoints` flag only when `alt` is updated.
When `alt` is updated, this char class gets inverted, hence now may
contain supplementary code points.
Otherwise, content of this char class does not change, i.e. no new
supplementary code points is added.

Result:

Fixes KT-46211.
2022-12-19 16:40:51 +00:00
Abduqodiri Qurbonzoda d7f166eda3 [K/N] Remove unused SupplementaryCharSet in regex
Motivation:

The node was never used. Perhaps, it was copied from apache harmony
but ultimately, despite possible performance impact, SequenceSet was
used instead. See Pattern.processCharSet and AbstractSet.first.
The performance impact wouldn't be noticeable anyway.

Modification:

Keeping unused code in project is not a good practice, so get rid of it.

Result:

Less code to maintain.
2022-12-19 16:40:50 +00:00
Sergey Bogolepov c6bbce986d [K/N] Fix KT-54498
Forward users to kotlinlang.org instead of new_mm.md because the latter
is obsolete now.
2022-10-17 14:36:59 +00:00
Abduqodiri Qurbonzoda 71381ec8e2 [K/N] HashMap/HashSet doesn't reclaim storage after removing elements #KT-53310 2022-10-07 11:19:31 +00:00
Abduqodiri Qurbonzoda 7060811c8b Remove the brittle contains optimization code #KT-47707 2022-09-11 10:54:37 +00:00
Abduqodiri Qurbonzoda 2d0e95cea0 Remove StringBuilder functions with nonnull parameter type in K/N and JS #KT-53864 2022-09-08 12:16:55 +00:00
Abduqodiri Qurbonzoda 0208246094 Remove StringBuilder functions with renamed parameters in K/N #KT-53864 2022-09-08 12:02:37 +00:00
Vsevolod Tolstopyatov 5054e301be [stdlib] Improve EnumEntries
* Provide short-circuit methods for contract "EnumEntries contains all
  enum entries"
* Make EnumEntries serializable
* Introduce more convenient overload for other backends

#KT-53152


Merge-request: KT-MR-6867
Merged-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
2022-08-22 16:50:28 +00:00
Ilya Gorbunov 1cfc6a8fca Move sources of ranges to common stdlib from builtins
But still cherry-pick them when serializing builtins because they are
used in builtins signatures.

Merge-request: KT-MR-6488
Merged-by: Ilya Gorbunov <Ilya.Gorbunov@jetbrains.com>
2022-06-23 03:49:30 +00:00