Commit Graph

111 Commits

Author SHA1 Message Date
Arnold Schwaighofer
86c9407cba Add a utility function to Inspector to load the reflection metadata from
loaded images
2021-10-28 07:58:53 -07:00
Doug Gregor
9a8847dd4f [swift-inspect] Make sure to initialize backtrace flags.
This eliminates a compilation error with Swift 5.5 and the latest
argument parser library.
2021-08-31 09:56:50 -07:00
Mike Ash
ecd6d4ddec Add a new ConcurrentReadableHashMap type. Switch the protocol conformance cache
to use it.

ConcurrentReadableHashMap is lock-free for readers, with writers using a lock to
ensure mutual exclusion amongst each other. The intent is to eventually replace
all uses ConcurrentMap with ConcurrentReadableHashMap.

ConcurrentReadableHashMap provides for relatively quick lookups by using a hash
table. Rearders perform an atomic increment/decrement in order to inform writers
that there are active readers. The design attempts to minimize wasted memory by
storing the actual elements out-of-line, and having the table store indices into
a separate array of elements.

The protocol conformance cache now uses ConcurrentReadableHashMap, which
provides faster lookups and less memory use than the previous ConcurrentMap
implementation. The previous implementation caches
ProtocolConformanceDescriptors and extracts the WitnessTable after the cache
lookup. The new implementation directly caches the WitnessTable, removing an
extra step (potentially a quite slow one) from the fast path.

The previous implementation used a generational scheme to detect when negative
cache entries became obsolete due to new dynamic libraries being loaded, and
update them in place. The new implementation just clears the entire cache when
libraries are loaded, greatly simplifying the code and saving the memory needed
to track the current generation in each negative cache entry. This means we need
to re-cache all requested conformances after loading a dynamic library, but
loading libraries at runtime is rare and slow anyway.

rdar://problem/67268325
2020-08-20 13:05:30 -04:00
Mike Ash
5347179739 [swift-inspect] Consolidate options into OptionGroups shared between subcommands. 2020-07-15 14:01:49 -04:00
Mike Ash
b65d2b5f99 [Reflection][swift-inspect] Add a command for dumping metadata cache nodes. 2020-07-15 14:01:49 -04:00
Mike Ash
5eb226557b [swift-inspect] Support DLQ_GetPtrAuthMask. While we're in there, fix an snprintf warning in ReflectionContext.h 2020-07-10 12:34:25 -04:00
Mike Ash
3fcf86ac01 [Reflection][swift-inspect] Show tag names when dumping raw metadata allocations. 2020-06-17 11:31:12 -04:00
Mike Ash
cd624bf380 [Runtime][Reflection][swift-inspect] Add facilities for tracking and examining backtraces for metadata allocations.
rdar://problem/63674755
2020-06-11 14:49:52 -04:00
Ben Cohen
b3a5cb7550 Separate raw metadata and generic metadata dump commands 2020-05-29 10:55:36 -07:00
Ben Cohen
23ebf78e0d Add copywrite headers 2020-05-29 08:55:02 -07:00
Ben Cohen
49cbf9788f Rename swiftdt to swift-inspect 2020-05-29 08:31:04 -07:00