Commit Graph

62 Commits

Author SHA1 Message Date
pyos
ef5e02da84 JVM_IR: handle Nothing and Unit more consistently.
* In blocks, discard the result of any statement that has a return
   type other than void. This was previously done by wrapping each
   statement into an "implicit Unit conversion" that was actually
   compiled down to a stack pop instead. If an expression happened to
   already have type Unit, however, such a conversion was not inserted,
   resulting in a stray reference on the stack. These conversions are
   now redundant and should probably be removed.

 * In assignments and non-exhaustive conditionals, materialize a Unit
   on the stack to avoid depth mismatches that trip up the bytecode
   validator. Because such expressions are generally used at block level
   (and, indeed, the frontend will reject a non-exhaustive conditional
   used as an expression), combined with the above change this results
   in no additional GETSTATIC opcodes, as they are immediately removed
   by the peephole optimizer.
2019-03-26 13:32:02 +01:00
Ting-Yuan Huang
f6cf434650 when: emit switch for String if possible
Effectively, the following when structure:

  when (s) {
    s1, s2 -> e1,
    s3 -> e2,
    s4 -> e3,
    ...
    else -> e
  }

is implemented as:

  when (s.hashCode()) {
    h1 -> {
      if (s == s1)
        e1
      else if (s == s2)
        e1
      else if (s == s3)
        e2
      else
        e
    }
    h2 -> if (s == s3) e2 else e,
    ...
    else -> e
  }

where s1.hashCode() == s2.hashCode() == s3.hashCode() == h1,
      s4.hashCode() == h2.

A tableswitch or lookupswitch is used for the hash code lookup.

Change-Id: I087bf623dbb4a41d3cc64399a1b42342a50757a6
2019-03-20 09:13:51 +01:00
Mads Ager
542d3c3532 JVM_IR: Fix stack underflow for unit coercion of when expressions.
Code such as

```
val b = getBoolean()
if (b) 4
else if (b) 5
```

didn't generate a value on the stack always and therefore would
have control-flow paths leading to a pop instruction with nothing
on the stack.

Change-Id: I09d059f361e56a41880006e3f4e51e9acdbd167d
2019-02-05 08:52:18 +01:00
Svyatoslav Kuzmich
aa811dcfb3 [JS IR BE] Add KJS_WITH_FULL_RUNTIME directive to compiler tests 2019-01-24 16:14:40 +03:00
Mikhael Bogdanov
1b2145af22 Fix test data 2018-10-25 09:12:26 +02:00
Mikhael Bogdanov
e5ef5d096e Fix test data 2018-10-25 09:10:40 +02:00
Svyatoslav Kuzmich
7074909230 [JS IR BE] Support enumValues<T>() and enumValueOf<T>(name) 2018-10-10 19:35:17 +03:00
Dmitry Petrov
7624dbbb20 Fix subject variable handling in specialized enum codegen
#KT-27161
2018-09-27 10:48:35 +03:00
Anton Bannykh
7d5a304cf6 [JS IR BE] support Char.rangeTo() 2018-09-18 15:43:55 +03:00
Anton Bannykh
2e709a81fa [JS IR BE] Arrays, varargs 2018-09-18 14:36:20 +03:00
Denis Zharkov
c1cc722ac4 Turn off incorrect switch-optimization for when by enums
#KT-24708 Fixed
2018-09-12 09:49:25 +03:00
Svyatoslav Kuzmich
ad58fdd158 [JS IR BE] Unmute tests after adding stdlib 2018-09-04 20:19:04 +03:00
Roman Artemev
8a871b3f0c Update tests 2018-08-31 15:34:18 +03:00
Pavel Punegov
2ff6047845 Update ignore tag for Native backend 2018-08-28 13:48:43 +03:00
Roman Artemev
6c8e30eb05 Fix test failures
* add metadata
 * unmute working tests
 * mute temporary broken ones
2018-08-09 20:55:50 +03:00
Zalim Bashorov
3c765e3625 [JS BE] Support val in when subject
#KT-25014 Fixed
2018-08-09 16:22:25 +03:00
Mikhael Bogdanov
357359b1dd Unmute ir-tests after CR support 2018-08-09 14:22:50 +03:00
Roman Artemev
efec82c0eb Update test data
* add new tests for coroutines
 * add copy of some tests without dependency on stdlib
2018-08-08 18:33:41 +03:00
Roman Artemev
c62e4b4fcf [JS IR BE] Support coroutines
* Move FinallyBlockLowering to common part
* Fix catching of dynamic exception
* Fix bridges for suspend functions
* Disable explicit cast to Unit
* Run lowering per module
* Update some test data
2018-08-08 18:33:39 +03:00
Svyatoslav Kuzmich
625983b28a [JS IR BE] Enum class lowering 2018-07-23 15:08:18 +03:00
Svyatoslav Kuzmich
1abb4f42ac [JS IR BE] Add ranges to runtime, rangeTo for primitive numbers 2018-07-17 20:18:29 +03:00
Anton Bannykh
07b3b66fd9 JS IR: unmute tests 2018-07-10 13:34:19 +03:00
Mikhael Bogdanov
e149cbe852 Mute failed jvm ir tests 2018-06-28 12:26:41 +02:00
Dmitry Petrov
d546fca876 Enable JS_IR back-end on passing 'when' tests 2018-06-21 12:32:00 +03:00
Dmitry Petrov
c312fddb45 Ignore some 'when' subject variable tests in JS_IR be 2018-06-20 14:06:34 +03:00
Dmitry Petrov
a7492e91c9 Check that subject expression is evaluated only once 2018-06-20 14:06:34 +03:00
Dmitry Petrov
6194cfc782 Additional IEEE754-related tests for subject variable in 'when' 2018-06-20 14:06:34 +03:00
Dmitry Petrov
34b76a3718 Support subject variable in specialized code generators for 'when' 2018-06-20 14:06:34 +03:00
Dmitry Petrov
6949610dcb 'val' in 'when': IEEE754 equality 2018-06-20 14:06:34 +03:00
Dmitry Petrov
d6894091a9 Support 'when' with subject variable in JVM BE 2018-06-20 14:06:34 +03:00
Roman Artemev
f69bd54d6c [JS IR BE] Update test data 2018-06-19 17:09:31 +03:00
Roman Artemev
6ac4fd2e5f [JS IR BE] Update test data 2018-06-14 19:54:30 +03:00
Anton Bannykh
96355e2732 JS IR: mute codegen box tests automatically 2018-06-09 19:15:38 +03:00
Anton Bannykh
cd3a797f2a JS: fix corner case in when translation (fix crash in KT-22544) 2018-02-12 17:15:48 +03:00
Alexey Andreev
89db4dfe79 JS: translate when against enum to JsSwitch when possible 2017-11-17 11:07:41 +03:00
Alexey Andreev
678b4c67c1 JS: translate when to JsSwitch when possible
See KT-21160
2017-11-17 11:07:38 +03:00
Dmitry Petrov
2ed5a5e368 'when' should use intrinsics for '=='
#KT-19029 Fixed Target versions 1.1.5
 #KT-18818 Fixed Target versions 1.1.5
2017-08-07 10:31:02 +03:00
Igor Chevdar
d7e4350d42 Ignored/fixed some tests for Kotlin/Native 2017-06-28 12:54:32 +03:00
Ilya Matveev
a5e4e0284e Mute some box tests for native backend
This patch mutes the following test categories:
   * Tests with java dependencies (System class,
     java stdlib, jvm-oriented annotations etc).
   * Coroutines tests.
   * Reflection tests.
   * Tests with an inheritance from the standard
     collections.
2017-03-10 19:59:37 +03:00
Mikhael Bogdanov
df8394bcd2 Fix for KT-14597: "When" over smartcasted enum is broken and breaks all other "when"
#KT-14597 Fixed
2017-01-24 15:17:47 +01:00
Ilya Gorbunov
38840bb529 Do not reference java.util in tests that run on JS backend. 2016-11-21 18:20:33 +03:00
Alexey Andreev
b5358122e2 JS: unmute shared box tests 2016-11-16 19:50:10 +03:00
Zalim Bashorov
596f3364c6 Automatically mute failed tests 2016-11-09 21:41:12 +03:00
Mikhail Glukhikh
f35fd32a25 Exhaustive when with 'Unit' result now also generates an exception in else branch #KT-12192 Fixed 2016-05-17 14:28:57 +03:00
Alexander Udalov
bab127ad33 Remove some legacy codegen tests, move some to generated 2016-03-09 10:25:38 +03:00
Alexander Udalov
06a67e6602 Merge boxWithStdlib testData into box, delete BoxWithStdlib test 2016-03-09 10:25:38 +03:00
Alexander Udalov
20e36438e2 Move some tests from boxWithStdlib/ to box/
Move those tests which do not require neither stdlib nor reflect
2016-03-09 10:25:38 +03:00
Dmitry Petrov
b3f390abe5 Fix KT-10775 Empty when causes compilation exception.
Expression type for an empty 'when' is 'kotlin.Unit'.
2016-01-29 18:50:48 +03:00
Mikhail Glukhikh
9360bd49a6 Data flow info: correct disjunction of a type with Nothing: Type U Nothing = Type #KT-9578 Fixed 2016-01-19 16:01:10 +03:00
Mikhail Glukhikh
7d6ccc40c2 Implicit exhaustive whens now have exception in else branch #KT-8700 Fixed 2015-12-26 10:46:39 +03:00