[K/N] Add custom allocator prototype ^KT-55364

Enable custom allocator with -Xallocator=custom.

If the gc is cms (default):
 * a patched version of the memory manager is used that does not build a
   list of allocated objects.
 * a patched version of the cms is used that defers to the allocator for
   sweeping.

Otherwise, a warning is printed, and the allocator is used using the
standard api.

Design doc:
https://docs.google.com/document/d/15xMp-nE-DWL8OrtOc8DoXB80AHUphFICEGjj5K0aNFc

Co-authored-by: Troels Lund <troels@google.com>

Merge-request: KOTLIN-MR-546
Merged-by: Alexander Shabalin <alexander.shabalin@jetbrains.com>
This commit is contained in:
Troels Bjerre Lund
2022-12-08 17:22:04 +00:00
committed by Space
parent 40f38c8adb
commit bb1acf729b
33 changed files with 1519 additions and 15 deletions
+19
View File
@@ -129,6 +129,13 @@ bitcode {
headersDirs.from(files("src/main/cpp"))
}
module("custom_alloc") {
headersDirs.from(files("src/main/cpp", "src/mm/cpp", "src/gc/common/cpp", "src/gc/cms/cpp"))
compilerArgs.add("-DCUSTOM_ALLOCATOR")
// Directly depends on cms which is only supported with threads.
onlyIf { targetSupportsThreads(target.name) }
}
module("opt_alloc") {
headersDirs.from(files("src/main/cpp"))
}
@@ -191,10 +198,22 @@ bitcode {
onlyIf { targetSupportsThreads(target.name) }
}
module("concurrent_ms_gc_custom", file("src/gc/cms")) {
headersDirs.from(files("src/gc/cms/cpp", "src/gc/common/cpp", "src/mm/cpp", "src/main/cpp", "src/custom_alloc/cpp"))
compilerArgs.add("-DCUSTOM_ALLOCATOR")
onlyIf { targetSupportsThreads(target.name) }
}
testsGroup("std_alloc_runtime_tests") {
testedModules.addAll("main", "legacy_memory_manager", "strict", "std_alloc", "objc")
}
testsGroup("custom_alloc_runtime_tests") {
testedModules.addAll("custom_alloc")
testSupportModules.addAll("main", "experimental_memory_manager", "common_gc", "concurrent_ms_gc", "objc")
}
testsGroup("mimalloc_runtime_tests") {
testedModules.addAll("main", "legacy_memory_manager", "strict", "mimalloc", "opt_alloc", "objc")
}