This change parallelizes marking by making each non-native Kotlin thread
mark its own view of the heap. To make this safe, we make flipping the
marking bit atomic which ensures that threads do not try to trace the
same objects.
Co-authored-by: Johan Bay <jobay@google.com>
Merge-request: KOTLIN-MR-423
Merged-by: Alexander Shabalin <alexander.shabalin@jetbrains.com>
This patch adds a binary compiler argument to allow not crashing if a
suspend function is called from a non-Main dispatcher from ObjC or
Swift. This is relevant for people using the new memory model, in which
this restriction may be relaxed.
We don't want to deprecate freezing at all, but it is possible
that freezing, new memory model and lazy global initialization
combination might not work in some cases. It might be a problem
when such case appears in 3rd-party library that user can't fix.
To mitigate this problem this commit introduces `freezing` binary
option. It has three variants:
* Full - ol' good behavior.
* Disabled - well, no freezing at all.
* ExplicitOnly - a compromise when user want to freeze something
themselves, but something is messed up during globals initialization.
* Do not reset unhandled exception hook
* Add processUnhandledException to perform default unhandled exception
processing
* Add terminateWithUnhandledException to report the unhandled exception
and terminate the program
* Use the default unhandled exception processing in entrypoint, interop
boundaries and in Worker.executeAfter
* Add -Xworker-exception-handling to control exception processing of
Worker.executeAfter. By default its the old behaviour with the old MM,
and new behaviour with the new MM.