[K/N] try to reimplement safe points with a load-branch-call

This commit is contained in:
Aleksei.Glushko
2023-04-03 23:09:04 +02:00
committed by Space Team
parent 5b4916a808
commit 5618ee84f8
30 changed files with 236 additions and 301 deletions
@@ -3,6 +3,8 @@
* that can be found in the LICENSE file.
*/
#pragma once
#include "Common.h"
#include "Utils.hpp"
@@ -9,6 +9,7 @@
#include <cstdarg>
#include "std_support/Span.hpp"
#include "CallsChecker.hpp"
#include "Format.h"
#include "Porting.h"
#include "StackTrace.hpp"
@@ -20,6 +21,8 @@ namespace {
THREAD_LOCAL_VARIABLE bool assertionReportInProgress = false;
void PrintAssert(bool allowStacktrace, const char* location, const char* format, std::va_list args) noexcept {
CallsCheckerIgnoreGuard ignoreCallsChecker;
if (assertionReportInProgress) {
// WARNING: avoid anything that can assert ar panic here
konan::consoleErrorf("An attempt to report an assertion lead to another failure:\n");
@@ -129,7 +129,6 @@ int getSourceInfo(void* symbol, SourceInfo *result, int result_len) {
// TODO: this implementation is just a hack, e.g. the result is inexact;
// however it is better to have an inexact stacktrace than not to have any.
NO_INLINE std_support::vector<void*> kotlin::internal::GetCurrentStackTrace(size_t skipFrames) noexcept {
NativeOrUnregisteredThreadGuard guard(true);
#if KONAN_NO_BACKTRACE
return {};
#else
@@ -174,7 +173,6 @@ NO_INLINE std_support::vector<void*> kotlin::internal::GetCurrentStackTrace(size
// TODO: this implementation is just a hack, e.g. the result is inexact;
// however it is better to have an inexact stacktrace than not to have any.
NO_INLINE size_t kotlin::internal::GetCurrentStackTrace(size_t skipFrames, std_support::span<void*> buffer) noexcept {
NativeOrUnregisteredThreadGuard guard(true);
#if KONAN_NO_BACKTRACE
return {};
#else
@@ -276,7 +274,6 @@ KNativePtr adjustAddressForSourceInfo(KNativePtr address) { return address; }
#endif
std_support::vector<std_support::string> kotlin::GetStackTraceStrings(std_support::span<void* const> stackTrace) noexcept {
NativeOrUnregisteredThreadGuard guard(true);
#if KONAN_NO_BACKTRACE
std_support::vector<std_support::string> strings;
strings.push_back("<UNIMPLEMENTED>");
@@ -98,17 +98,17 @@ object GC {
external fun start()
/**
* GC threshold, controlling how frequenly GC is activated, and how much time GC
* Deprecated and unused.
*
* Legacy MM: GC threshold, controlling how frequenly GC is activated, and how much time GC
* takes. Bigger values lead to longer GC pauses, but less GCs.
* Usually unused. For the on-safepoints GC scheduler counts
* how many safepoints must the code pass before informing the GC scheduler.
*
* Default: (old MM) 8 * 1024
*
* Default: (new MM) 100000
* Default: 8 * 1024
*
* @throws [IllegalArgumentException] when value is not positive.
*/
@Suppress("DEPRECATION")
@Deprecated("No-op in modern GC implementation")
var threshold: Int by kotlin.native.runtime.GC::threshold
/**
@@ -99,17 +99,16 @@ public object GC {
external fun start()
/**
* GC threshold, controlling how frequenly GC is activated, and how much time GC
* Deprecated and unused.
*
* Legacy MM: GC threshold, controlling how frequenly GC is activated, and how much time GC
* takes. Bigger values lead to longer GC pauses, but less GCs.
* Usually unused. For the on-safepoints GC scheduler counts
* how many safepoints must the code pass before informing the GC scheduler.
*
* Default: (old MM) 8 * 1024
*
* Default: (new MM) 100000
* Default: 8 * 1024
*
* @throws [IllegalArgumentException] when value is not positive.
*/
@Deprecated("No-op in modern GC implementation")
var threshold: Int
get() = getThreshold()
set(value) {