[Runtime+IRGen] Fix layout string flag in type layout and add array functions

This commit is contained in:
Dario Rexin
2023-08-21 10:54:35 -07:00
parent 31de67c713
commit 27b1764d13
5 changed files with 227 additions and 125 deletions

View File

@@ -22,6 +22,7 @@
//
//===----------------------------------------------------------------------===//
#include "BytecodeLayouts.h"
#include "swift/Runtime/Config.h"
#include "swift/Runtime/HeapObject.h"
#include "swift/Runtime/Metadata.h"
@@ -124,6 +125,10 @@ static void array_copy_operation(OpaqueValue *dest, OpaqueValue *src,
assert(copyKind == ArrayCopy::BackToFront);
assert(count != 0);
if (self->hasLayoutString() && destOp == ArrayDest::Init && srcOp == ArraySource::Copy) {
return swift_generic_arrayInitWithCopy(dest, src, count, stride, self);
}
auto copy = get_witness_function<destOp, srcOp>(wtable);
size_t i = count;
do {
@@ -202,6 +207,10 @@ void swift_arrayDestroy(OpaqueValue *begin, size_t count, const Metadata *self)
return;
auto stride = wtable->getStride();
if (self->hasLayoutString()) {
return swift_generic_arrayDestroy(begin, count, stride, self);
}
for (size_t i = 0; i < count; ++i) {
auto offset = i * stride;
auto *obj = reinterpret_cast<OpaqueValue *>((char *)begin + offset);