Commit Graph

614 Commits

Author SHA1 Message Date
Dmitry Petrov
bc7c8e4819 Update bytecode text tests for JVM_IR 2020-02-20 14:59:29 +03:00
Dmitry Petrov
81b30b7399 Update bytecode text tests for JVM_IR 2020-02-20 14:20:21 +03:00
Steven Schäfer
0ed719f792 JVM IR: Use package visibility for $assertionsDisabled field 2020-02-20 11:07:46 +01:00
Steven Schäfer
ba90e87756 JVM, JVM IR: Fix assertion status for regenerated anonymous objects
We always set the $assertionsDisabled field based on the top-level
enclosing class. This means that for anonymous objects we have to
rewrite the call to Class.desiredAssertionStatus.
2020-02-19 11:23:24 +01:00
Dmitry Petrov
0b9b1b6945 Update bytecode text tests for JVM_IR 2020-02-18 22:51:29 +03:00
Ilmir Usmanov
c748b6f3ee JVM_IR. Minor. Update bytecode text test to JVM_IR or create issues when this
is not feasible.
2020-02-18 11:43:37 +01:00
Dmitry Petrov
94d20d9176 Update bytecode text tests in JVM_IR 2020-02-17 23:52:48 +03:00
Mark Punzalan
64141b8b38 [JVM IR] Fix issue where fields are not being set to their default
values within initializer blocks.

The issue occurs in code like this:
```
class C {
  var b = true
  init {
    b = false   // Missing PUTFIELD for this statement
  }
}
```

Added a new statement origin for field initialization (at declaration)
instead of relying on `origin == null` in ExpressionCodegen to determine
whether to generate the initializations.

This was unintentionally broken in
d68a1898d0.
2020-02-17 23:04:11 +03:00
Jinseong Jeon
e3184e407d KT-20844 Re-enable stack spilling during inline.
`dx` has entered the final stage of sunset:
https://android-developers.googleblog.com/2020/02/the-path-to-dx-deprecation.html
2020-02-17 15:44:48 +01:00
Steven Schäfer
5760c0be9c JVM IR: Avoid redundant coercions in ExpressionCodegen 2020-02-15 22:32:23 +03:00
Dmitry Petrov
59cdf3c52e Update bytecode text tests in JVM_IR 2020-02-14 14:07:03 +03:00
Yan Zhulanow
cc2fe6b0c6 Debugger, BE: Generate original line number after inlining if call is used in an if condition
If a part of an 'if' condition is an inline function call, we need to insert the original condition line after it. Otherwise, the debugger will think it is inside the inline function implementation. Obviously, this breaks stepping – instead of the 'if' body, we go on stepping through the inline function.

This commit fixes 'KotlinSteppingTestGenerated.StepOver#testSoInlineLibFun' test.
2020-02-14 17:35:17 +09:00
Yan Zhulanow
8b17718086 Debugger, BE: Make the NOP instruction optimizer save the first NOP, not the last
This commit fixes the following tests:
 - KotlinSteppingTestGenerated.StepOver#testSoInlineLibFun
 - KotlinSteppingTestGenerated.StepOver#testSoInlineIterableFun
 - KotlinSteppingTestGenerated.StepOver#testSoInlineFunOnOneLineFor
2020-02-14 17:35:17 +09:00
Kristoffer Andersen
f782ea075b [JVM IR] ProperVisibilityForCompanionObjectInstanceField
- Uncomment tests
- Add proper visibility to companion field
  + Make exception for interfaces -> they need to respect language versions 1.8
    before they can put private members there.
- Adjust synthetic accessor lowering to look for enclosing classes with access
  via companion object.
2020-02-13 21:50:48 +03:00
Mark Punzalan
ba606147c9 [JVM IR] Maintain KT-36625 bug compatibility between non-IR and IR
backends by removing IMPLICIT_NOTNULL casts from IrStringConcatenation
arguments.

Also fixed an issue where IrStringConcatenation can be lowered into
a null String instead of a literal "null" String if the lone argument
was a platform type String or String with enhanced nullability and the
value was null (e.g., "${FromJava.nullPlatformString()}").
2020-02-12 22:57:15 +03:00
Steven Schäfer
6d23e50142 JVM IR: Create non-synthetic multifile parts for -Xmultifile-parts-inherit 2020-02-11 17:01:22 +01:00
Steven Schäfer
9db82bfcc8 JVM IR: Create package private synthetic multi file part classes 2020-02-11 17:01:22 +01:00
Steven Schäfer
951b2fa770 JVM IR: Optimize type checks to null checks if possible 2020-02-07 18:44:50 +03:00
Steven Schäfer
07737f8fc6 JVM IR: Fix BridgeLowering 2020-02-07 18:44:50 +03:00
Steven Schäfer
5f6af58aeb JVM IR: (Un)mute tests and add more tests for bridge generation 2020-02-07 18:44:50 +03:00
Dmitry Petrov
ee020ef290 KT-36336 @EnhancedNullability and null checks
Don't insert implicit null check on a value of @EnhancedNullability type
used where @EnhancedNullability type is expected.

This uncovers a bunch of other problems in FE and BE.
KT-36343 and KT-36347 are bugs in StrictJavaNullabilityAssertions
implementation which should most likely be fixed in next major language
version (with proper breaking change notice).
KT-36344 is a design problem which should be addressed after 1.4 issues
are resolved.
2020-02-05 11:15:41 +03:00
pyos
bda5b0d5a9 JVM_IR: further refine synthetic accessor generation
References to protected members from crossinline lambdas in the same
package do not need accessors.
2020-01-31 13:20:30 +01:00
Mads Ager
d68a1898d0 JVM_IR: Use direct field access instead of calling certain accessors.
Final default properties accessors that access a backing field
on the same class can be replaced by direct field use.

Perform the optimization late in the pipeline to allow lowerings
to expose more opportunities for optimizations.
2020-01-31 09:31:52 +01:00
Steven Schäfer
cf3e4608f3 JVM IR: Support -Xno-call-assertions 2020-01-30 14:43:23 +03:00
Mikhael Bogdanov
17e89fbbdb JVM_IR. Align synthetic parameter name generation across backends 2020-01-29 16:59:57 +01:00
max-kammerer
f256547cc8 Revert "JVM_IR: Use direct field access instead of calling certain accessors."
This reverts commit 62f9e7a810.
2020-01-28 14:55:56 +01:00
Mads Ager
62f9e7a810 JVM_IR: Use direct field access instead of calling certain accessors.
Final default properties accessors that access a backing field
on the same class can be replaced by direct field use.

Perform the optimization late in the pipeline to allow lowerings
to expose more opportunities for optimizations.
2020-01-28 10:42:15 +01:00
Steven Schäfer
8e07482862 JVM IR: Fix generation of parameterless default constructor
The JVM backend does not generate parameterless default constructors for
private constructors and constructors of local, inner, or inline
classes.
2020-01-21 16:34:33 +01:00
Mads Ager
79840a05b2 Fix test expectations.
Do not check for occurrences of "this" on the current backend.
I accidentally unified the checking for the two backends
without checking that it worked (used the wrong test suite to
test).
2020-01-21 11:26:02 +01:00
Alexander Udalov
6a90dc2efe Fix bytecode text tests for language version 1.4
New null check assertions are generated a bit more efficiently, with a
call to `checkNotNull` instead of IFNONNULL+jump.
2020-01-20 19:12:59 +01:00
Ilmir Usmanov
877509306d JVM_IR: Minor. Unmute tests. 2020-01-20 16:00:36 +01:00
Mikhail Zarechenskiy
5c5635ce20 Fix codegen & bytecode tests after unifying exceptions in JVM backend
See KT-22275 for details
2020-01-20 16:36:03 +03:00
Mads Ager
33a24bfd27 JVM_IR: Avoid using parent name in name of captures.
If parent is an anonymous object that could lead to the use
of names such as `$this$no name provided` which is invalid
in dex files.
2020-01-20 10:49:46 +01:00
Dmitry Petrov
f8341ad7eb JVM: Update tests for IEEE 754 comparisons 2020-01-17 14:14:59 +03:00
Dmitry Petrov
6bbfb2ffe9 JVM: add tests for companion object accessor generation 2020-01-15 16:40:06 +03:00
Alexander Udalov
7742a3b697 Rename UseExperimental->OptIn, Experimental->RequiresOptIn in compiler tests 2020-01-14 21:04:42 +01:00
Dmitry Petrov
a16b21a7cc JVM: Don't generate accessors to companions in earlier language versions 2020-01-14 16:12:19 +03:00
Alexander Udalov
b48d7f4ba7 JVM IR: fix InterfaceLowering for $default methods from base interfaces
The first change here is swapping the isCompatibility and hasJvmDefault
checks. Otherwise behavior could be different depending on -Xjvm-default
mode even for non-JvmDefault declarations, which makes little sense.

Another change is avoiding generating $default stubs for fake overrides
in interfaces, which replicates the behavior of the current backend.
(Note that this change also fixes the first problem on the newly added
tests, but the first change seems useful anyway.)
2020-01-10 14:05:27 +01:00
Dmitry Petrov
1d5370a56a Fix rationale for test muted in JVM_IR (see KT-35656) 2019-12-26 12:44:54 +03:00
Ilmir Usmanov
1ea89ce28e JVM_IR: Minor. Unmute tests 2019-12-23 18:03:44 +01:00
Ilya Chernikov
4e14d04926 [minor] fix testdata for compiler 1.4 2019-12-19 14:25:56 +01:00
Georgy Bronnikov
0d8036bb14 JVM_IR: do not generate main() when extension main is present
Extension methods with signature C.main() should not cause generation
of main(args: Array<String>).
2019-12-18 15:25:57 +03:00
Mikhael Bogdanov
03c2350e79 Keep original casts during reification to avoid VerifyError
#KT-26435 Fixed
2019-12-17 12:41:22 +01:00
Alexander Udalov
025360edc4 JVM IR: lookup symbols by name in ProgressionHandlers in known classes only
Alternatively, we could improve the lookup utilities and their usages to
always find the exact override of a symbol from
Collection/Iterable/CharSequence/etc, but since we need to load the
original symbol anyway in cases when the loop subject's type is a type
parameter, we might as well simplify everything and always reference the
original symbol.

Also improve exception message and removed unused declarations in
IrBackendUtils.kt.
2019-12-12 14:55:47 +03:00
pyos
498b41b148 JVM_IR: do not do invokeinterface on Object methods
This works on HotSpot, but might confuse other VMs.
2019-12-11 15:09:37 +01:00
Dmitry Petrov
f6b99955f8 Update testData in bytecodeText (argument nullability assertions) 2019-12-06 11:03:07 +03:00
Alexander Udalov
e9946b21b5 JVM IR: do not hide constructor with inline class types and defaults
This corresponds to the ABI generated by the old backend. Moreover, when
compiling the module 'ir.tree' with JVM IR (could not reproduce on a
small sample), this led to a codegen crash when trying to reassign
parameter value to the default stub, which is an error expression and
can't be generated by ExpressionCodegen.
2019-12-02 10:19:55 +01:00
Kristoffer Andersen
6f8682c950 [JVM IR] Stabilize accesor names in IR Backend
- introduce a scoped counter instead of a global one for name
  generation for accessors. Naive solution not working.

- Introduced hardcoded "jd" suffix for accessors on interfaces, under
  the assumption that the only such accessors are due to JvmDefault
  and their bridges from `$DefaultImpls`. Removed all associated
  templated tests, so the old and IR backend correspond on this matter
  again.

- Respecialized writeFlags from regexps to string-equality: we are
  going for exact matches now!

- Fixed package calculation in `IrUtils.kt`.

- Accessors for static members must be due to accessing super
  classes. Actual super-qualified calls are naturally also accessing
  super classes. Hence the `$s+{hashcode(superClassName)}`
  suffix. Added test to affirm this naming scheme.

- Field getters/setters for static fields must be companion accessors,
  otherwise just labelled as accessors. They are also tagged with `s`
  suffix when accessing static fields.

- For naming of accessors to coincide with the old backend, field
  renaming to avoid JVM signature clashes must be done _after_
  generation of accessors for those fields.
2019-12-02 08:19:52 +01:00
Kristoffer Andersen
d1c2862e27 IR: Align Interface Defaults with Old Backend
Change the treatment of default implementations on interfaces in JVM
compatibility mode. Previously, the IR backend moved the actual
default implementation to the DefaultImpls class, and then bridged to
it from the interface default. The old backend did the reverse, at the
cost of an additional accessor, in order to gain better binary
compatibility properties. See #2612 for discussion.

The accessor needs to call a specific implementation, so must be
performed through an `invokespecial`. We trick the
SyntheticAccessorLowering into doing this for us, by marking the
bridging call as a super call. We do this in want of an explicit
`invokespecial` Ir Node.

InterfaceDefaultCallsPhase previously assumed the old behaviour of the
IR backend (that calls to default implementations, e.g. `foo$default`
should target `DefaultImpls.foo$default`). But now the bridge to
foo$default resides on `DefaultImpls` already, causing that pass to
create a recursive loop. We cut that loop with a simple check.
2019-12-02 08:19:52 +01:00
pyos
e4b1599457 JVM_IR: do not erase constant non-static field initializers...
...unless in 1.4 mode.
2019-11-29 16:49:52 +01:00