mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
libswift: Add the StackList data structure
StackList is a very efficient data structure for worklist type things. This is a port of the C++ utility with the same name. Compared to Array, it does not require any memory allocations.
This commit is contained in:
@@ -57,10 +57,10 @@ class Output;
|
||||
|
||||
namespace swift {
|
||||
|
||||
/// A fixed size slab of memory, which can be allocated and freed by the
|
||||
/// SILModule at (basically) zero cost.
|
||||
class FixedSizeSlab : public llvm::ilist_node<FixedSizeSlab>,
|
||||
public SILAllocated<FixedSizeSlab> {
|
||||
/// The payload for the FixedSizeSlab.
|
||||
/// This is a super-class rather than a member of FixedSizeSlab to make bridging
|
||||
/// with libswift easier.
|
||||
class FixedSizeSlabPayload {
|
||||
public:
|
||||
/// The capacity of the payload.
|
||||
static constexpr size_t capacity = 64 * sizeof(uintptr_t);
|
||||
@@ -78,7 +78,7 @@ private:
|
||||
uintptr_t overflowGuard = magicNumber;
|
||||
|
||||
public:
|
||||
void operator=(const FixedSizeSlab &) = delete;
|
||||
void operator=(const FixedSizeSlabPayload &) = delete;
|
||||
void operator delete(void *Ptr, size_t) = delete;
|
||||
|
||||
/// Returns the payload pointing to \p T.
|
||||
@@ -88,6 +88,17 @@ public:
|
||||
template<typename T> const T *dataFor() const { return (const T *)(&data[0]); }
|
||||
};
|
||||
|
||||
/// A fixed size slab of memory, which can be allocated and freed by the
|
||||
/// SILModule at (basically) zero cost.
|
||||
/// See SILModule::allocSlab().
|
||||
class FixedSizeSlab : public llvm::ilist_node<FixedSizeSlab>,
|
||||
public SILAllocated<FixedSizeSlab>,
|
||||
public FixedSizeSlabPayload {
|
||||
public:
|
||||
void operator=(const FixedSizeSlab &) = delete;
|
||||
void operator delete(void *Ptr, size_t) = delete;
|
||||
};
|
||||
|
||||
class AnyFunctionType;
|
||||
class ASTContext;
|
||||
class FileUnit;
|
||||
|
||||
Reference in New Issue
Block a user