Commit Graph

331 Commits

Author SHA1 Message Date
Ilya Matveev 42c4391654 backend: Process 'until MIN_VALUE' in for loops
This patch takes into account a corner case available for loops
over a progression (see backend.native/tests/external/codegen/box/
ranges/forInUntil/forInUntilMinint.kt test):

for (i in 0 until Int.MIN_VALUE) { ... }

Here we cannot use subtraction to obtain a right bound of the loop
due to an overflow. Instead we consider any loop with MIN_VALUE in
it's right bound as empty loop. Such behaviour is similar to the one
of 'until' method.

So now the empty check for a loops with 'until' call:

for (i in first until bound) { ... }

is as follows:

val last = getProgressionLast(first, bound, step) // Only if step==1
if (first <= last && bound > <Int|Long|Char>.MIN_VALUE) {
    do { ... } while(i != last)
}

Further improvements: We can generate a simpler IR for some simple
frequent cases (e.g. for until calls without steps) and eliminate
loops if we can prove that they are empty.
2017-07-25 22:26:17 +07:00
Ilya Matveev d474f207e3 backend: Don't create a Progression objects in 'for' loops
This patch optimizes the following pattern:

for (i in first..last step st) { ... }

In this case we need to create a Progression object and then call its
iterator() method causing at least 2 allocation per loop. This change
replaces such loops with the following constuction:

var inductionVar = first
checkProgressionStep(step)  // check if step > 0
last = getProgressionLastElement(first, last, step)
if (first <= last) {
    do {
        i = inductionVar
        inductionVar += step
        ...
    } while(i != last)
}
2017-07-18 17:05:58 +07:00
Nikolay Igotti 06e31939dd WebAssembly effort (#721) 2017-07-14 16:44:46 +03:00
Nikolay Igotti 64e106157f Custom malloc support (#742) 2017-07-14 16:21:42 +03:00
Nikolay Igotti 1565371cda Porting layer (#741) 2017-07-14 14:23:52 +03:00
Svyatoslav Scherbina 747922ce00 Add one more workaround for LLVM bug 33220 2017-07-14 09:16:28 +03:00
Nikolay Igotti dae273099a Centralized memory allocation (#736) 2017-07-13 14:10:26 +03:00
Alexander Gorshenev 55c4966203 Moved clang flags out of the root build.gardle.
Collected clang args in ClangArgs.kt
Switched dependencies/build.gradle to KonanTarget.
Introduced KonanProperties to take care of target specific properties.
2017-07-12 18:31:09 +03:00
Vasily Levchenko 27517b0db1 [codegen][debug] make runtime debug information friendly to generated one.
- inroduced function generation context containing mostly functionality local to function generation
- initial debug location is linked with basic block.
- then on each expression location is tuned.
- removed manual placement of debug location dictations over the place.

- refactoring removed unused declarations
2017-07-10 07:25:17 -07:00
Ilya Matveev 224dd0f0fc stdlib: Add util methods for time measurements 2017-07-10 11:32:00 +07:00
Nikolay Igotti 399f4bd0ff Fix memleak with exceptions (#713) 2017-06-27 15:08:42 +03:00
Nikolay Igotti 96d9f734c0 Switch Kotlin version to 1.1.3, remove obsolete Gradle syntax (#707) 2017-06-27 11:18:13 +03:00
Igor Chevdar 44620c1428 Some fixes in android sample 2017-06-22 14:58:33 +03:00
Nikolay Igotti c1d65ffede Fix warnings (#690) 2017-06-22 13:53:03 +03:00
Nikolay Igotti 1ad50bc33f Workers draft (#655) 2017-06-21 11:26:09 +03:00
Igor Chevdar ed0c78167b Uncommented hex floating point parser 2017-06-20 17:55:03 +03:00
Igor Chevdar 282ac885c5 Added nullifying all globals on deinitialization of runtime 2017-06-20 16:45:13 +03:00
Ilya Matveev 4daebe47a9 regex: Add licenses 2017-06-20 02:53:54 +07:00
Ilya Matveev c994573a77 regex: Fix warnings and TODOs 2017-06-20 02:53:54 +07:00
Ilya Matveev 22aead3d18 regex: Perform char decomposition on C++ side 2017-06-20 02:53:54 +07:00
Ilya Matveev 1e7d132a88 regex: Clean TODOs 2017-06-20 02:53:54 +07:00
Ilya Matveev bfcc0fc0d0 regex: Refactor predefined character classes. 2017-06-20 02:53:54 +07:00
Ilya Matveev 9c81f9b402 regex: Move decomposition tables to C++ code 2017-06-20 02:53:54 +07:00
Ilya Matveev 1bf9b23108 regex: Initial regex implementation
regex: All tests are passed.
2017-06-20 02:53:54 +07:00
Igor Chevdar fa93f5b7e1 Revert "Implemented *Array.toString() for all arrays"
This reverts commit 7997b4f362.
Synchorinization with Kotlin/JVM - default implementation will do.
2017-06-19 17:17:30 +03:00
Igor Chevdar b1db2fa182 Pulled out io.* from KString.cpp to Console.cpp 2017-06-15 19:04:58 +03:00
Igor Chevdar 3a55c123d7 Sample: textured dodecahedron rotated by fingers 2017-06-15 19:04:58 +03:00
Igor Chevdar 2151e55576 Added separate launcher for android 2017-06-15 19:04:58 +03:00
Ilya Matveev 4202e6d818 stdlib: Remove redundant checks from String.lastIndexOf
Kotlin/JVM allows a user to specify a start index greater than
a string length in String.lastIndexOf method. This patch
modifies the Kotlin/Native implementation according to this
behaviour. It also removes other redundant checks.
2017-06-15 14:37:31 +07:00
Ilya Matveev e64a5f42f0 stdlib: Improve character API.
The patch adds methods for surrogate characters processing and Unicode
category support needed for regular expression library.
2017-06-14 10:33:45 +07:00
Mikhael Bogdanov 724710811d Rename DefaultArgumentMarker to DefaultConstructorMarker 2017-06-09 15:51:07 +03:00
Ilya Matveev a70f170e80 [SQUASHME] bitset: fix logical operations. 2017-06-07 11:11:36 +07:00
Ilya Matveev dc0058371c [SQUASHME] Review fixes 1 2017-06-07 11:11:36 +07:00
Ilya Matveev 6ff43d690f stdlib: Add BitSet implementation. 2017-06-07 11:11:36 +07:00
Alexander Gorshenev 5192bd1313 Entry point selection.
$ kotlinc -entry foo.bar.qux ...

selects `qux(args: Array<String>):Unit` in the package `foo.bar` as an entry point.

The short flag is `-e`.
2017-06-05 20:56:10 +03:00
SvyatoslavScherbina f2f82ab843 Support stack traces on Windows (#624)
Use GCC's unwind and load COFF symbols on mingw target.
2017-06-01 17:06:11 +03:00
Nikolay Igotti 74ffc479bb Add Windows i18n support (#617) 2017-05-31 10:01:49 +03:00
Igor Chevdar 5a216953e2 Ported harmony implementation of Double/Float <-> String
Double.toString(), Float.toString(), String.toFloat(), String.toDouble()
2017-05-30 14:50:15 +03:00
Svyatoslav Scherbina d6b8b4fb0f Add basic support for Windows with mingw-w64 2017-05-29 19:13:55 +03:00
Nikolay Igotti 070ea929f0 Small backtrace support cleanup. 2017-05-25 22:35:56 +03:00
Nikolay Igotti a4ba0fbb32 Add Linux backtrace support. (#605) 2017-05-25 15:50:18 +03:00
Igor Chevdar 7997b4f362 Implemented *Array.toString() for all arrays 2017-05-24 22:53:18 +03:00
Igor Chevdar 2a4ee21bc7 Added KotlinVersion.kt 2017-05-24 22:53:18 +03:00
Nikolay Igotti 42197a2bec Android NDK support and build system refactoring (#585) 2017-05-24 00:20:19 +03:00
Igor Chevdar d1e248b8c3 Added String.repeat() 2017-05-23 11:44:09 +03:00
Igor Chevdar 67f37bad8d Fixed bug in strings comparison 2017-05-23 11:44:09 +03:00
Igor Chevdar 0d0e652709 Fixed toString() KFunction 2017-05-23 11:44:09 +03:00
Igor Chevdar 889e0e5078 Fixed annotation 2017-05-23 11:44:09 +03:00
Igor Chevdar 072da99ba3 Coroutines bug fix: correct handling of returnIfSuspended intrinsic 2017-05-23 11:44:09 +03:00
Igor Chevdar a41552b3c8 Rewrote callable reference lowering
For each callable reference a class inherited from KFunctionImpl is built.
2017-05-18 11:56:32 +03:00