[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:
committed by
Space
parent
77ab69240e
commit
0734456a87
+2
@@ -40,6 +40,8 @@ object BinaryOptions : BinaryOptionRegistry() {
|
||||
val appStateTracking by option<AppStateTracking>()
|
||||
|
||||
val sanitizer by option<SanitizerKind>()
|
||||
|
||||
val mimallocUseDefaultOptions by booleanOption()
|
||||
}
|
||||
|
||||
open class BinaryOption<T : Any>(
|
||||
|
||||
+4
@@ -181,6 +181,10 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration
|
||||
configuration.get(BinaryOptions.appStateTracking) ?: AppStateTracking.DISABLED
|
||||
}
|
||||
|
||||
val mimallocUseDefaultOptions by lazy {
|
||||
configuration.get(BinaryOptions.mimallocUseDefaultOptions) ?: false
|
||||
}
|
||||
|
||||
init {
|
||||
if (!platformManager.isEnabled(target)) {
|
||||
error("Target ${target.visibleName} is not available on the ${HostManager.hostName} host")
|
||||
|
||||
+2
-1
@@ -2792,6 +2792,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
||||
overrideRuntimeGlobal("Kotlin_printToAndroidLogcat", Int32(if (programType.consolePrintsToLogcat) 1 else 0))
|
||||
}
|
||||
overrideRuntimeGlobal("Kotlin_appStateTracking", Int32(context.config.appStateTracking.value))
|
||||
overrideRuntimeGlobal("Kotlin_mimallocUseDefaultOptions", Int32(if (context.config.mimallocUseDefaultOptions) 1 else 0))
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------//
|
||||
@@ -2998,4 +2999,4 @@ internal fun Context.generateRuntimeConstantsModule() : LLVMModuleRef {
|
||||
setRuntimeConstGlobal("Kotlin_gcSchedulerType", Int32(config.gcSchedulerType.value))
|
||||
|
||||
return llvmModule
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user