Commit Graph

19 Commits

Author SHA1 Message Date
Mads Ager 1f4a3b0d1c [JVM_IR] Avoid safe-call conversions from Byte? and Short? to Int? for
comparisons.

Having those conversions leads to unnecesary boxing and null checks.

This change does it only for JVM in the optimization lowering. It
is unclear to me if the other backends can get away with something
similar.
2020-05-08 11:39:30 +03:00
Dmitry Petrov 3143b15a17 Generate widening cast for Byte and Short to Int 2020-05-06 14:42:37 +03:00
Mads Ager 6257b32954 [JVM_IR] Avoid boxing when comparing primitive to object. 2020-05-01 17:53:34 +03:00
Mads Ager db17184cfd [JVM_IR] Avoid some boxing when comparing boxed primitives to primitives. 2020-05-01 13:14:20 +03:00
Dmitry Petrov 94d20d9176 Update bytecode text tests in JVM_IR 2020-02-17 23:52:48 +03:00
pyos fc6b03b08f JVM_IR: move const initialization handling to lowering
Had to edit some bytecodeText tests to account for the fact that JVM_IR
no longer generates explicit initializations for ConstantValue fields,
but NoConstantValueAttributeForNonConstVals is not the default yet.
2019-11-29 16:49:52 +01:00
Kristoffer Andersen e7d0909979 JVM_IR: Fix null-constant comparison with primitive types. 2019-09-09 10:23:11 +02:00
Jiaxiang Chen d3cc0e6ce9 JVM_IR: Optimize disjunction condition with intrinsic function call. 2019-05-28 08:48:43 +02: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
Mark Punzalan 3585792b3b Break out bytecodeText/conditions tests into smaller tests for if/while/do-while. 2019-03-15 08:32:22 +01:00
Mark Punzalan 9eb11ff3e9 Generate conditional jumps with optimizations for loops, if possible. 2019-03-15 08:32:22 +01:00
Mads Ager 057bdb3954 Generate better code for branches based on comparisons.
For comparison intrinsics and for instanceof checks, make
it possible to get the the stack value produced and branch
on that directly instead of materializing a boolean to
branch on from it.

That reduces code such as

```
    IF_CMPEQ L1
    CONST_0
    GOTO L2
L1: CONST_1
L2: IFEQ L3
```

to just one IF_CMP instruction.
2019-02-19 15:46:52 +01:00
Mads Ager 690b8e0ac9 JVM_IR: Optimize null checks.
Introduce lowering to remove null checks for primitive type
expressions and replace them with true/false. Side-effects
are preserved.

Generate ifnull/ifnonnull instructions for null checks instead
of materializing a null literal for an equality check.
2019-01-19 09:43:43 +01:00
Mads Ager 3a11322506 Enable bytecode text tests for the JVM_IR backend. 2018-12-21 16:20:45 +01:00
Dmitry Petrov e1a55e8dec Prefer compact bytecode for primitive/object comparisons with Boolean
'java.lang.Boolean#valueOf' doesn't allocate new objects
(it uses pre-allocated singletons for 'true' and 'false').
2017-07-21 08:52:29 +03:00
Dmitry Petrov 8e9c0294fe Do not box primitives for 'primitive == object'
NB user-defined 'equals' can violate contract for 'Object#equals', e.g.,
it can be asymmetric.
Thus we can't avoid boxing for 'object == primitive'.
2017-07-21 08:52:29 +03:00
Dmitry Petrov 1378b0cf05 Fix bytecode tests after new optimizations
- Turn some const conditions into non-const conditions
- Make sure inlined const values are used where required
(otherwise they are eliminated by POP backward propagation)
2017-05-16 17:28:43 +03:00
Michael Bogdanov 841b199d49 Optimize comparison with zero and null 2015-04-07 17:28:01 +03:00
Michael Bogdanov c7fe8e0b66 Branched value refactoring, And/Or support 2015-04-07 16:05:42 +03:00