Commit Graph

116 Commits

Author SHA1 Message Date
Mikhael Bogdanov 30aeb8dc0a Support finally blocks in non-local returns 2019-04-08 13:10:23 +02:00
Mikhael Bogdanov 4c59d161d4 Support basic reification in IR 2019-04-08 13:10:22 +02:00
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
pyos 8c55376f0c Unmute almost all JVM_IR tests that use property references 2019-03-19 12:00:29 +01:00
Ting-Yuan Huang 013ad4b8e4 JVM_IR: defer some branch optimizations to codegen.
Specifically, defer the removal of hand-written "if (true|false)" from
JvmBuiltinOptimizationLowering into codegen so that appropriate debug
info (and a NOP) can be inserted.

Change-Id: Ia11af05ad8b4251946bd3e685fb7c3319f0f433f
2019-03-13 08:48:20 +01:00
Steven Schäfer 9ea39d2b7c Fix return types for while loops. 2019-03-12 09:33:00 +01:00
Steven Schäfer eec25dbea2 Avoid true condition generation for do while loop, since it confuses the Java verifier.
Change-Id: I96eca6623a91a8365090768f42c6e865b612e1cc
2019-03-06 16:04:23 +01:00
Dmitriy Novozhilov 5d0074bda5 Fix bug in try/catch resolution in NI
Bug was presented in a236ad5
2019-02-18 12:43:42 +03:00
Svyatoslav Kuzmich 75328f26ea [JS IR BE] Add missing KJS_WITH_FULL_RUNTIME to some tests
+ ranges test generator
2019-01-27 01:14:51 +03:00
Svyatoslav Kuzmich aa811dcfb3 [JS IR BE] Add KJS_WITH_FULL_RUNTIME directive to compiler tests 2019-01-24 16:14:40 +03:00
Mads Ager fb6eafddf1 JVM_IR: Generate better code for null checks.
Simplify ifs when branches have condition true/false.

Simplify blocks containing only a variable declaration
and a variable get of the same variable. Simplify to
just the condition.

Do not introduce temporary variables for constants for
null checks. Constants have no side-effects and can be
reloaded freely instead of going through a local.

This simplifies code such as "42.toLong()!!" so that the
resulting code has no branches and uses no locals. The
simplifications happen as follows:

```
block
  temp = 42.toLong()
  when
    (temp == null) throw NPE
    (true) load temp

---> null test simplification

block
  temp = 42.toLong()
  when
    (false) throw NPE
    (true) load temp

---> when simplification

block
  temp = 42.toLong()
  load temp

---> block simplification

42.toLong()
```
2019-01-23 15:11:14 +01:00
Mikhael Bogdanov d1efac617d Get rid of reduntant jvm parts in tests 2018-12-21 16:09:12 +01:00
Mikhael Bogdanov f59b6a350f Specify JVM target backend for other java related tests 2018-12-21 16:09:11 +01:00
Mikhael Bogdanov d76cb32781 Specify JVM target backend for test with java type inheritance 2018-12-21 16:09:11 +01:00
Alexander Udalov 5b58eb8491 Remove LANGUAGE_VERSION from non-coroutine codegen tests
Most of these tests used this directive as a way to opt in to a new
language feature, and most of those features are already stable for a
long time, so no opt-in is needed. Some other tests used the directive
to opt out from a language feature, replace those by the `LANGUAGE`
directive. One test used the directive to test behavior that actually
depended on the API version; use `API_VERSION` directive there instead.
2018-12-20 12:53:23 +01:00
Roman Artemev c5922bf74b Refact stdlib generator, add support for different backends
[JS IR BE] Runtime fixes
 * Do not generate external declarations for IR BE
 * Move `arrayToString` helper function out of shared JS stdlib
 * Fix arrays type check for IR BE
2018-11-29 22:04:53 +03:00
Dmitry Petrov 9082f19c00 KT-25907: Use proper loop parameter type in for-in-CharSequence 2018-11-20 09:52:09 +03:00
Roman Artemev 91ea377622 [JS IR BE] Fix translation for float literals 2018-10-25 15:48:42 +03:00
Svyatoslav Kuzmich 4c38d55f21 [JS IR BE] Unmute tests 2018-10-15 00:03:45 +03:00
Zalim Bashorov 8013a56286 [JS IR BE] process empty loops correctly in BlockDecomposerLowering 2018-10-13 01:51:59 +03:00
Anton Bannykh 8c6337f3f6 [JS IR BE]: support dynamic_var["foo"] = "bar"
Used EQ origin to detect. Added a test to check dynamic_var = "bar" case
is not affected
2018-10-10 13:43:22 +03:00
Svyatoslav Kuzmich 334c776b92 [JS IR BE] Fix @DoNotIntrinsify processing. Reuse it for compareTo 2018-09-28 20:27:01 +03:00
Anton Bannykh beaf6df8c5 [JS IR BE] support CharSequence and String methods 2018-09-21 18:16:03 +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
Svyatoslav Kuzmich ad58fdd158 [JS IR BE] Unmute tests after adding stdlib 2018-09-04 20:19:04 +03:00
Pavel Punegov 1ea9c2d4ba Replace min with coerceAtMost in test 2018-08-28 13:48:44 +03:00
Pavel Punegov 1a7d366733 Disable JVM tests in native 2018-08-28 13:48:44 +03:00
Zalim Bashorov 8966e220f0 Update tests 2018-08-17 21:44:08 +03:00
Mikhael Bogdanov 494828f4cf Unmute jvm ir-tests 2018-08-15 10:26:28 +03:00
Mikhael Bogdanov 357359b1dd Unmute ir-tests after CR support 2018-08-09 14:22:50 +03:00
Mikhael Bogdanov 06b16a6459 Unmute ir-tests after prev commit 2018-08-09 14:22:46 +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
Zalim Bashorov a6cd552a71 [JS IR BE] Implement Long.rangeTo and unmute tests 2018-07-25 14:51:08 +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
Roman Artemev f69bd54d6c [JS IR BE] Update test data 2018-06-19 17:09:31 +03:00
Anton Bannykh 96355e2732 JS IR: mute codegen box tests automatically 2018-06-09 19:15:38 +03:00
Dmitry Petrov 1eca402332 Use correctElementType to determine array element type for withIndex
Rather unkind "gotcha" in ASM API.

 #KT-23900 Fixed Target versions 1.2.50
2018-04-23 18:00:12 +03:00
Dmitry Petrov 99cea07bf4 Correctly map container element type in intrinsic for withIndex
In case of arrays, we couldn't distinguish array of boxed Ints
from array of primitive Ints.

 #KT-22904 Fixed Target versions 1.2.40
2018-02-20 09:18:25 +03:00
Mikaël Peltier 9fb0f59813 KT-17110 Rewrite branches targeting other branches
- Rewrite branches targeting other branches to target directly the
final destination to avoid runtime performance penalties.

Fix of https://youtrack.jetbrains.com/issue/KT-17110
2018-02-16 15:15:52 +03:00
Mikaël Peltier ef6b6cd261 Fix NPE into isArraySizeAccess 2018-02-15 12:41:33 +03:00
Mikaël Peltier 3c2f137fd5 Exclude tests from JS backend due to a bug into it 2018-02-15 12:41:33 +03:00
Mikaël Peltier be07a348ea Reformat tests 2018-02-15 12:41:33 +03:00
Mikaël Peltier 8676ca34d7 KT-22334 Specialized loops using range such as integer..array.size-1
- Into PrimitiveNumberRangeLiteralRangeValue modifies how bounded
value are created by checking if the high bound range can be modified
to be exclusive instead of inclusive such as the generated code will
be optimized.
- Add black box tests checking that the specialization does not fail
on any kind of arrays.
- Add a bytecode test checking that the code is correctly optimized.

Fix of https://youtrack.jetbrains.com/issue/KT-22334
2018-02-15 12:41:33 +03:00
Dmitry Petrov 72ffbb9825 Add test for array modification within for-in-array-withIndex loop body 2018-01-23 10:55:24 +03:00
Dmitry Petrov 40d1925e19 Provide optimized code generation for for-in-withIndex for sequences
#KT-5177 In Progress
2018-01-23 10:55:24 +03:00
Dmitry Petrov 2399a39414 Provide optimized code generation for for-in-withIndex for CharSequences
#KT-5177 In Progress
2018-01-23 10:55:24 +03:00
Dmitry Petrov 9c9e507172 Provide optimized code generation for for-in-withIndex for iterables
#KT-5177 In Progress
2018-01-23 10:55:24 +03:00