Commit Graph

109316 Commits

Author SHA1 Message Date
Marco Pennekamp 708ed81eb2 [Test] Avoid importing unused @Nested annotations in generated tests
- Unused `Nested` imports frequently cause unused import warnings in the
  IDE, which are especially annoying in after-commit warning/error
  analysis.
2024-02-27 20:30:06 +00:00
Abduqodiri Qurbonzoda 0811a5b77b Promote enumEntries() to stable #KT-65532 2024-02-27 19:49:12 +00:00
Artem Kobzar 02a78051aa [PSI2IR] Sync start and end offsets on PSI and FIR for an implicit return inside lambdas 2024-02-27 19:25:24 +00:00
Vladimir Sukharev a582bf22e3 [JS] Try remove ScriptRemoveReceiverLowering
^KT-64958
2024-02-27 19:10:03 +00:00
Aleksei.Glushko 69127b4483 [K/N] Exapnd concurrent part of the GC mark phase (KT-58865)
* Build mark closure completely concurrent.
    * Reintroduce concurrent weak processing.
    * Request the second STW only to preare the heap for sweeping.
2024-02-27 18:55:31 +00:00
Aleksei.Glushko b7067e0980 [K/N] ExtraSafePointActionActivator to be used in concurrnt mark 2024-02-27 18:55:31 +00:00
Aleksei.Glushko 728e9a5811 [K/N] OnceComputable C++ utility class 2024-02-27 18:55:31 +00:00
Anna Kozlova e650ba9855 [AA] return expect declaration for "implicit" actual
If actual declaration is broken (missing explicit `actual` keyword),
expect declaration still makes sense.
This way, we allow refactorings on broken code

^KT-65191 fixed
2024-02-27 18:49:02 +00:00
Ivan Kylchik 98dba48fde [Native] Simplify AssertRemovalLowering 2024-02-27 17:41:33 +00:00
Ivan Kylchik 6ec75a705e [IR] Store original function in the IrInlinedBlock
In Native and JS, there is a special logic where the compiler saves
a copy of inlined function (see `InlineFunctionsSupport`). This copy
is used in the IR inliner. Because of that, we can't really compare
inlined function with other functions directly. We need to
get `originalFunction` first and save it.
2024-02-27 17:41:33 +00:00
Artem Kobzar 800704a130 [K/JS] Allow private constructors inside external declarations ^KT-65964 Fixed 2024-02-27 16:51:07 +00:00
Marco Pennekamp aabb7aaa18 [LL] CleanableSoftValueCache: Make read/write action requirements bold
- This should improve the read/write action requirement visibility in
  the documentation.

^KT-61222
2024-02-27 16:45:52 +00:00
Marco Pennekamp 2b40ef6b05 [LL] CleanableSoftValueCache: Avoid cleanup on already removed values
- The cache guarantees deterministic cleanup on removal, so if the
  reference has already been removed from the cache, there is no need to
  clean it up again.
- Still, I don't want to guarantee that `SoftValueCleaner` is only
  invoked once (see its documentation), as soft reference semantics
  cannot be tested properly in our current test infrastructure.

^KT-61222
2024-02-27 16:45:52 +00:00
Marco Pennekamp f7a0e1f7c1 [LL] CleanableSoftValueCacheLincheckTest: Check cleanup state of removed values
- Now it's checked that cleanup behaves as expected in a concurrent
  setting for `put` and `remove`. Note that Lincheck never checks that a
  value is actually cleaned up. Instead, it compares the result with the
  single-threaded execution of a scenario. Hence, the non-concurrent
  `CleanableSoftValueCacheTest` is crucial, as it separately ensures
  correct deterministic cleanup in a single-threaded environment.
- We cannot test that operations returning a new value (such as `get`)
  always return values which haven't been cleaned up yet, because the
  value might be cleaned up by another thread between the return point
  of the operation and cleanup checking.

^KT-62136
2024-02-27 16:45:52 +00:00
Marco Pennekamp d4b0dfee0a [LL] Update Lincheck to version 2.24
- This new version fixes problems with concurrent hash maps in model
  checking tests and allows us to remove the correctness guarantee for
  them.

^KT-62136
2024-02-27 16:45:52 +00:00
Marco Pennekamp 5207940f0b [LL] CleanableSoftValueCache: Add non-concurrent tests for value cleanup
- The non-concurrent `CleanableSoftValueCacheTest` ensures that
  deterministic cleanup behaves correctly. A Lincheck test can only
  discover differences between the single-threaded and concurrent
  executions of a test scenario, so it cannot find correctness issues
  with deterministic cleanup on its own.

^KT-61222
2024-02-27 16:45:52 +00:00
Marco Pennekamp 53e545aa3f [LL] CleanableSoftValueCache: Don't perform cleanup when putting the same value
- If we have some value `X` in the cache, and we put `X` a second time
  into the same location, `X` shouldn't be cleaned up because it wasn't
  actually removed from the cache.
- With this feature, it's necessary to implement `put` in terms of
  `backingMap.compute`, because we need to compare the old and the new
  value atomically, and based on that, decide whether to create a new
  soft reference.

^KT-61222
2024-02-27 16:45:52 +00:00
Marco Pennekamp 80a2382cf6 [LL] Add Lincheck tests for CleanableSoftValueCache
- Lincheck tests the linearizability of a concurrent data structure,
  which helps us verify that `CleanableSoftValueCache` works in
  concurrent scenarios.

^KT-62136 fixed
2024-02-27 16:45:52 +00:00
Marco Pennekamp b2cd29726b [LL] Rewrite CleanableSoftValueCache in terms of ConcurrentHashMap.compute
- The previous implementation of `putIfAbsent` made two calls to the
  `backingMap`: `putIfAbsent` and `replace`. This breaks atomicity at
  least in theory. Implementing the major compute operations in terms of
  `backingMap.compute` allows us to restrict the critical section to
  this single atomic `ConcurrentHashMap` operation, which is easier to
  reason about.
- Using `backingMap.compute` also improves the guarantees we can make in
  respect to `computeIfAbsent`'s computation function `f`. We can now
  guarantee that the function is called exactly once iff the `key` is
  absent, because it is only ever invoked inside `backingMap.compute`,
  which makes this guarantee itself.
- Remove `putIfAbsent`, which isn't currently used by
  `LLFirSessionCache`. It can easily be implemented using
  `computeIfAbsent` in the future.

^KT-61222
2024-02-27 16:45:52 +00:00
Marco Pennekamp 5819f4eaa2 [LL FIR] Test resolve extension disposal after modification events
- These tests simply ensure that a resolve extension is disposed after
  any kind of modification event is raised. It's not meant to test
  complex scenarios, but rather to detect when resolve extension
  disposal isn't invoked *at all*.
- I tried implementing a similar test for resolve extension disposal
  after soft reference garbage collection, but the only way to force the
  GC to collect soft references is to allocate memory until an
  out-of-memory error occurs. That is bad for the test infrastructure,
  because it might allocate A LOT of memory (depending on the max heap),
  which is problematic for running tests locally. Also, our Kotlin tests
  stop on an OOM error altogether (so additional configuration would be
  required) and the heap is dumped into a 20GB file (on my machine),
  which is again problematic for local test runs.

^KT-61222
2024-02-27 16:45:52 +00:00
Marco Pennekamp 040b7472a9 [AA] Add MODIFICATION_EVENT test directive
- This allows tests to specify which modification event they want to
  publish.
- The modification event won't be published automatically. Tests need to
  invoke `publishModificationEventByDirective` at the right time.

^KT-56288
2024-02-27 16:45:52 +00:00
Marco Pennekamp 7a5a1833e7 [AA] Implement disposable KtResolveExtensions
- This commit adds the `Disposable` interface to `KtResolveExtension`.
  Resolve extensions are disposed after their associated session has
  been invalidated, or reclaimed by the GC.
- Example use case: Opening a message bus connection with the lifetime
  of the resolve extension.

^KT-61222 fixed
2024-02-27 16:45:52 +00:00
Marco Pennekamp efb56ed30a [LL FIR] Implement disposal support for LLFirSessions
- This commit adds a `Disposable` to `LLFirSession` which lives as long
  as the session. For example, session components can now open a message
  bus connection that is automatically disposed after the session has
  been invalidated or reclaimed.
- Because `LLFirSession`s should still benefit from soft reference-based
  automatic reclamation by the GC, we have to use a soft value map with
  cleanup in `LLFirSessionCache`. It ensures that the child disposables
  are properly disposed even when the session is collected as a soft
  value.
- The session cannot be the `Disposable` itself because a valid
  disposable reference is needed to call `Disposer.dispose`. When a soft
  reference is added to a reference queue (such as the reference queue
  employed by the soft value map), its referent is already cleared.
  Hence, it's not possible to watch a softly referenced `Disposable`
  with a reference queue and also pass it to `Disposer.dispose`. This is
  why the `LLFirSessionCleaner` contains a strong reference to the
  `disposable`, because that will not keep the `LLFirSession` from being
  reclaimed, while keeping the `disposable` alive slightly longer than
  the session.

^KT-61222
2024-02-27 16:45:52 +00:00
Marco Pennekamp 35856ab58f [LL FIR] Implement CleanableSoftValueCache
- This cache implementation is useful for lifecycle management of cached
  values when we also want to allow the GC to reclaim those values which
  are unused. It ensures that the cleanup is (almost) definitely invoked
  at some point after a value has been reclaimed by the GC, and also
  invokes the same cleanup operation when the value is removed from the
  cache conventionally. This unifies the approach to cleaning up such
  elements.
  - It would be possible to have the cache ONLY perform cleanup for
    references reclaimed by the GC, but this would put the onus on the
    consumer to perform the cleanup when an element is removed from the
    cache conventionally. That comes with its own pitfalls, such as
    requiring the user to handle `clear` correctly, or not forgetting
    to perform cleanup with the old value returned by `put`.
- "Almost definitely" because the reference queue won't be processed if
  the cache becomes unused at some point. However, this is not an issue
  for the current intended use case (session invalidation and disposal)
  and can be solved by clearing the cache before it becomes entirely
  unused.
- The cache requires read and write actions for certain operations to
  simplify the implementation of `clear`.

^KT-61222
2024-02-27 16:45:51 +00:00
Artem Kobzar 3429cbd321 [K/JS] Support companion objects in external and exported declarations 2024-02-27 16:30:13 +00:00
Alexander Udalov 5cda3fba12 IR: produce new fake override for each static member
This is an addition to d4278250e6. Apparently we still need to produce
a new fake override for each inherited static member, because otherwise
we would try to determine the most specific return type, maximum
visibility, etc, all of which makes no sense for static members.

 #KT-66152 Fixed
2024-02-27 16:05:52 +00:00
Dmitriy Dolovov f204293e4d [Test] Unify work with KLIB artifact paths and dependencies
Unify functions from `JsEnvironmentConfigurator` and
`WasmEnvironmentConfigurator` that do the same logic. Make this logic
also be available for `NativeEnvironmentConfigurator`:
- get*ArtifactSimpleName()
- get*KlibArtifactPath()
- get*KlibOutputDir()
- getAllRecursiveLibrariesFor()
- getAllRecursiveDependenciesFor()
- getAllDependenciesMappingFor()
- getKlibDependencies()

This would allow to have the same logic in one place, and also
reuse it in `IrBackendFacade`s to be implemented for Native.

^KT-65117
2024-02-27 15:22:47 +00:00
Timofey Solonin 7e9e064748 Add an IT for publication of multiplatform resources in a jvm target
^KT-65540
2024-02-27 14:04:51 +00:00
Timofey Solonin 370799b4e3 Publish multiplatform resources in for jvm target
^KT-65540
2024-02-27 14:04:51 +00:00
Timofey Solonin 3dd33e5aa7 Add external APIs to publish multiplatform resources in a target
^KT-65540
2024-02-27 14:04:51 +00:00
Andrei Tyrin 4e10dcd808 [tests] Klib based signature clash improve coverage for KT-63670 2024-02-27 14:01:44 +00:00
Artem Daugel-Dauge fff5a412ec [Gradle] Xcode version too high warning
Adds new warning diagnostic that checks that selected Xcode version is not higher than latest tested with the current Kotlin version

^KT-62373 Verification Pending
2024-02-27 13:23:55 +00:00
Artem Daugel-Dauge e822375461 [Gradle] Fix CocoaPods configuration cache IT for Gradle 8.6 2024-02-27 13:23:33 +00:00
Alexander Shabalin 0882d1752d [K/N][tests] Fix path-separator handling ^KT-65977 2024-02-27 13:20:50 +00:00
Alexander Shabalin c491858a49 [K/N][tests] Add EnforcedHostTarget to atomicfu tests ^KT-65977 2024-02-27 13:20:50 +00:00
Alexander Shabalin a8fcef9cca Revert "[K/N][tests] Remove atomicfu tests from :nativeCompilerTest ^KT-65977"
This reverts commit 513f86f8fc.
2024-02-27 13:20:50 +00:00
Alexander.Likhachev 2d161723d5 [Gradle] Regenerate Gradle compiler arguments DSL
^KT-65986 Fixed
2024-02-27 13:07:18 +00:00
Alexander.Likhachev 95fd91ae16 [CLI, Gradle] Update GradleDeprecatedOption.removeAfter values
The values updated to follow the deprecation cycle "warning -> error -> removed"
^KT-65986 In Progress
2024-02-27 13:07:18 +00:00
Alexander.Likhachev d20f31e963 [CLI, Gradle] Fix GradleDeprecatedOption.removeAfter processing
The expected format was Kotlin language version (e.g. `2.0`), however the actual passed values were Kotlin release versions (e.g. `2.0.0`)
^KT-65986 In Progress
2024-02-27 13:07:18 +00:00
Alexander.Likhachev 83a9ac62ea [Gradle] Regenerate Gradle compiler arguments DSL
^KT-65986 In Progress
2024-02-27 13:07:18 +00:00
Alexander.Likhachev d40d1316d3 [CLI, Gradle] Suppress deprecation errors in generated compiler arguments DSL
^KT-65986 In Progress
2024-02-27 13:07:18 +00:00
Alexander Shabalin ac6aad1f65 [K/N][tests] Do not run objcexport-header-generator in backend.native:tests ^KTI-1571 2024-02-27 12:24:36 +00:00
Roman Efremov 23ae617ea0 Fix inaccurate report of DEPRECATED_ACCESS_TO_ENTRY_PROPERTY_FROM_ENUM
Add separate diagnostic for the case when it is reported on qualifiers.

^KT-64488
2024-02-27 11:22:35 +00:00
Roman Efremov 02b5fed389 Fix inaccurate report of DEPRECATED_ACCESS_TO_ENTRY_PROPERTY_FROM_ENUM
It can be reported not only from within the enum, but also from
top-level functions. Add separate diagnostic for such cases.

^KT-64488
2024-02-27 11:22:35 +00:00
Roman Efremov 34d87465ac [Test] Add test for Enum.entries shadowing when property is imported
This is similar to KT-64488 but without context receivers.
Warning message "access ... from within the enum" is also incorrect
here.

^KT-64488
2024-02-27 11:22:35 +00:00
cristiangarcia e83d2e31d4 Fix CompileToBitcodePlugin onlyIf to make it CC compatible
Required for KTI-1553
2024-02-27 10:32:58 +00:00
Vyacheslav Gerasimov c382b0e2b3 Build: Remove kotlin-compiler from dependencies during Idea import
#KTI-1598
2024-02-27 10:29:59 +00:00
Vyacheslav Gerasimov 8fd3166199 Build: Remove coroutines-core dependency from backend.native:tests
The dependency on kotlinx-coroutines-core seems redundant and always
overridden by another dependency.
2024-02-27 10:29:59 +00:00
Vyacheslav Gerasimov f924de5a2c Build: Remove unused dependencies on :kotlin-compiler project
#KTI-1598
2024-02-27 10:29:59 +00:00
Timofey Solonin 5ddc7b47ef Add a task to hierarchically assemble multiplatform resources
^KT-65540
2024-02-27 10:27:38 +00:00