Commit Graph

82 Commits

Author SHA1 Message Date
Vladimir Sukharev 7c9e567496 [K2/N] KT-56028: Enable and patch test interop_kt49034_objcclass
Merge-request: KT-MR-8942
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-02-23 13:08:33 +00:00
Svyatoslav Scherbina 445d44b79a K2/Native: simplify forward declarations test to make it work with K2 2023-01-30 11:00:32 +00:00
Svyatoslav Scherbina f3ed006ed9 Native: add a test for forward declarations with two cinterop libs 2023-01-30 11:00:31 +00:00
Svyatoslav Scherbina d4f5d5297f K2/Native: simplify forward declarations test to make it work with K2 2023-01-30 11:00:31 +00:00
Svyatoslav Scherbina 46a85d9729 Native: add a test for cinterop forward declarations 2023-01-30 11:00:30 +00:00
Roman Efremov 5bd76dbf0b Temporarily comment failing Enum.entries resolve in K/N C interop
See KT-53929
2023-01-23 12:53:07 +01:00
Pavel Kunyavskiy fbc39fcab1 [K/N] Make a reproducer test for KT-55938
^KT-55938
2023-01-18 08:29:51 +01:00
Sergey Bogolepov 9bffec268a [K/N] Add a trivial test-case for KT-40426 2023-01-17 17:54:28 +00:00
Sergey Bogolepov 8120025076 [K/N] Add a test for KT-55653 2023-01-16 13:26:09 +00:00
Sergey Bogolepov 3ade4fbedc [K/N] Add backend.native test for objcClassesIncludingCategories 2023-01-16 13:26:08 +00:00
Vladimir Sukharev b883dc5434 [KT-39120] Add "-fmodules" argument support to Cinterop
Merge-request: KT-MR-6921
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2022-11-30 08:46:40 +00:00
Johan Bay bc13173ea9 [K/N] cinterop: Do not expand non-constant macros
Expanding macros such as __FILE__ or __TIME__ exposes
arbitrary generated filenames and timestamps from the compiler
pipeline which are not useful for interop and makes the klib
generation non-deterministic. This patch instead redefines
the macros to just map to their name in the properties
available from Kotlin.

Co-authored-by: Johan Bay <jobay@google.com>
2022-10-12 16:54:00 +00:00
Pavel Kunyavskiy 2a36c08e1f [K/N] Fix nan tests on mips 2022-09-08 12:13:43 +00:00
Pavel Kunyavskiy d822d3e7c6 [K/N] Reenable constant inlining except for Double nan constants
^KT-52970
2022-09-05 06:06:44 +00:00
Pavel Kunyavskiy 895a8ff149 [K/N] Basic support of Enum.entries for Native
No forward compatibility yet, with old klib IR linker will fail.

^KT-53324
2022-08-25 12:40:30 +00:00
Alexander Shabalin 58569f2eee Fix pthread to number converstion ^KT-52429
Merge-request: KT-MR-6918
Merged-by: Alexander Shabalin <Alexander.Shabalin@jetbrains.com>
2022-08-23 16:36:24 +00:00
Svyatoslav Scherbina 860f99482a Native: prohibit calling suspend functions from autoreleasepool {}
If a suspend function is called from `autoreleasepool {}` block, this
might cause the autoreleasepool frame to be removed earlier than
expected. See https://youtrack.jetbrains.com/issue/KT-50786 for more
details.

^KT-50786 Fixed
2022-08-23 14:30:54 +00:00
Alexander Shabalin 6f844f15e0 [K/N] Worker API improvements ^KT-52429
Merge-request: KT-MR-6898
Merged-by: Alexander Shabalin <Alexander.Shabalin@jetbrains.com>
2022-08-22 10:41:14 +00:00
Svyatoslav Scherbina ce6c8a51ba Native: fix @ExportObjCClass with the new memory manager
Previous implementation of `@ExportObjCClass` relied on the fact that
initialization of top-level fields was eager, i.e. happened during
Kotlin runtime initialization, when Kotlin code is accesses for the
first time.

With the new MM, initialization of top-level fields became lazy, it
happens when the particular file is accessed for the first time.

This commit fixes `@ExportObjCClass` with the new MM by making the
initialization of particular top-level fields eager.

^KT-53373 Fixed
2022-08-03 12:40:02 +00:00
Rick Clephas 497bb9a05c Add wrapped function test 2022-07-15 19:14:11 +03:00
Rick Clephas fd22add3ca Create test 2022-07-15 19:14:11 +03:00
Sergey Bogolepov bb493ccb3e [K/N] Add test-case for KT-49034 2022-06-24 23:57:12 +03:00
Alexander Shabalin 29f3445721 [K/N] Deprecated freezing ^KT-50541
Starting with 1.7.20 freezing is deprecated. See https://github.com/JetBrains/kotlin/blob/master/kotlin-native/NEW_MM.md#freezing-deprecation for details.

Merge-request: KT-MR-6399
Merged-by: Alexander Shabalin <Alexander.Shabalin@jetbrains.com>
2022-06-16 09:04:14 +00:00
Diego Gomez Olvera 9a430efbe7 [KT-52681] Remove unnecessary semicolon after Objective-C @end
Objective-c `@end` doesn't need a semicolon, however KMM exported header
file, for instance:
```
__attribute__((swift_name("KotlinIterator")))
@protocol MyProjectKotlinIterator
@required
- (BOOL)hasNext __attribute__((swift_name("hasNext()")));
- (id _Nullable)next __attribute__((swift_name("next()")));
@end;
```
This creates problems with some code checkers that will not expect it
there, so it seems best to remove it.
2022-06-10 15:46:27 +03:00
Vladimir Sukharev 83d7524232 Fix KT-26478: Objective-C-objects-class-name-is-null-in-ClassCastExceptions-message
#KT-26478 Fixed

Merge-request: KT-MR-6405
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2022-06-09 12:57:11 +00:00
Vladimir Sukharev eabf6dac7f Fix "kotlin.TypeCastException has no message on Native"
#KT-35544 Fixed

Merge-request: KT-MR-6392
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2022-06-03 07:40:26 +00:00
Alexander Shabalin 1535ab8eed [K/N] Tweak aligned allocation on all platforms ^KT-37272
Merge-request: KT-MR-6341
Merged-by: Alexander Shabalin <Alexander.Shabalin@jetbrains.com>
2022-05-27 15:10:32 +00:00
Igor Chevdar af566dd454 [K/N][tests] Added test for KT-51925 2022-04-28 14:31:30 +00:00
Svyatoslav Scherbina d8b1992fde Native: fix cinterop for Swift-produced Objective-C categories
For some reason, libclang's indexer doesn't index categories with
__attribute__((external_source_symbol(language="Swift",...))),
so we have to additionally enumerate them explicitly.

^KT-49455 Fixed
2022-02-11 12:45:39 +00:00
Svyatoslav Scherbina 76672a4abf Native: terminate if cinterop ObjC reference conversion throws exception
To avoid forwarding Obj-C exceptions to Kotlin or vice versa.
Otherwise this might lead to a crash or other undesirable behaviour.

^KT-50648 Fixed
2022-02-09 07:47:42 +00:00
Pavel Kunyavskiy 3798920183 [K/N] Any.isFrozen is now always false when freezing is disabled 2022-01-24 13:38:30 +00:00
Pavel Punegov 6dac9fd2a3 [K/N][test] Improve available processors test
Pass expected number of processors as arguments. Don't check it on
linux-arm32/64 which run remotely
2022-01-17 09:32:37 +00:00
Pavel Kunyavskiy 2ba0a7b40f [K/N] Implement Platform.availableProcessors
^KT-48179
2022-01-13 12:43:03 +00:00
Svyatoslav Scherbina 575c0fabb6 Native: add test for KT-38850
(the bug was fixed long ago, in 1.4-M1).
2021-12-08 13:00:15 +00:00
Elena Lepilkina c06875b8e9 [K/N] Added test for exceptions behaviour in case of dynamic libs (KT-47828) 2021-11-16 10:44:53 +00:00
Svyatoslav Scherbina ea7160947a Native: enable lazy IR generation before running fake override builder
^KT-48816 Fixed

Native compiler uses lazy IR for declarations provided by cinterop.
The problem: `FakeOverrideBuilder` requests super types during
type checking, accessing `.owner` for them. So if a type and super type
are represented as lazy IR, and lazy IR generation is not enabled yet,
then the super type symbol won't be bound by this moment, and the access
will fail.

This happens in KT-48816: fake override builder tries to access `.owner`
for `IrClassSymbol` of `NSObject` (super type of `NSDate` and `NSUUID`).

Fix this by enabling lazy IR generation before building fake overrides.
2021-11-10 12:30:12 +00:00
Elena Lepilkina 23e5079391 [K/N] Added test for checking C callback set with Kotlin function throwing exception 2021-11-02 12:04:43 +00:00
Pavel Kunyavskiy 172373c57e [K/N] Add tests for flexible arrays in interop
^KT-48074
2021-10-19 13:45:00 +00:00
Mikhail Glukhikh 3febabe977 Use OPT_IN instead of EXPERIMENTAL in diagnostic names 2021-09-10 16:29:13 +03:00
Vladimir Ivanov 8ba164163c [K/N] cinterop: ignore CXIdxEntity_CXXClass in ObjC header
Unexpected behavior is caused by `@class` declaration in ObjC context.
This entity is not used in CPP context either.
2021-09-09 09:37:05 +00:00
Dmitriy Dolovov df208dc060 [Native][tests] Fix failing 'interop_objc_smoke_noopgc' test 2021-09-03 14:53:10 +03:00
Dmitriy Dolovov 1a863106e6 [Native][tests] Move golden data outside of Gradle build file 2021-09-01 10:14:01 +03:00
Sergey Bogolepov d4c91c96d3 [K/N] Fix objc_acr_contract test in two_stage mode 2021-08-31 12:52:42 +00:00
Ilya Matveev 463bc22bf3 [K/N] Enable callbackOnSeparateThread test since KT-44283 is fixed 2021-08-26 14:46:07 +00:00
Ilya Matveev 99bd26c2ef [K/N][Runtime] Switch thread states in termination handlers 2021-08-26 14:46:07 +00:00
Sergey Bogolepov 9dd8266bee [K/N] Add trivial test for llvm.objc.clang.arc.use lowering 2021-08-24 10:19:33 +03:00
Alexander Gorshenev 9148094bbd Garbage collection capable wrappers for skia interop 2021-07-30 12:54:51 +03:00
Sergey Bogolepov f05110f99b [K/N] Add some tests for https://youtrack.jetbrains.com/issue/KT-47605 2021-07-07 07:50:57 +00:00
Ilya Matveev dc8186cb83 [K/N][Interop] Fix throwing exceptions through bridges in opt mode
By default, C functions compiled to bitcode by clang have the
nounwind attribute. If such functions throws an exception, the
behaviour is undefined.

Our interop machinery can process foreign exceptions on call sites
(terminate or wrap them in Kotlin exceptions). But if the interop
bridges have the nounwind attribute, LLVM optimizations (particularly
inlining) may lead to the situation when a foreign exception is ignored by
our foreign exception handler.

This patch fixes the issue by compiling bridges with -fexceptions flag.
This flag makes clang to not set the nounwind attribute, so exceptions
can be thrown through C frames.
2021-07-02 11:51:06 +00:00
Svyatoslav Scherbina e324c9b3fb Generate initRuntimeIfNeeded() at the beginning of staticCFunction
#KT-44283 Fixed
2021-06-16 06:39:51 +00:00