Commit Graph

62 Commits

Author SHA1 Message Date
pyos 9334327bbf JVM_IR: unmute two more tests fixed by #3106 2020-04-08 07:04:16 +02:00
pyos e98bdc6f8e JVM: preserve call site markers when inlining lambdas
and default functions into their own stubs.

Fixes #KT-35006
2020-03-31 16:06:57 +02:00
pyos 9d21800d8f JVM: fix SMAP range extension logic
If `mapLineNumber` was called in non-monotonic order, e.g. N then N+2
then N+1, the first two calls created a range that spans [N; N+2] but
the third call did not reuse it.
2020-03-31 16:06:57 +02:00
Jinseong Jeon 2352b1fec5 JVM_IR: use fresh source map when generating lambda body for inline. 2020-03-19 08:28:38 +01:00
Yan Zhulanow 7581e0bd8e Unmute noParametersArgumentCallInExpression test in JVM IR backend 2020-02-20 20:56:36 +09:00
Yan Zhulanow f4337eede1 Debugger, BE: Support lambda breakpoints for lambdas passed to '@InlineOnly' functions 2020-02-14 17:35:17 +09:00
Steven Schäfer e261b1e2de JVM IR: Fix line numbers in callable reference classes 2019-12-23 14:03:34 +01:00
Yan Zhulanow 076166c22f Debugger: Generate line numbers for class initializers with a number on the 'init' keyword (KT-16277)
Debugger tests not absent as they use the bootstrap version of kotlinc.
Obviously, this change is not present in it yet.
2019-11-25 17:26:31 +09:00
Steven Schäfer efb938a7c8 (Un)mute tests 2019-07-31 11:18:44 +02:00
Yan Zhulanow 9760c156a4 Debugger: Fix breakpoints on if/loops with constant conditions (KT-14421) 2019-07-08 16:25:18 +09:00
Yan Zhulanow 55bbcc4601 Generate line numbers for closing '}' in 'init {}' blocks (KT-12787) 2019-05-30 15:27:08 +09:00
Jiaxiang Chen 2c5ebf3ab2 Fix compareCustom function in IrLineNumberTest class, to exclude comment
lines that are not related for line number verification.

Unmute a test case should have been unmuted but shadowed by this bug.
2019-05-08 12:53:45 -07:00
Jiaxiang Chen 4b99d85322 Optimize JVM byte code generation for conditional conjunction
Implement an intrinsic method for boolean.and operation, and replace
ANDAND condition with a call to such intrinsic method.
2019-04-29 13:28:18 +02:00
Mikhael Bogdanov e01cac4c3d Fix test data 2019-03-26 17:17:54 +01: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
Yan Zhulanow 77c2a5c87c Debugger: Fix missing NOP in empty 'when' header (KT-29189) 2019-03-20 20:52:20 +03:00
Mads Ager bb0cd92da0 JVM_IR: Fix codegeneration for missing branches.
This used to generate an ACONST_NULL instruction leading to incorrect
stack height for code such as:

```
if (condition) else 32
```
2019-01-28 15:41:48 +01: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 0bb97cf590 Add test for Obsolete issue
#KT-12208 Obsolete
2019-01-09 16:00:03 +01:00
Denis Vnukov ddf92ef187 Creating IrLineNumberTestGenerated, adding line numbers for few common expressions
This PR enables LineNumberTestGenerated test on IR backend. The testing of
hardcoded sequence of line numbers is replaced with mere checks for set-like
checks for expected line numbers.
2018-08-29 12:52:20 +02:00
Yan Zhulanow 966480a155 Debugger: A dirty fix for setting breakpoints inside finally {} in case if exception is thrown from try {} (#KT-22654) 2018-04-02 19:14:28 +03:00
Nikolay Krasko d282f14eac Don't add double linenumber when return expression is absent (KT-18949)
#KT-18949 Fixed
2017-07-18 14:39:54 +03:00
Nikolay Krasko ce4f923ba0 Replace return with nop to avoid merging line instructions (KT-18949)
Dex ignores subsequent line numbers for same instructions and interprets
instruction after inline as if they were inlined. This makes debugger
behaves as if there's nowhere to stop on line with breakpoint.

This also makes stepping through inline function consistent with
non-inline analog. In both context debugger now stops on '}'.

 #KT-18949 Fixed
 #KT-17120 Fixed
2017-07-18 14:39:54 +03:00
Dmitry Petrov 65799a5cb4 Fix debugger-related tests after dead code elimination improvements 2017-05-16 17:28:43 +03:00
Mikhael Bogdanov 708bfdbd5f Generate line numbers for function call parameters
Before this fix line numbers for function call arguments were not generated,
 so if argument was on another line than function call it was
 impossible to stop on argument line during debugging.
 Now line number for each argument is generated if necessary
 (another line than function call line).

 #KT-17144 Fixed
2017-04-17 16:09:59 +02:00
Dmitry Petrov 4dd100122b Explicitly remove NOPs inserted for bytecode analysis in post-conditional loops.
Remove redundant NOPs during bytecode optimization.

NOP instruction is required iff one of the following is true:
(a) it is a first bytecode instruction in a try-catch block (JVM BE assumption);
(b) it is a sole bytecode instruction in a source code line (breakpoints on that line will not work).
All other NOP instructions can be removed.

Note that it doesn't really affect the performance for mature JVM implementations.
However, the perceived quality of the generated code is somewhat improved :).

Related: KT-15609
2017-01-13 10:31:07 +03:00
Dmitry Petrov ba933fa887 KT-15112, KT-15631
Revert changes for "tolerant to uninitialized values" in OptimizationBasicInterpreter:
this approach doesn't converge for some specific cases where local variable is reused
(e.g., in several inlined functions - see https://youtrack.jetbrains.com/issue/KT-15112).

Instead, treat fake always-false conditional jump in the beginning of the post-condition loop as a "reference point" for stack on loop break / continue.
This requires an extra abstraction layer in FixStackAnalyzer, since we can't perform fine-grain manipulations on Frames
(such as "combine frame C from local variables of frame A and stack of frame B").

NB additional NOPs will be generated for post-condition loops.
Should make a separate bytecode postprocessing pass to get rid of unnecessary NOPs
(several YT issues for perceived quality of the generated bytecode are about such NOPs).
2017-01-13 10:31:07 +03:00
Nikolay Krasko 87b628a3f7 Generate 'nop' instruction on lambda call when everything on line is going to be eliminated by inliner (KT-6477)
(cherry picked from commit 462bdb2)

 #KT-6477 Fixed
2016-10-14 14:52:06 +03:00
Nikolay Krasko 3d9d6e666d Test several line numbers are generated for one instruction
(cherry picked from commit 1ea9280)
2016-10-05 18:49:38 +03:00
Nikolay Krasko 57ef3f5656 Generate linenumber for goto instruction in while (KT-13059)
Otherwise linenumber for previous instruction will be used in debugger. That can lead to error stepping
because it might be line that isn't reachable on current iteration.

 #KT-13059 Fixed
2016-07-12 15:19:02 +03:00
Michael Bogdanov faca68297c Updated line numbers tests 2016-04-20 17:07:09 +03:00
Natalia Ukhorskaya 7a5ab93f9e Debugger: write line number for catch clause declaration 2016-04-15 15:58:07 +03:00
Natalia Ukhorskaya d0355a793b Write lineNumbers for constructors 2015-11-30 12:25:51 +03:00
Natalia Ukhorskaya 0d984ce8e2 Refactor AbstractLineNumberTest using assertEqualsToFile 2015-11-30 12:25:50 +03:00
Yan Zhulanow 9d1af5a17e Fix tests: "infix modifier required" and "operator modifier required" errors 2015-11-27 15:51:11 +03:00
Natalia Ukhorskaya cb80a3e83a Write lineNumber for function literal with void return value
#KT-9865 Fixed
2015-11-26 11:39:18 +03:00
Natalia Ukhorskaya 4a2e4312ea Write lineNumber when inline function result is written to property 2015-11-26 11:39:17 +03:00
Dmitry Petrov 3502c393fc Drop package facades: JVM BE tests passed. 2015-10-19 16:03:16 +03:00
Yan Zhulanow e14c9645dc Error on 'if' without an 'else' branch when used as an expression 2015-10-19 03:56:15 +03:00
Alexey Sedunov b4efe33efa IDEA 142.4859.6: Update LineNumberTestGenerated test data (due to IDEA's ASM upgrade to 5.0.4 which supports multiline labels) 2015-09-21 18:07:46 +03:00
Mikhail Glukhikh 3f14e74b08 Drop old enum syntax. Comma / semicolon are now a syntactic part of enum entry.
Comma must present now between enum entries, semicolon between last entry & first member, constructor calls must be without colons / specifiers.
A swarm of tests fixed accordingly.
2015-08-11 10:38:10 +03:00
Dmitry Jemerov 4bdf598bfe compiler testdata: s/trait/interface 2015-05-12 19:43:17 +02:00
Michael Bogdanov 99496f8f52 Update some test due smap generation 2015-04-09 09:25:26 +03:00
Michael Bogdanov c582b1d9ce Generate linenumber if needed after inlining 2015-04-09 09:25:26 +03:00
Michael Bogdanov ed62e4972f Temporary disable smap generation 2015-03-18 19:00:24 +03:00
Pavel V. Talanov 06916d98c6 default -> companion: replace all mentions of default and default object 2015-03-17 15:47:39 +03:00
Michael Bogdanov ea2f9e91e9 Test fix - update and review required 2015-03-16 18:52:01 +03:00
Michael Bogdanov a4117360a2 Smap refactorings 2015-03-16 18:52:01 +03:00
Pavel V. Talanov 59f192ef90 Replace 'class object' with 'default object' in renderers and test data
Includes changes to decompiled text
Old syntax is used in builtins and project code for now
2015-03-06 19:36:54 +03:00
Natalia Ukhorskaya e35b960eb5 Stepping: do not write line numbers for call arguments
#KT-3080 Fixed
2014-12-23 14:40:26 +03:00