Commit Graph

2555 Commits

Author SHA1 Message Date
pyos 683f8417d3 Add a common JVM/JS lowering for Array(size, function)
and remove the hack from JVM_IR codegen that replaces this call with
hardcoded inline function bytecode.

(cherry picked from commit 4a29e3cfcf)
2019-05-09 11:54:18 +02:00
max-kammerer e74e0ea013 Revert "Add a common JVM/JS lowering for Array(size, function)"
This reverts commit 4a29e3cfcf.
2019-05-09 11:49:34 +02:00
pyos 4a29e3cfcf Add a common JVM/JS lowering for Array(size, function)
and remove the hack from JVM_IR codegen that replaces this call with
hardcoded inline function bytecode.
2019-05-09 08:03:18 +02:00
Ilya Gorbunov 2c26dc3af6 Add simplified overloads of String<->ByteArray/CharArray conversions
These overloads cover the most common cases of conversion of the entire
String or Byte/CharArray, avoiding extra index check and branching.

#KT-24810, KT-29265
2019-05-08 02:58:57 +03:00
Svyatoslav Kuzmich e3bcabeae3 [JS IR] stdlib: Fix bugs in Long.toString(radix) 2019-05-07 21:49:12 +03:00
Svyatoslav Kuzmich bc29a5b15c [JS IR] stdlib: port methods that use bit representation of numbers
- Port part of 'misc.js' from current backend to 'bitUtils.kt' in IR backend
- Enable toBits, toRawBits, fromBits extension function on Double and Float
- Enable Double.withSign
- Refactor getNumberHashCode using new utils
2019-05-07 21:49:12 +03:00
Svyatoslav Kuzmich 362fbc8770 [JS IR] stdlib: Use comparator in CharArray.sort
CharArray is represented as a regular JS Array. Its default sort order is based
on string representation of elements.
2019-05-07 21:48:50 +03:00
Svyatoslav Kuzmich 179acf0789 [JS IR] stdlib: generate type-safe contentToString for primitive arrays
Avoid casting 'primitive' arrays to Array<*> because they fail on runtime
2019-05-07 21:48:50 +03:00
Svyatoslav Kuzmich 7687985442 [JS IR] Stdlib: use total-order comparasion for content equals 2019-05-07 21:48:50 +03:00
Svyatoslav Kuzmich 3a506a372b [JS IR] stdlib: Use Nothing in return type of THROW helpers
Backend generated calls to those helpers inside expression which
resuleted in invalid type casts in IR (in dead code).
2019-05-07 21:48:50 +03:00
Abduqodiri Qurbonzoda c8a4fa58cd Implement String to/from ByteArray conversion (KT-24810) 2019-05-06 15:54:28 +03:00
Abduqodiri Qurbonzoda 81d2d3cb6a Implement String to/from CharArray conversion (KT-29265) 2019-05-06 15:54:28 +03:00
Ilya Gorbunov 5f2762ed20 Follow up: fix typos in coroutine docs 2019-05-01 05:40:35 +03:00
Svyatoslav Kuzmich 87415cb769 [JS IR] Help IDEA: Copy stdlib sources instead of sharing 2019-05-01 00:28:36 +03:00
Yanis Batura a51b7fb8d0 Fix typos 2019-04-30 18:42:07 +03:00
Svyatoslav Kuzmich 379cb08226 [JS] Reduce usage of 'js' function in stdlib
Function 'kotlin.js.js' is to be redesigned in JS IR backend,
partially because it is a hard feature to support.

Current implementation is unstable and can cause problems around
 inlining and name generator. Luckily most of its use-cases
can be covered by simpler features like dynamic expressions and
external declarations.

Thus we are reducing it's usage in stdlib to make IR backend more
stable in current state. JavaScript features that can't be covered by dynamic expression are
implemented in 'jsOperators.kt' file respectively for each backend:

 - 'internal inline' function which calls 'js' function inside for current
   pre-IR backend

 - 'internal' function with '_hack' parameters for JS IR backend which will be
   later intinsicified in a compiler
2019-04-30 15:27:19 +03:00
Roman Elizarov 1e5d973bb1 Fix CoroutineContext documentation with respect to equality
KT-26398 had updated behavior from reference comparison to regular
equality, but the documentation for CoroutineContext was left out.
The whole "by reference" needs to be removed, because it now
follows default behavior of all Kotlin collections and need no
further clarification.
2019-04-29 16:33:22 +03:00
Svyatoslav Kuzmich 13b332e99e Build scripts for JS IR versions of stdlib and kotlin.tests 2019-04-26 20:14:12 +03:00
Svyatoslav Kuzmich 5da83889d9 Stdlib tests: Supporess NoInfer access instead of redeclaration
Stdlib annotation 'kotlin.internal.NoInfer' was redeclared in stdlib tests
so non-fried modules (kotlin-stdlib-jdk7, kotlin-stdlib-jdk8, etc.)
could access it.

IR deserializer does not support declaration duplicates (at least yet
for JS IR backend). Thus this commit removes this redeclaration and
suppresses errors on its usages instead.
2019-04-26 20:14:03 +03:00
Svyatoslav Kuzmich 09d7f4015b Move test.kt stubs to smallRuntime
We already use kotlin.test with fullRuntime klib.
2019-04-24 13:06:59 +03:00
Svyatoslav Kuzmich b0bd5802bb Remove optionalExpectation hacks
Add common sources to Generate IR Runtime
2019-04-24 13:06:58 +03:00
nikita.movshin deb416484c Update copyright. Fix 2 lines comments after rebase
Change the copyright from "JetBrains s.r.o." to
"JetBrains s.r.o. and Kotlin Project contributors"
2019-04-23 20:15:03 +03:00
nikita.movshin abb7d3ab46 Update copyright.
Change the copyright from "JetBrains s.r.o." to
"JetBrains s.r.o. and Kotlin Project contributors"
Update 2 lines comment
2019-04-23 20:09:27 +03:00
nikita.movshin 65244b4bea Update copyright.
Change the copyright from "JetBrains s.r.o." to
"JetBrains s.r.o. and Kotlin Project contributors"
Update only 2 lines copyright.
2019-04-23 20:09:22 +03:00
Svyatoslav Kuzmich b1d303b027 Reorganize stdlib-js sources specific to the current JS backend
Move kotlin-stdlib-js project and the sources specific to the current backend to 'stdlib/js-v1' directory,
but leave sources that can be shared with the new IR backend in the common 'stdlib/js' location
with exception for 'stdlib/js/src/generated', which is used exclusively for current backend.
This simplifies sourceset configuration when building stdlib with the new backend.
2019-04-22 20:30:57 +03:00
Svyatoslav Kuzmich d7be91e8a4 [JS IR BE] Add SIZE_BYTES and SIZE_BITS to Long and Char 2019-04-22 20:30:57 +03:00
Svyatoslav Kuzmich 3fd55673a8 [JS IR BE] Workaround for println
IR backend has a bug in decomposition of dynamic calls.
Workaround: don't use inline function call inside dynamic call argument.
2019-04-22 13:18:00 +03:00
Abduqodiri Qurbonzoda 3f08753f87 Move string-related files to text directory 2019-04-19 03:51:20 +03:00
Svyatoslav Kuzmich 977d3ef840 [JS IR BE] New name generator 2019-04-13 14:19:36 +03:00
Svyatoslav Kuzmich 38fc4b0c59 [JS IR BE] Hack irRuntime js function usage to compensate for implementation shortcomings 2019-04-13 14:17:59 +03:00
Anton Bannykh b7ffdb9fde JS IR: support kotlin.test 2019-04-05 12:30:21 +03:00
Ilya Gorbunov dde2b30601 Clarify wording in Random.nextUInt docs: missed extra 'not' 2019-04-03 16:31:03 +03:00
Ilya Gorbunov 04bbf23936 Add explicit imports of kotlin.ranges more specific functions
The extensions 'contains' and 'reversed' from kotlin.ranges can be more
specific for IntRange, LongRange, etc than the same functions from
kotlin.collections, yet they lose in overload resolution to the latter
ones when invoked from kotlin.collections package
because of same package package extensions are preferred (KT-30633).
2019-04-02 21:28:33 +03:00
Ilya Gorbunov d77f76bdb0 Clarify wording in Random.nextInt/Long/UInt/ULong docs
#KT-30704 Fixed
2019-04-02 21:28:32 +03:00
Toshiaki Kameyama 4a3e4f099d KT-30451 Redundant call of selector in maxBy&minBy
Refactor maxBy & minBy: do not call selector when collection has single item
2019-03-31 05:11:05 +03:00
Ilya Gorbunov 91c7233ed8 Make Throwable.addSuppressed extension work without kotlin-stdlib-jdk7*
*given that it runs on JDK7 and higher. The addSuppressed member
is called with reflection when it's available.
kotlin-stdlib-jdk7 extension still overrides that and calls
addSuppressed member statically as before.

#KT-30560 Fixed
2019-03-28 22:42:20 +03:00
Ilya Gorbunov e6e00483d4 Put kotlin-stdlib-jdk7/8 output in test classpath when running jdk6 tests
These tests ensure how compiled jdk6 binaries work in newer JDK7/8 environment,
and most likely the stdlib-jdk7/8 artifacts will be in that environment.

This reverts test classpath change (accidentally?) made in the commit 99f2cc3d.
2019-03-28 22:42:20 +03:00
Sergey Rostov 7b89b0abbb JPS Build: exclude :core:builtins, use prebuilt bootstrap version 2019-03-28 10:06:35 +03:00
Sergey Rostov fb3f28974e Build: support local.properties for JPS build. Apply JPS related tweaks only inside IDEA import. 2019-03-28 10:06:16 +03:00
Abduqodiri Qurbonzoda 636ed025da Replace "binary representation of" with "bits of" 2019-03-22 21:18:27 +03:00
Alexander Udalov ed86757817 Rework how built-in types are loaded in compiler for JVM
In TopDownAnalyzerFacadeForJVM, we now always use the "load built-ins
from module dependencies" behavior that was previously only enabled with
the dedicated CLI argument -Xload-builtins-from-dependencies. However,
sometimes we compile code without kotlin-stdlib in the classpath, and we
don't want everything to crash because some standard type like
kotlin.Unit hasn't been found.

To mitigate this, we add another module at the end of the dependencies
list, namely a "fallback built-ins" module. This module loads all
built-in declarations from the compiler's class loader, as was done by
default previously. This prevents the compiler from crashing if any
built-in declaration is not found, but compiling the code against
built-ins found in the compiler is still discouraged, so we report an
error if anything is resolved to a declaration from this module, via a
new checker MissingBuiltInDeclarationChecker.

Also introduce a new CLI argument -Xsuppress-missing-builtins-error
specifically to suppress this error and to allow compiling code against
compiler's own built-ins.

 #KT-19227 Fixed
 #KT-28198 Fixed
2019-03-22 14:59:03 +01:00
Ilya Gorbunov 8021f9c4af Clarify toSortedMap and sortedMapOf docs (KT-30100)
Remove the note about iteration order so that toSortedMap is not misused
for sorting map entires with the comparator inconsistent with key equality.
2019-03-20 22:08:03 +03:00
Ilya Gorbunov b74fe7c1c3 Clarify floor and ceil docs (KT-30418) 2019-03-19 03:12:12 +03:00
Ilya Gorbunov b0a234ec74 Minor: collection docs formatting 2019-03-19 03:12:09 +03:00
Ilya Gorbunov 25b3f62767 Clarify yield/yieldAll function suspending the caller behavior 2019-03-18 18:01:39 +03:00
Abduqodiri Qurbonzoda 35c6f09886 Implement coerce extension functions for unsigned types 2019-03-15 17:46:48 +03:00
Abduqodiri Qurbonzoda a369496aca Throw IOOB on invalid index in JS StringBuilder.get to adhere contract 2019-03-15 17:40:31 +03:00
Abduqodiri Qurbonzoda 814d6cf39c Document Array and String get() function behavior (KT-30141) 2019-03-15 17:40:19 +03:00
Ilya Gorbunov 7a038f1330 Refactor sanitizeStackTrace function to spare allocations
Use Arrays.copyOfRange instead of List.subList.toArray.
2019-03-15 06:26:59 +03:00
Ilya Gorbunov edc766af56 Document exception thrown for negative n in take/takeLast/drop/dropLast
#KT-29151
2019-03-13 17:58:19 +03:00