LLVM
17.0.0git
|
Provides amortized O(1) random access to a CodeView type stream. More...
#include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h"
Public Member Functions | |
LazyRandomTypeCollection (uint32_t RecordCountHint) | |
LazyRandomTypeCollection (StringRef Data, uint32_t RecordCountHint) | |
LazyRandomTypeCollection (ArrayRef< uint8_t > Data, uint32_t RecordCountHint) | |
LazyRandomTypeCollection (const CVTypeArray &Types, uint32_t RecordCountHint, PartialOffsetArray PartialOffsets) | |
LazyRandomTypeCollection (const CVTypeArray &Types, uint32_t RecordCountHint) | |
void | reset (ArrayRef< uint8_t > Data, uint32_t RecordCountHint) |
void | reset (StringRef Data, uint32_t RecordCountHint) |
void | reset (BinaryStreamReader &Reader, uint32_t RecordCountHint) |
uint32_t | getOffsetOfType (TypeIndex Index) |
std::optional< CVType > | tryGetType (TypeIndex Index) |
CVType | getType (TypeIndex Index) override |
StringRef | getTypeName (TypeIndex Index) override |
bool | contains (TypeIndex Index) override |
uint32_t | size () override |
uint32_t | capacity () override |
std::optional< TypeIndex > | getFirst () override |
std::optional< TypeIndex > | getNext (TypeIndex Prev) override |
bool | replaceType (TypeIndex &Index, CVType Data, bool Stabilize) override |
![]() | |
virtual | ~TypeCollection ()=default |
bool | empty () |
template<typename TFunc > | |
void | ForEachRecord (TFunc Func) |
Provides amortized O(1) random access to a CodeView type stream.
Normally to access a type from a type stream, you must know its byte offset into the type stream, because type records are variable-lengthed. However, this is not the way we prefer to access them. For example, given a symbol record one of the fields may be the TypeIndex of the symbol's type record. Or given a type record such as an array type, there might be a TypeIndex for the element type. Sequential access is perfect when we're just dumping every entry, but it's very poor for real world usage.
Type streams in PDBs contain an additional field which is a list of pairs containing indices and their corresponding offsets, roughly every ~8KB of record data. This general idea need not be confined to PDBs though. By supplying such an array, the producer of a type stream can allow the consumer much better access time, because the consumer can find the nearest index in this array, and do a linear scan forward only from there.
LazyRandomTypeCollection implements this algorithm, but additionally goes one step further by caching offsets of every record that has been visited at least once. This way, even repeated visits of the same record will never require more than one linear scan. For a type stream of N elements divided into M chunks of roughly equal size, this yields a worst case lookup time of O(N/M) and an amortized time of O(1).
Definition at line 48 of file LazyRandomTypeCollection.h.
|
explicit |
Definition at line 34 of file LazyRandomTypeCollection.cpp.
Definition at line 50 of file LazyRandomTypeCollection.cpp.
References llvm::Data.
LazyRandomTypeCollection::LazyRandomTypeCollection | ( | ArrayRef< uint8_t > | Data, |
uint32_t | RecordCountHint | ||
) |
Definition at line 45 of file LazyRandomTypeCollection.cpp.
LazyRandomTypeCollection::LazyRandomTypeCollection | ( | const CVTypeArray & | Types, |
uint32_t | RecordCountHint, | ||
PartialOffsetArray | PartialOffsets | ||
) |
Definition at line 38 of file LazyRandomTypeCollection.cpp.
LazyRandomTypeCollection::LazyRandomTypeCollection | ( | const CVTypeArray & | Types, |
uint32_t | RecordCountHint | ||
) |
Definition at line 55 of file LazyRandomTypeCollection.cpp.
|
overridevirtual |
Implements llvm::codeview::TypeCollection.
Definition at line 147 of file LazyRandomTypeCollection.cpp.
|
overridevirtual |
Implements llvm::codeview::TypeCollection.
Definition at line 134 of file LazyRandomTypeCollection.cpp.
Referenced by getOffsetOfType(), getType(), and tryGetType().
|
overridevirtual |
Implements llvm::codeview::TypeCollection.
Definition at line 203 of file LazyRandomTypeCollection.cpp.
References llvm::consumeError(), llvm::codeview::EC, llvm::codeview::TypeIndex::fromArrayIndex(), and move.
Implements llvm::codeview::TypeCollection.
Definition at line 212 of file LazyRandomTypeCollection.cpp.
References llvm::consumeError(), llvm::codeview::EC, and move.
Definition at line 82 of file LazyRandomTypeCollection.cpp.
References assert(), contains(), and error().
Implements llvm::codeview::TypeCollection.
Definition at line 89 of file LazyRandomTypeCollection.cpp.
References assert(), contains(), llvm::codeview::EC, error(), and move.
Referenced by llvm::pdb::NativeInlineSiteSymbol::getName().
Implements llvm::codeview::TypeCollection.
Definition at line 112 of file LazyRandomTypeCollection.cpp.
References llvm::codeview::computeTypeName(), llvm::consumeError(), llvm::codeview::EC, I, move, llvm::StringSaver::save(), and llvm::codeview::TypeIndex::simpleTypeName().
Referenced by llvm::pdb::NativeInlineSiteSymbol::getName().
|
overridevirtual |
Implements llvm::codeview::TypeCollection.
Definition at line 280 of file LazyRandomTypeCollection.cpp.
References llvm_unreachable.
Definition at line 76 of file LazyRandomTypeCollection.cpp.
References llvm::Data, and llvm::support::little.
Referenced by reset().
void LazyRandomTypeCollection::reset | ( | BinaryStreamReader & | Reader, |
uint32_t | RecordCountHint | ||
) |
Definition at line 59 of file LazyRandomTypeCollection.cpp.
References llvm::BinaryStreamReader::bytesRemaining(), error(), and llvm::BinaryStreamReader::readArray().
Definition at line 71 of file LazyRandomTypeCollection.cpp.
References llvm::Data, llvm::support::little, and reset().
|
overridevirtual |
Implements llvm::codeview::TypeCollection.
Definition at line 145 of file LazyRandomTypeCollection.cpp.
Definition at line 99 of file LazyRandomTypeCollection.cpp.
References assert(), llvm::consumeError(), contains(), llvm::codeview::EC, and move.