mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Runtime] Add tracing for section scans.
Section scans (for metadata, protocols, etc.) can be costly. This change adds tracing calls to those scans so we can more easily see how much time is spent in these scans and where they're initiated. This adds an os_signpost implementation controlled by SWIFT_STDLIB_TRACING, and a default empty implementation for when that's disabled. rdar://110266743
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include "../CompatibilityOverride/CompatibilityOverride.h"
|
||||
#include "ImageInspection.h"
|
||||
#include "Private.h"
|
||||
#include "Tracing.h"
|
||||
|
||||
#include <new>
|
||||
#include <vector>
|
||||
@@ -1089,6 +1090,9 @@ swift_conformsToProtocolMaybeInstantiateSuperclasses(
|
||||
}
|
||||
};
|
||||
|
||||
auto traceState =
|
||||
runtime::trace::protocol_conformance_scan_begin(type, protocol);
|
||||
|
||||
auto snapshot = C.SectionsToScan.snapshot();
|
||||
if (C.scanSectionsBackwards) {
|
||||
for (auto §ion : llvm::reverse(snapshot))
|
||||
@@ -1125,6 +1129,8 @@ swift_conformsToProtocolMaybeInstantiateSuperclasses(
|
||||
}
|
||||
noteFinalMetadataState(superclassIterator.state);
|
||||
|
||||
traceState.end(foundWitness);
|
||||
|
||||
// If it's for a superclass or if we didn't find anything, then add an
|
||||
// authoritative entry for this type.
|
||||
if (foundType != type)
|
||||
@@ -1170,13 +1176,15 @@ swift_conformsToProtocolImpl(const Metadata *const type,
|
||||
|
||||
const ContextDescriptor *
|
||||
swift::_searchConformancesByMangledTypeName(Demangle::NodePointer node) {
|
||||
auto traceState = runtime::trace::protocol_conformance_scan_begin(node);
|
||||
|
||||
auto &C = Conformances.get();
|
||||
|
||||
for (auto §ion : C.SectionsToScan.snapshot()) {
|
||||
for (const auto &record : section) {
|
||||
if (auto ntd = record->getTypeDescriptor()) {
|
||||
if (_contextDescriptorMatchesMangling(ntd, node))
|
||||
return ntd;
|
||||
return traceState.end(ntd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user