Skip to content

Commit 99a24d4

Browse files
authored
Introduce a CMake flag to disable fast-path context descriptor lookup based on short manglings (#39729)
1 parent 64bbb12 commit 99a24d4

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

stdlib/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ option(SWIFT_STDLIB_PASSTHROUGH_METADATA_ALLOCATOR
138138
"Build stdlib without a custom implementation of MetadataAllocator, relying on malloc+free instead."
139139
FALSE)
140140

141+
option(SWIFT_STDLIB_SHORT_MANGLING_LOOKUPS
142+
"Build stdlib with fast-path context descriptor lookups based on well-known short manglings."
143+
TRUE)
144+
141145
option(SWIFT_STDLIB_HAS_COMMANDLINE
142146
"Build stdlib with the CommandLine enum and support for argv/argc."
143147
TRUE)

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,10 @@ function(_add_target_variant_c_compile_flags)
359359
list(APPEND result "-DSWIFT_STDLIB_PASSTHROUGH_METADATA_ALLOCATOR")
360360
endif()
361361

362+
if(SWIFT_STDLIB_SHORT_MANGLING_LOOKUPS)
363+
list(APPEND result "-DSWIFT_STDLIB_SHORT_MANGLING_LOOKUPS")
364+
endif()
365+
362366
if(SWIFT_STDLIB_SUPPORTS_BACKTRACE_REPORTING)
363367
list(APPEND result "-DSWIFT_STDLIB_SUPPORTS_BACKTRACE_REPORTING")
364368
endif()

stdlib/public/runtime/MetadataLookup.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,7 @@ _findContextDescriptor(Demangle::NodePointer node,
699699
(const ContextDescriptor *)symbolicNode->getIndex());
700700
}
701701

702+
#if SWIFT_STDLIB_SHORT_MANGLING_LOOKUPS
702703
// Fast-path lookup for standard library type references with short manglings.
703704
if (symbolicNode->getNumChildren() >= 2
704705
&& symbolicNode->getChild(0)->getKind() == Node::Kind::Module
@@ -719,6 +720,7 @@ _findContextDescriptor(Demangle::NodePointer node,
719720

720721
#include "swift/Demangling/StandardTypesMangling.def"
721722
}
723+
#endif
722724

723725
const ContextDescriptor *foundContext = nullptr;
724726
auto &T = TypeMetadataRecords.get();

utils/build-presets.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2480,6 +2480,7 @@ extra-cmake-options=
24802480
-DSWIFT_IMPLICIT_CONCURRENCY_IMPORT:BOOL=FALSE
24812481
-DSWIFT_STDLIB_ENABLE_PRESPECIALIZATION:BOOL=FALSE
24822482
-DSWIFT_STDLIB_PASSTHROUGH_METADATA_ALLOCATOR:BOOL=TRUE
2483+
-DSWIFT_STDLIB_SHORT_MANGLING_LOOKUPS:BOOL=FALSE
24832484

24842485
[preset: stdlib_S_standalone_minimal_macho_x86_64,build]
24852486
mixin-preset=

0 commit comments

Comments
 (0)