Increase memory buffer for scanning objc classes on darwin systems

iOS systems are getting near this limit; double itfrom a 150kb
buffer to a 300kb buffer, which is freed after processing the
list of classes.

rdar://88454594
Differential Revision: https://reviews.llvm.org/D118972
This commit is contained in:
Jason Molenda 2022-02-04 23:53:27 -08:00
parent 5f35009996
commit a37c38176a
1 changed files with 8 additions and 5 deletions

View File

@ -2008,7 +2008,8 @@ AppleObjCRuntimeV2::SharedCacheClassInfoExtractor::UpdateISAToDescriptorMap() {
shared_cache_base_addr == LLDB_INVALID_ADDRESS) shared_cache_base_addr == LLDB_INVALID_ADDRESS)
return DescriptorMapUpdateResult::Fail(); return DescriptorMapUpdateResult::Fail();
const uint32_t num_classes = 128 * 1024; // The number of entries to pre-allocate room for.
const uint32_t max_num_classes = 256 * 1024;
UtilityFunction *get_class_info_code = GetClassInfoUtilityFunction(exe_ctx); UtilityFunction *get_class_info_code = GetClassInfoUtilityFunction(exe_ctx);
if (!get_class_info_code) { if (!get_class_info_code) {
@ -2030,7 +2031,7 @@ AppleObjCRuntimeV2::SharedCacheClassInfoExtractor::UpdateISAToDescriptorMap() {
DiagnosticManager diagnostics; DiagnosticManager diagnostics;
const uint32_t class_info_byte_size = addr_size + 4; const uint32_t class_info_byte_size = addr_size + 4;
const uint32_t class_infos_byte_size = num_classes * class_info_byte_size; const uint32_t class_infos_byte_size = max_num_classes * class_info_byte_size;
lldb::addr_t class_infos_addr = process->AllocateMemory( lldb::addr_t class_infos_addr = process->AllocateMemory(
class_infos_byte_size, ePermissionsReadable | ePermissionsWritable, err); class_infos_byte_size, ePermissionsReadable | ePermissionsWritable, err);
const uint32_t relative_selector_offset_addr_size = 64; const uint32_t relative_selector_offset_addr_size = 64;
@ -2096,10 +2097,12 @@ AppleObjCRuntimeV2::SharedCacheClassInfoExtractor::UpdateISAToDescriptorMap() {
num_class_infos = return_value.GetScalar().ULong(); num_class_infos = return_value.GetScalar().ULong();
LLDB_LOG(log, "Discovered {0} Objective-C classes in the shared cache", LLDB_LOG(log, "Discovered {0} Objective-C classes in the shared cache",
num_class_infos); num_class_infos);
assert(num_class_infos <= num_classes); // Assert if there were more classes than we pre-allocated
// room for.
assert(num_class_infos <= max_num_classes);
if (num_class_infos > 0) { if (num_class_infos > 0) {
if (num_class_infos > num_classes) { if (num_class_infos > max_num_classes) {
num_class_infos = num_classes; num_class_infos = max_num_classes;
success = false; success = false;
} else { } else {