@@ -125,55 +125,6 @@ extern "C" void swift_bufferDeallocateFromStack(HeapObject *) {
125
125
126
126
extern " C" intptr_t swift_bufferHeaderSize () { return sizeof (HeapObject); }
127
127
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
-
177
128
namespace {
178
129
// / Heap metadata for a box, which may have been generated statically by the
179
130
// / compiler or by the runtime.
0 commit comments