Commit Graph

82 Commits

Author SHA1 Message Date
Nikita Bobko 44b1cf6c46 Add docs for different metadata versions and proto files
Review: https://jetbrains.team/p/kt/reviews/8401
In scope of KT-55082
2023-02-01 15:13:34 +01:00
Dmitriy Novozhilov 66544a4e00 Switch kotlin version to 1.9
with appropriate fixes in testdata, tests and other
places.
2023-01-30 09:29:55 +00:00
Mikhail Glukhikh cbedbda527 Enhance API/messages around BinaryVersion / JvmMetadataVersion 2023-01-16 18:16:07 +01:00
Mikhail Glukhikh 13502abab9 Fix FIR bootstrap in version 2.0 2023-01-16 18:16:07 +01:00
Mikhail Glukhikh bbeae23b04 Allow to read metadata 2.0 from version 1.8 2023-01-16 18:16:07 +01:00
Mikhail Glukhikh 0c4a0360ac Deserialization/class reading: pass chosen JvmMetadataVersion whenever possible 2023-01-16 18:16:07 +01:00
Mikhail Glukhikh 89dd28226b BinaryVersion: introduce isCompatibleWithCurrentCompilerVersion 2023-01-16 18:12:55 +01:00
Mikhail Glukhikh 3dc05f4ec5 Introduce language version 2.0 and associate K2 compiler with it 2023-01-16 18:12:55 +01:00
Ilya Chernikov bb996c1b27 Switch kotlin version to 1.8
with appropriate fixes in testdata, tests and other
places.
2022-06-29 10:20:30 +02:00
Ilya Chernikov 6b61488099 Implement IC caches changes detection logic over frontend metadata 2022-03-30 08:31:02 +00:00
Ilya Chernikov 3ca4fe5f9e Refactor metadata serialization for using after frontend
for "tight" IC cycle
2022-03-30 08:30:54 +00:00
Evgeniy.Zhelenskiy 282ab398c6 [IR] Generify lowerings
#KT-1179
2022-03-24 11:38:42 +00:00
Mikhail Glukhikh 53d6ac24e5 Switch kotlin version to 1.7
* Change 1.6 to 1.7 constants
* Fix SAFE_CALL_WILL_CHANGE_NULLABILITY for testData
* Change EXPOSED_PROPERTY_TYPE_IN_CONSTRUCTOR_WARNING to EXPOSED_PROPERTY_TYPE_IN_CONSTRUCTOR_ERROR
* Change NON_EXHAUSTIVE_WHEN_STATEMENT to NO_ELSE_IN_WHEN
* Fix testData for SafeCallsAreAlwaysNullable
* Change T -> T & Any in test dumps
* Change INVALID_CHARACTERS_NATIVE_WARNING -> INVALID_CHARACTERS_NATIVE_ERROR
* TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_WARNING -> TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR
2022-02-25 11:46:27 +00:00
Mikhael Bogdanov a1262a4ecd Rename JVM default flags 2021-12-06 14:20:25 +01:00
Mikhael Bogdanov ea58c858d1 JvmDefault. Support @JvmDefaultWithCompatibility annotation
#KT-48217 Fixed
2021-12-06 14:20:24 +01:00
Andrey Uskov 4ad828f80f [JPS] Improved processing of broken caches
If serialized metadata version has evidently incorrect size the module
should be marked for rebuild prior to reading serialized version.

#KT-42194 Fixed
2021-09-21 10:41:12 +03:00
Mikhael Bogdanov a919aab3ab Update metadata related logic after switch to 1.6 2021-07-29 19:45:53 +02:00
pyos 6a3c79bb9e JVM: support on-the-fly generation of property delegates in metadata
Optimizations may remove the `x$delegate` field, in which case there
should be a `getX$delegate` method to reconstruct the value if needed
due to a call to `KProperty{0,1,2}.getDelegate`. We need to know the
signature of this method somehow.
2021-07-12 22:38:43 +02:00
Abduqodiri Qurbonzoda 19116e5623 Migrate compiler and others from sumBy to sumOf 2021-04-08 03:48:02 +03:00
Ilya Gorbunov e450a6494a Migrate deprecations in core, compiler, idea, tests
Replacing deprecated Char.toInt() with Char.code and
Number.toChar() with Number.toInt().toChar(), where Number is not Int.

KT-23451
2021-04-07 18:30:20 +03:00
Alexander Udalov ea01c97a8e Write underlying property name & type for inline class to metadata
This will be used in the compiler starting from 1.5.20 instead of the
currently used approach of looking for the single value parameter of the
primary constructor. The problem with the current approach is that
primary constructor can be private (since 1.4.30) and the property could
always be private. Relying on private declarations from metadata is
dangerous; for example lazy IR doesn't usually create stubs for private
declarations, and it didn't create stubs for private inline class
constructors before b5f9b1df, which led to the problem reported in
KT-44723.
2021-03-23 11:45:22 +01:00
Alexander Udalov f63ffc51ae Remove JvmBytecodeBinaryVersion from the compiler code
Move it to build-common where it's still used in incremental compilation
caches, and simplify a bit. In the future, it'll make sense to remove it
completely and to avoid writing it to caches. In this commit, I don't do
that to prevent the IC cache version to be updated, causing rebuilds for
all JPS projects.

 #KT-41758
2021-02-23 12:45:41 +01:00
Alexander Udalov 862a9143da Do not report errors about bytecode version
#KT-41758
2021-02-23 12:45:40 +01:00
Alexander Udalov 8c95b78346 Update JVM metadata version to 1.5.0
Improve the test which checks that we use correct metadata version if
`-language-version` is passed by checking all supported language
versions.

The change in libraries/reflect/build.gradle.kts is needed because
kotlinx-metadata-jvm of version 0.1.0 is based on pre-1.4 Kotlin, which
doesn't support the new module file metadata generated with metadata
version 1.4 and later, and module files need to be readable there to be
able to transform them for the shadow plugin.

Similarly override dependency on kotlinx-metadata-jvm in the
binary-compatibility-validator module.
2021-02-18 12:42:23 +01:00
Ilmir Usmanov f158411f9a Value classes: Increase JVM metadata version to distinguish
between inline and value classes.
2020-11-27 23:52:05 +01:00
Mads Ager 8d791ca98e [IR] Update naming, but not binary format for IrSetValue. 2020-10-06 21:47:29 +02:00
Dmitriy Novozhilov 36d2129fd3 Move common deserialization classes from :core:metadata modules 2020-09-11 10:08:37 +03:00
Dmitriy Novozhilov 9e1e525343 Fix circular dependency between :core:compiler:common.jvm and :core:metadata.jvm 2020-09-11 10:08:36 +03:00
Dmitriy Novozhilov 1417fcecb8 Move more common parts from :compiler:descriptors.jvm 2020-09-11 10:08:36 +03:00
Dmitriy Novozhilov 5d4d07066b Move common deserialization components to :core:metadata and :core:metadata.jvm 2020-09-11 10:08:35 +03:00
Dmitriy Dolovov 3d9093583f Metadata: 'non-stable parameter names' flag for callables
^KT-34602
2020-07-27 23:11:30 +07:00
Mikhail Bogdanov 3580c7c28c Write proto flag about compatibility mode
There is no any special aim for this flag now.
  But it could be useful in future in case of compatibility mode deprecation
2020-06-30 14:59:01 +02:00
Alexander Udalov 012ffa2993 Support new scheme of compilation of OptionalExpectation annotations
Instead of generating these annotation classes as package-private on
JVM, serialize their metadata to the .kotlin_module file, and load it
when compiling dependent multiplatform modules.

The problem with generating them as package-private was that
kotlin-stdlib for JVM would end up declaring symbols from other
platforms, which would include some annotations from package
kotlin.native. But using that package is discouraged by some tools
because it has a Java keyword in its name. In particular, jlink refused
to work with such artifact altogether (KT-21266).

 #KT-38652 Fixed
2020-05-12 19:28:57 +02:00
Alexander Udalov 098a935aa7 Fix exponential string table size of anonymous classes during inlining
When we inline an anonymous object which captures something such as
crossinline values or reified parameters, we copy and transform its
metadata in `AnonymousObjectTransformer.transformMetadata`. Basically we
read the metadata of the original class, add a minor protobuf extension
and write it to the new class.

This also includes copying the string table. We read the string table
into `JvmNameResolver` (a representation of string table used in
deserialization), then construct a `JvmStringTable` (a representation
used in _serialization_) and then write it back.

There's a few optimizations in the string table representation in JVM
metadata which allow to store less strings and thus take less space. See
`StringTableTypes.Record` in `jvm_metadata.proto` for more information.
One of the optimizations `Record.range` allows to avoid storing the same
record many times in a sequence. For example, if we have N different
strings in the string table but none of them require any operation (such
as substring, char replacement, etc.), then we only store the record
with all default values (no operation, no predefined string, etc.) and
set its `range` to N. Upon reading such optimized record list in
`JvmNameResolver`, we "expand" it back to normal, so that we could index
it quickly and figure out what operation needs to be performed on each
string from the string table.

The problem was that when we expanded this list, we didn't set the range
of the expanded record entry to 1. So each record in
`JvmNameResolver.records` still has its original range. It doesn't cause
any problems most of the time because the range in this expanded list is
almost unused. However, when copying/transforming metadata for anonymous
objects, we mistakenly passed this expanded list with incorrect ranges
to `JvmStringTable`. So the metadata in the copied anonymous object
ended up being incorrect: each record now was present the number of
times equal to its range. Copying such metadata once again led to
another multiplication of the record list size. Multiple copies resulted
in exponential increase in memory consumption and quickly led to OOM.

For the fix, we now take the original, unexpanded list of records when
creating `JvmStringTable` out of `JvmNameResolver` for transformation of
anonymous object metadata.

Note that another possible fix would be to make range for each record in
`JvmNameResolver.records` equal to 1. This is undesirable though, since
then we'd need to copy each `JvmProtoBuf.StringTableTypes.Record`
instance, of which there could be many, and use some memory for no
apparent gain (since ranges in that expanded list are now not used at
all).

 #KT-38197 Fixed
2020-04-28 12:59:52 +02:00
Mikhail Bogdanov 7d54027f41 Minor. Rename new proto property, JvmFlags.getClassFlags method
Compiler requires this new flag to know where actual interface method body is generated to emit proper method calls
2020-04-09 07:37:33 +02:00
Mikhail Bogdanov 7876d821a9 Minor. Rename jvm default utility methods 2020-04-09 07:37:33 +02:00
Mikhael Bogdanov ff8eac29a0 New flag in proto 2020-04-09 07:37:31 +02:00
Jinseong Jeon 79790ca227 Avoid uses of plain "kotlin" in metadata deserialization.
KT-35587 Fixed
2020-03-05 02:22:36 +01:00
Alexander Udalov c08c3d4d9b Update JVM metadata version to 1.4.0 2020-02-06 17:22:02 +01:00
Mikhail Zarechenskiy 303811cbd9 FIC: Increase JVM metadata version 2020-01-17 19:35:06 +03:00
Steven Schäfer 2e53e36fd5 JVM: Do not use equals-impl0 methods generated by older compiler versions 2019-09-18 18:52:58 +02:00
Alexander Udalov 01ddac58e1 Add language feature for changed name of property annotations method
#KT-31352 Fixed
2019-08-12 16:48:26 +02:00
Alexander Udalov ea0142da60 Use JVM name of getter in synthetic method for property annotations
#KT-31352 In Progress
2019-08-12 16:48:25 +02:00
Alexander Udalov a3d8fdf30a Fix compilation of kotlin-maven-plugin
Also remove the remaining usage (in a comment) of
JvmAbi.DEFAULT_MODULE_NAME
2019-05-27 13:21:31 +02:00
Alexander Udalov 9e2733915b Add module name JVM extensions to class/package in kotlinx-metadata-jvm
#KT-31308 Fixed
2019-05-24 14:42:25 +02:00
nikita.movshin 65244b4bea Update copyright.
Change the copyright from "JetBrains s.r.o." to
"JetBrains s.r.o. and Kotlin Project contributors"
Update only 2 lines copyright.
2019-04-23 20:09:22 +03:00
Alexander Udalov 59fda8d7ce Support JvmPackageName with JvmMultifileClass
This is an internal feature of our standard library needed to compile
new API for unsigned types
2019-03-06 15:34:23 +01:00
Mikhail Zarechenskiy 892fb9f39e Increment metadata version and improve message for error type
Follow-up of 617bed1b
2019-02-27 14:03:22 +03:00
Mikhail Zarechenskiy 7d2bc5c0f6 Properly load top-level constant initializers from multifile classes
Before Kotlin 1.3-M2 we didn't write `has_field` flag for constants
 inside multifile classes. Now we write and rely on this when
 trying to load constant initializers, which is totally fine for
 binaries that were compiled with the 1.3-M2 or newer version.
 Unfortunately, constant initializers will not be loaded for old binaries.

 One way is to avoid relying on this flag, but then we'll get other
 problems (e.g. 3345dc81fd).

 Therefore, for binaries that were compiled with at least 1.3-M2 version,
 we'll rely on the flag, otherwise, we won't.
2018-09-17 16:21:02 +03:00
Dmitry Petrov 88fb76bffc Fix annotations loading for inline class constructors 2018-09-14 16:09:41 +03:00