Commit 3eccb11
[K/N] Enforce the native thread state for skiko's _nFlushAndSubmit
`org_jetbrains_skia_DirectContext__1nFlushAndSubmit` is a function from
Skiko written in C++ and called from Kotlin through a
`@SymbolName external fun`.
As discovered in KT-75895, this function might block and wait for
another Kotlin thread. Therefore, it violates the contract of
`SymbolName`. Switching the thread state to "native" is required when
calling such a function, which `SymbolName` doesn't do.
This commit adds a hack to the compiler: when calling a function with
such a symbol name, enforce thread state switching.
The hack is configurable: it is added in the form of a binary option,
`-Xbinary=forceNativeThreadStateForFunctions=fun1;fun2`, with
`org_jetbrains_skia_DirectContext__1nFlushAndSubmit` as the default
value.
It can also be disabled with
`-Xbinary=forceNativeThreadStateForFunctions=`.
Specifying a value for `forceNativeThreadStateForFunctions` disabled
compiler caches (since callsites to listed functions might be in the
caches).
^KT-77489 Fixed1 parent 5524d1e commit 3eccb11
File tree
3 files changed
+40
-5
lines changed- kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan
- llvm
3 files changed
+40
-5
lines changedLines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
| 90 | + | |
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
277 | 277 | | |
278 | 278 | | |
279 | 279 | | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
280 | 286 | | |
281 | 287 | | |
282 | 288 | | |
| |||
542 | 548 | | |
543 | 549 | | |
544 | 550 | | |
| 551 | + | |
545 | 552 | | |
546 | 553 | | |
547 | 554 | | |
| |||
Lines changed: 31 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2597 | 2597 | | |
2598 | 2598 | | |
2599 | 2599 | | |
2600 | | - | |
2601 | | - | |
2602 | | - | |
| 2600 | + | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
| 2609 | + | |
| 2610 | + | |
| 2611 | + | |
| 2612 | + | |
| 2613 | + | |
| 2614 | + | |
| 2615 | + | |
| 2616 | + | |
| 2617 | + | |
| 2618 | + | |
| 2619 | + | |
| 2620 | + | |
| 2621 | + | |
| 2622 | + | |
| 2623 | + | |
2603 | 2624 | | |
2604 | 2625 | | |
2605 | | - | |
| 2626 | + | |
2606 | 2627 | | |
2607 | 2628 | | |
2608 | | - | |
| 2629 | + | |
| 2630 | + | |
| 2631 | + | |
| 2632 | + | |
| 2633 | + | |
| 2634 | + | |
2609 | 2635 | | |
2610 | 2636 | | |
2611 | 2637 | | |
| |||
0 commit comments