Skip to content

Commit a5ba9e0

Browse files
committed
Runtime: Remove unused swift_allocPOD implementation.
A vestige of the old box implementation that's now dead.
1 parent 144e993 commit a5ba9e0

File tree

2 files changed

+0
-69
lines changed

2 files changed

+0
-69
lines changed

include/swift/Runtime/HeapObject.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -123,26 +123,6 @@ inline TwoWordPair<A,B>::TwoWordPair(A first, B second)
123123

124124
using BoxPair = TwoWordPair<HeapObject *, OpaqueValue *>;
125125

126-
/// Allocates a heap object with POD value semantics. The returned memory is
127-
/// uninitialized outside of the heap object header. The object has an
128-
/// initial retain count of 1, and its metadata is set to a predefined
129-
/// POD heap metadata for which destruction is a no-op.
130-
///
131-
/// \param dataSize The size of the data area for the allocation.
132-
/// Excludes the heap metadata header.
133-
/// \param dataAlignmentMask The alignment of the data area.
134-
///
135-
/// \returns a BoxPair in which the heapObject field points to the newly-created
136-
/// HeapObject and the value field points to the data area inside the
137-
/// allocation. The value pointer will have the alignment specified
138-
/// by the dataAlignmentMask and point to dataSize bytes of memory.
139-
extern "C" BoxPair::Return
140-
swift_allocPOD(size_t dataSize, size_t dataAlignmentMask);
141-
142-
/// Deallocates a heap object known to have been allocated by swift_allocPOD and
143-
/// to have no remaining owners.
144-
extern "C" void swift_deallocPOD(HeapObject *obj);
145-
146126
/// Allocates a heap object that can contain a value of the given type.
147127
/// Returns a Box structure containing a HeapObject* pointer to the
148128
/// allocated object, and a pointer to the value inside the heap object.

stdlib/public/runtime/HeapObject.cpp

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -125,55 +125,6 @@ extern "C" void swift_bufferDeallocateFromStack(HeapObject *) {
125125

126126
extern "C" intptr_t swift_bufferHeaderSize() { return sizeof(HeapObject); }
127127

128-
/// A do-nothing destructor for POD metadata.
129-
static void destroyPOD(HeapObject *o);
130-
131-
/// Heap metadata for POD allocations.
132-
static const FullMetadata<HeapMetadata> PODHeapMetadata{
133-
HeapMetadataHeader{{destroyPOD}, {nullptr}},
134-
HeapMetadata{Metadata{MetadataKind::HeapLocalVariable}}
135-
};
136-
137-
namespace {
138-
/// Header for a POD allocation created by swift_allocPOD.
139-
struct PODBox : HeapObject {
140-
/// The size of the complete allocation.
141-
size_t allocatedSize;
142-
143-
/// The required alignment of the complete allocation.
144-
size_t allocatedAlignMask;
145-
146-
/// Returns the offset in bytes from the address of the header of a POD
147-
/// allocation with the given size and alignment.
148-
static size_t getValueOffset(size_t size, size_t alignMask) {
149-
// llvm::RoundUpToAlignment(size, mask + 1) generates terrible code
150-
return (sizeof(PODBox) + alignMask) & ~alignMask;
151-
}
152-
};
153-
}
154-
155-
static void destroyPOD(HeapObject *o) {
156-
auto box = static_cast<PODBox*>(o);
157-
// Deallocate the buffer.
158-
return swift_deallocObject(box, box->allocatedSize, box->allocatedAlignMask);
159-
}
160-
161-
BoxPair::Return
162-
swift::swift_allocPOD(size_t dataSize, size_t dataAlignmentMask) {
163-
assert(isAlignmentMask(dataAlignmentMask));
164-
// Allocate the heap object.
165-
size_t valueOffset = PODBox::getValueOffset(dataSize, dataAlignmentMask);
166-
size_t size = valueOffset + dataSize;
167-
size_t alignMask = std::max(dataAlignmentMask, alignof(HeapObject) - 1);
168-
auto *obj = swift_allocObject(&PODHeapMetadata, size, alignMask);
169-
// Initialize the header for the box.
170-
static_cast<PODBox*>(obj)->allocatedSize = size;
171-
static_cast<PODBox*>(obj)->allocatedAlignMask = alignMask;
172-
// Get the address of the value inside.
173-
auto *data = reinterpret_cast<char*>(obj) + valueOffset;
174-
return BoxPair{obj, reinterpret_cast<OpaqueValue*>(data)};
175-
}
176-
177128
namespace {
178129
/// Heap metadata for a box, which may have been generated statically by the
179130
/// compiler or by the runtime.

0 commit comments

Comments
 (0)