Commit Graph

2828 Commits

Author SHA1 Message Date
Ilya Gorbunov f3fc1197ae Add SIZE_BITS and SIZE_BYTES constants to Double and Float
#KT-29182
2020-04-01 08:06:57 +03:00
Ilya Gorbunov 1c93911279 Make Double and Float known values constant
#KT-13887
2020-04-01 08:06:57 +03:00
Ilya Gorbunov 2bb36899da Introduce 'fail' method to throw AssertionError with cause
#KT-37804
2020-03-31 13:37:03 +03:00
Miguel Serra 61ad32f012 Samples of Map functions "contains" and "isNotEmpty"
Co-authored-by: Ilya Gorbunov <ilya.gorbunov@jetbrains.com>
2020-03-31 04:54:51 +03:00
Ilya Gorbunov 606b4db48a Improve samples for partition: add destructuring 2020-03-31 02:04:56 +03:00
n-p-s 7bb7c86fa9 Add samples for partition 2020-03-31 02:04:55 +03:00
Ilya Gorbunov dd2aa3de28 Add sample for filterNot and improve sample for filter 2020-03-31 02:04:55 +03:00
Brian Plummer f887a29279 Add sample for filter 2020-03-31 02:04:55 +03:00
adammc331 840f222867 Add sample for filterNotNull 2020-03-31 02:04:55 +03:00
Scott Weber e8ee405cdb Add sample for text version of chunked 2020-03-31 02:04:55 +03:00
Ilya Gorbunov e8dff3609b Add @ExperimentalUnsignedTypes to unsigned array snapshot extensions 2020-03-26 23:30:19 +03:00
Ilya Gorbunov d7007044c2 Add a note about the Random(...) generators being not thread-safe 2020-03-24 01:37:03 +03:00
Roman Elizarov e26a3ad033 Speed up stdlib readLine function (#3185)
There are several performance optimizations:

* ByteBuffer/CharBuffer/StringBuilder objects pre-allocated and are
  reused on each call to readLine.
* The state for readLine is lazily allocated via JVM classloading
  (using a singleton object).
* There is an auto-detection heuristic for "directEOL" encodings which
  represent LF ('\n') directly as the corresponding byte
  (UTF-8 and many single-byte encodings are like that).
  When "directEOL" encoding is used, then bytes are batched into
  ByteBuffer for a single call to CharsetDecoder.decode which
  results in higher throughput. Otherwise (UTF-16, etc), slower
  byte-by-byte approach is used.
* Bytes and chars are directly moved in/out of byte/char arrays and
  ByteBuffer/CharBuffer wrappers are used only to interface with
  JVM CharsetDecoder class (which is the slowest piece).
* StringBuilder is not used at all for short lines (<=32 chars).

There are also some function improvements to readLine functionality:

* Restriction on "max chars per byte" is lifted, so readLine works with
  all encodings that JVM supports.
* It support on-the-fly changes to system default charset, because
  it rechecks current charset on each call and updates it decoder
  when needed.

All the other features of readLine function are retained:

* It does not read more bytes from System.in than needed, so it
  is compatible with other ways to read System.in. On-the-fly
  changes to System.in are supported.
* It is thread-safe. Its internal mutable state is protected by
  synchronization.
* There is an internal method for tests that supports explicit
  charset specification, but the name of this method has changed.

There are additional tests:

* Check all supported encodings on JVM to make sure that readLine
  works correctly with them all.
* Check unicode code points of different bits length with all standard
  unicode encodings (UTF-8, UTF-16, and UTF-32 in LE/HE byte orders).

Benchmarks that compare different implementations of readLine,
including this one (readLine6NoLV in the set) can be found here:
https://github.com/elizarov/ReadLineBenchmark

Taking BufferedReader as 100% baseline we see that:

* Current readLine is 7.5 times slower than BufferedReader baseline.
* New implementation in this commit is 2.5 timer slower than baseline.
  It is ~3 times faster than existing implementation of readLine.

Altogether these optimizations are enough to enable reading of
~500K lines in sports programming setting under 2s time-limit with
plenty of headroom in time. Example that is using this version of
readLine can be found here:
https://codeforces.com/contest/1322/submission/73005366

#KT-37416 Fixed
2020-03-23 14:36:55 +03:00
Zalim Bashorov 8c7562d338 [CJS BE] don't crash when intersection types passed for a reified parameter
#KT-37163 Fixed
2020-03-13 10:15:53 +03:00
Abduqodiri Qurbonzoda b1fac4e721 Implement reduceIndexedOrNull and reduceRightIndexedOrNull #KT-36866 2020-03-12 18:08:55 +03:00
Abduqodiri Qurbonzoda b60633d79a Add associateWith to Array<T> #KT-30372 2020-03-12 18:06:54 +03:00
Abduqodiri Qurbonzoda e632d58936 Nullable Array.contentEquals/contentHashCode/contentToString #KT-34161 2020-03-12 18:01:23 +03:00
Zalim Bashorov 8e788e2169 [stdlib-js-ir] Copy Boolean and String sources and add equals, hashCode, toString 2020-03-11 12:54:42 +03:00
Zalim Bashorov adfb296e45 [stdlib-js-ir] Add equals, hashCode, toString to some builtins
Namely:
* Throwable;
* primitive numbers except Long (which implemented in Kotlin).
2020-03-11 12:54:42 +03:00
Zalim Bashorov 97e86fb2ce [stdlib-js-ir] Char shouldn't be a data class 2020-03-11 12:54:41 +03:00
Zalim Bashorov 7c874ccf0c [stdlib-js-ir] Hack: mark Char.toString by JsName to force keeping it 2020-03-11 12:54:41 +03:00
Zalim Bashorov 9e7f72382f [stdlib-js-ir] Remove BitUtils object and make all members toplevel
It works slightly better with IR DCE --
we get about 6% less code on box tests.
2020-03-11 12:54:41 +03:00
Zalim Bashorov 43171f67a8 [stdlib-js-ir] Cleanup exceptions 2020-03-11 12:54:41 +03:00
Ilya Gorbunov afab52c3bc Remove workarounds that called primary constructor manually 2020-03-11 02:09:32 +03:00
Alexander Udalov 787e4503e5 Migrate -Xuse-experimental -> -Xopt-in in project sources 2020-03-10 12:07:15 +01:00
Alexander Udalov 795d6ab407 Migrate UseExperimental->OptIn in project sources 2020-03-10 12:07:14 +01:00
Alexander Udalov 98aecbef6b Optimize runtime representation for callable reference subclasses
Instead of generating overrides for getOwner/getName/getSignature in
each anonymous class representing a callable reference, pass them to the
superclass' constructor and store as fields. This occupies some small
memory but helps to reduce the size of the generated class files, and
will be helpful for adding further runtime information to callable
references, such as information about implicit conversions this
reference has been subject to.

Represent owner as java.lang.Class + boolean instead of
KDeclarationContainer, so that the unnecessary wrapping Class->KClass
wouldn't happen before it's needed, and also to make sure all callable
references remain serializable.

Note that the argument type where the "is declaration container a class"
is passed is int instead of boolean. The plan is to pass the
aforementioned implicit conversion information as bits of this same
integer value.

 #KT-27362 Fixed
2020-03-06 16:55:07 +01:00
Alexander Udalov 8d7c8672ac Generate reference to existing class for builtin function references
Instead of non-existing `kotlin.KotlinPackage`, which led to
NoClassDefFoundError as soon as reflection tried to call getOwner on a
builtin callable reference, use a reference to a new physical class
`kotlin.jvm.internal.Intrinsics$Kotlin`. This will allow to support
KT-17151.

Note that for API version less than 1.4, this will still lead to
NoClassDefFoundError, but this is not worse than the current situation
where it happens anyway.
2020-03-06 16:55:05 +01:00
Abduqodiri Qurbonzoda d5c851980c String.toBoolean() should be String?.toBoolean() #KT-14119 2020-03-05 17:53:29 +03:00
Abduqodiri Qurbonzoda a32f742893 Inherit ReadWriteProperty from ReadOnlyProperty #KT-27729 2020-03-05 16:53:02 +03:00
Abduqodiri Qurbonzoda fc22cfa896 String.format does not support no locale #KT-22932 2020-03-05 16:38:43 +03:00
Alexander Udalov 8588f96ec8 Fix inspections in kotlin.jvm.internal runtime classes 2020-03-05 14:01:29 +01:00
Vyacheslav Gerasimov 744c4c545e Build: Make DexMethodCount task cacheable, extract print stats to task 2020-03-05 00:47:52 +03:00
Vyacheslav Gerasimov 52b88bf753 Build: Fix various libraryJarWithIr task inputs 2020-03-04 01:14:56 +03:00
Roman Artemev c2676ded31 [JS IR] Implement KProperty runtime utils 2020-03-03 18:54:36 +03:00
Roman Artemev 0e67c6ac7d [JS IR] Update coroutine runtime 2020-03-03 18:54:35 +03:00
Roman Artemev 26237f8bd5 [JS IR] Implement new function references scheme 2020-03-03 18:54:34 +03:00
Vyacheslav Gerasimov 2f087fe7a2 Build: Fix kotlin-stdlib-js-ir:tryRunFullCli task inputs 2020-03-03 18:46:05 +03:00
Vyacheslav Gerasimov a4030d3abf Build: Make JavaExec relative path system independent 2020-03-03 16:47:55 +03:00
Vyacheslav Gerasimov 08ac7da7a6 Build: Fix input declaration for :kotlin-stdlib-js-ir:fullRuntimeSources
Input order was random because of unordered set
2020-03-03 16:47:55 +03:00
Vyacheslav Gerasimov bb2cf38617 Build: Make :kotlin-stdlib-js-ir buildKLib tasks cacheable 2020-03-03 16:47:55 +03:00
Vyacheslav Gerasimov 75a3808230 Build: Use sourceMapBaseDirs in :kotlin-stdlib-js:compileKotlin2Js
instead of freeCompiler args to avoid snapshotting absolute paths
and fix caching
2020-03-03 14:33:57 +03:00
Abduqodiri Qurbonzoda fe50bb4b93 KProperty and ReadOnlyProperty type parameter names #KT-16529 2020-02-26 17:34:03 +03:00
Abduqodiri Qurbonzoda 1f721796b8 Add vararg overloads for maxOf/minOf functions #KT-33906 2020-02-26 04:17:19 +03:00
Abduqodiri Qurbonzoda afceec71a4 Create an interface with provideDelegate() method #KT-26494 2020-02-20 18:57:52 +03:00
Abduqodiri Qurbonzoda 2566fbea87 toMutableList documentation is vague #KT-35231 2020-02-20 18:52:10 +03:00
Abduqodiri Qurbonzoda f9ee1dc22d Specify which element Iterable.distinctBy(selector) retains #KT-36356 2020-02-20 18:50:13 +03:00
Abduqodiri Qurbonzoda ce8e511b79 Add setOfNotNull function #KT-35851 2020-02-18 02:33:59 +03:00
Abduqodiri Qurbonzoda 5a4ce2aa4c Mark shared global vals to fix K/N worker thread crash 2020-02-18 01:49:24 +03:00
Mikhail Zarechenskiy 155b716e7e Revert "Disable NewInference for stdlib tests"
This reverts commit cdf5323f8c.
2020-02-17 10:29:46 +03:00