mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Runtime+IRGen] Fix layout string flag in type layout and add array functions
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user