[K/N] Enable extra option for mimalloc ^KT-53182

Merge-request: KT-MR-6952
Merged-by: Alexander Shabalin <Alexander.Shabalin@jetbrains.com>
This commit is contained in:
Alexander Shabalin
2022-09-01 09:02:23 +00:00
committed by Space
parent 77ab69240e
commit 0734456a87
6 changed files with 26 additions and 1 deletions
@@ -27,6 +27,7 @@ RUNTIME_WEAK int32_t Kotlin_printToAndroidLogcat = 1;
#endif
// Keep it 0 even when the compiler defaults to 1: if the overriding mechanism breaks, keeping it disabled is safer.
RUNTIME_WEAK int32_t Kotlin_appStateTracking = 0;
RUNTIME_WEAK int32_t Kotlin_mimallocUseDefaultOptions = 1;
ALWAYS_INLINE compiler::DestroyRuntimeMode compiler::destroyRuntimeMode() noexcept {
return static_cast<compiler::DestroyRuntimeMode>(Kotlin_destroyRuntimeMode);
@@ -58,3 +59,7 @@ ALWAYS_INLINE int compiler::getSourceInfo(void* addr, SourceInfo *result, int re
return Kotlin_getSourceInfo_Function(addr, result, result_size);
}
}
ALWAYS_INLINE bool compiler::mimallocUseDefaultOptions() noexcept {
return Kotlin_mimallocUseDefaultOptions != 0;
}
@@ -108,6 +108,7 @@ DestroyRuntimeMode destroyRuntimeMode() noexcept;
bool suspendFunctionsFromAnyThreadFromObjCEnabled() noexcept;
AppStateTracking appStateTracking() noexcept;
int getSourceInfo(void* addr, SourceInfo *result, int result_size) noexcept;
bool mimallocUseDefaultOptions() noexcept;
#ifdef KONAN_ANDROID
bool printToAndroidLogcat() noexcept;
@@ -5,12 +5,24 @@
#include "ObjectAlloc.hpp"
#include <mutex>
#include "../../mimalloc/c/include/mimalloc.h"
#include "Alignment.hpp"
#include "CompilerConstants.hpp"
using namespace kotlin;
namespace {
std::once_flag initOptions;
}
void kotlin::initObjectPool() noexcept {
if (!compiler::mimallocUseDefaultOptions()) {
std::call_once(initOptions, [] { mi_option_enable(mi_option_reset_decommits); });
}
mi_thread_init();
}