Skip to content

Commit cedea94

Browse files
committed
Test fixes and review feedback
1 parent f76d841 commit cedea94

File tree

9 files changed

+58
-42
lines changed

9 files changed

+58
-42
lines changed

include/swift/RemoteInspection/TypeRef.h

+7-6
Original file line numberDiff line numberDiff line change
@@ -1123,27 +1123,28 @@ class IntegerTypeRef final : public TypeRef {
11231123
};
11241124

11251125
class BuiltinFixedArrayTypeRef final : public TypeRef {
1126-
intptr_t Size;
1126+
const TypeRef *Size;
11271127
const TypeRef *Element;
11281128

1129-
static TypeRefID Profile(const intptr_t &Size, const TypeRef *Element) {
1129+
static TypeRefID Profile(const TypeRef *Size, const TypeRef *Element) {
11301130
TypeRefID ID;
1131-
ID.addInteger((uint64_t)Size);
1131+
ID.addPointer(Size);
11321132
ID.addPointer(Element);
11331133
return ID;
11341134
}
11351135

11361136
public:
1137-
BuiltinFixedArrayTypeRef(const intptr_t &Size, const TypeRef *Element)
1137+
BuiltinFixedArrayTypeRef(const TypeRef *Size, const TypeRef *Element)
11381138
: TypeRef(TypeRefKind::BuiltinFixedArray), Size(Size), Element(Element) {}
11391139

11401140
template <typename Allocator>
1141-
static const BuiltinFixedArrayTypeRef *create(Allocator &A, intptr_t Size,
1141+
static const BuiltinFixedArrayTypeRef *create(Allocator &A,
1142+
const TypeRef *Size,
11421143
const TypeRef *Element) {
11431144
FIND_OR_CREATE_TYPEREF(A, BuiltinFixedArrayTypeRef, Size, Element);
11441145
}
11451146

1146-
const intptr_t &getSize() const {
1147+
const TypeRef *getSizeType() const {
11471148
return Size;
11481149
}
11491150

include/swift/RemoteInspection/TypeRefBuilder.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -938,9 +938,7 @@ class TypeRefBuilder {
938938

939939
const TypeRef *createBuiltinFixedArrayType(const TypeRef *size,
940940
const TypeRef *element) {
941-
auto integer = cast<IntegerTypeRef>(size);
942-
return BuiltinFixedArrayTypeRef::create(*this, integer->getValue(),
943-
element);
941+
return BuiltinFixedArrayTypeRef::create(*this, size, element);
944942
}
945943

946944
// Construct a bound generic type ref along with the parent type info

lib/Serialization/Serialization.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,7 @@ void Serializer::writeBlockInfoBlock() {
958958
BLOCK_RECORD(sil_block, SIL_OPEN_PACK_ELEMENT);
959959
BLOCK_RECORD(sil_block, SIL_PACK_ELEMENT_GET);
960960
BLOCK_RECORD(sil_block, SIL_PACK_ELEMENT_SET);
961+
BLOCK_RECORD(sil_block, SIL_TYPE_VALUE);
961962
BLOCK_RECORD(sil_block, SIL_DEBUG_SCOPE);
962963
BLOCK_RECORD(sil_block, SIL_DEBUG_SCOPE_REF);
963964
BLOCK_RECORD(sil_block, SIL_SOURCE_LOC);

stdlib/public/RemoteInspection/TypeLowering.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -2595,8 +2595,9 @@ class LowerType
25952595

25962596
const TypeInfo *visitBuiltinFixedArrayTypeRef(const BuiltinFixedArrayTypeRef *BA) {
25972597
auto elementTI = visit(BA->getElementType());
2598+
auto size = cast<IntegerTypeRef>(BA->getSizeType())->getValue();
25982599

2599-
return TC.makeTypeInfo<ArrayTypeInfo>(BA->getSize(), elementTI);
2600+
return TC.makeTypeInfo<ArrayTypeInfo>(size, elementTI);
26002601
}
26012602
};
26022603

stdlib/public/RemoteInspection/TypeRef.cpp

+4-7
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ class PrintTypeRef : public TypeRefVisitor<PrintTypeRef, void> {
404404

405405
void visitBuiltinFixedArrayTypeRef(const BuiltinFixedArrayTypeRef *BA) {
406406
printHeader("builtin_fixed_array");
407-
printField("size", std::to_string(BA->getSize()));
407+
printRec(BA->getSizeType());
408408
printRec(BA->getElementType());
409409
stream << ")";
410410
}
@@ -1086,10 +1086,7 @@ class DemanglingForTypeRef
10861086
Demangle::NodePointer visitBuiltinFixedArrayTypeRef(const BuiltinFixedArrayTypeRef *BA) {
10871087
auto ba = Dem.createNode(Node::Kind::BuiltinFixedArray);
10881088

1089-
auto size = Dem.createNode(Node::Kind::Type);
1090-
size->addChild(createInteger(BA->getSize()), Dem);
1091-
ba->addChild(size, Dem);
1092-
1089+
ba->addChild(visit(BA->getSizeType()), Dem);
10931090
ba->addChild(visit(BA->getElementType()), Dem);
10941091

10951092
return ba;
@@ -1327,7 +1324,7 @@ class ThickenMetatype
13271324
}
13281325

13291326
const TypeRef *visitBuiltinFixedArrayTypeRef(const BuiltinFixedArrayTypeRef *BA) {
1330-
return BuiltinFixedArrayTypeRef::create(Builder, BA->getSize(),
1327+
return BuiltinFixedArrayTypeRef::create(Builder, visit(BA->getSizeType()),
13311328
visit(BA->getElementType()));
13321329
}
13331330
};
@@ -1590,7 +1587,7 @@ class TypeRefSubstitution
15901587
}
15911588

15921589
const TypeRef *visitBuiltinFixedArrayTypeRef(const BuiltinFixedArrayTypeRef *BA) {
1593-
return BuiltinFixedArrayTypeRef::create(Builder, BA->getSize(),
1590+
return BuiltinFixedArrayTypeRef::create(Builder, visit(BA->getSizeType()),
15941591
visit(BA->getElementType()));
15951592
}
15961593
};

stdlib/public/core/Slab.swift

+25-22
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
@frozen
1616
public struct Slab<let count: Int, Element: ~Copyable>: ~Copyable {
1717
@usableFromInline
18-
let storage: Builtin.FixedArray<count, Element>
18+
internal let _storage: Builtin.FixedArray<count, Element>
1919
}
2020

2121
@available(SwiftStdlib 6.1, *)
@@ -37,23 +37,23 @@ extension Slab where Element: ~Copyable {
3737
@available(SwiftStdlib 6.1, *)
3838
@_alwaysEmitIntoClient
3939
@_transparent
40-
var address: UnsafePointer<Element> {
40+
internal var _address: UnsafePointer<Element> {
4141
UnsafePointer<Element>(Builtin.unprotectedAddressOfBorrow(self))
4242
}
4343

4444
/// Returns a buffer pointer over the entire vector.
4545
@available(SwiftStdlib 6.1, *)
4646
@_alwaysEmitIntoClient
4747
@_transparent
48-
var buffer: UnsafeBufferPointer<Element> {
49-
UnsafeBufferPointer<Element>(start: address, count: count)
48+
internal var _buffer: UnsafeBufferPointer<Element> {
49+
UnsafeBufferPointer<Element>(start: _address, count: count)
5050
}
5151

5252
/// Returns a mutable pointer to the first element in the vector.
5353
@available(SwiftStdlib 6.1, *)
5454
@_alwaysEmitIntoClient
5555
@_transparent
56-
var mutableAddress: UnsafeMutablePointer<Element> {
56+
internal var _mutableAddress: UnsafeMutablePointer<Element> {
5757
mutating get {
5858
UnsafeMutablePointer<Element>(Builtin.unprotectedAddressOf(&self))
5959
}
@@ -63,9 +63,9 @@ extension Slab where Element: ~Copyable {
6363
@available(SwiftStdlib 6.1, *)
6464
@_alwaysEmitIntoClient
6565
@_transparent
66-
var mutableBuffer: UnsafeMutableBufferPointer<Element> {
66+
internal var _mutableBuffer: UnsafeMutableBufferPointer<Element> {
6767
mutating get {
68-
UnsafeMutableBufferPointer<Element>(start: mutableAddress, count: count)
68+
UnsafeMutableBufferPointer<Element>(start: _mutableAddress, count: count)
6969
}
7070
}
7171

@@ -74,7 +74,7 @@ extension Slab where Element: ~Copyable {
7474
@available(SwiftStdlib 6.1, *)
7575
@_alwaysEmitIntoClient
7676
@_transparent
77-
static func _initializationBuffer(
77+
internal static func _initializationBuffer(
7878
start: Builtin.RawPointer
7979
) -> UnsafeMutableBufferPointer<Element> {
8080
UnsafeMutableBufferPointer<Element>(
@@ -197,7 +197,7 @@ extension Slab where Element: Copyable {
197197

198198
@available(SwiftStdlib 6.1, *)
199199
extension Slab where Element: ~Copyable {
200-
/// A type representing the collection's elements.
200+
/// The type of the container's elements.
201201
@available(SwiftStdlib 6.1, *)
202202
public typealias Element = Element
203203

@@ -292,7 +292,7 @@ extension Slab where Element: ~Copyable {
292292
@_alwaysEmitIntoClient
293293
@_transparent
294294
public borrowing func index(after i: Int) -> Int {
295-
i + 1
295+
i &+ 1
296296
}
297297

298298
/// Returns the position immediately before the given index.
@@ -304,7 +304,7 @@ extension Slab where Element: ~Copyable {
304304
@_alwaysEmitIntoClient
305305
@_transparent
306306
public borrowing func index(before i: Int) -> Int {
307-
i - 1
307+
i &- 1
308308
}
309309

310310
/// Accesses the element at the specified position.
@@ -334,14 +334,14 @@ extension Slab where Element: ~Copyable {
334334
unsafeAddress {
335335
_precondition(indices.contains(i), "Index out of bounds")
336336

337-
return address + i
337+
return _address + i
338338
}
339339

340340
@_transparent
341341
unsafeMutableAddress {
342342
_precondition(indices.contains(i), "Index out of bounds")
343343

344-
return mutableAddress + i
344+
return _mutableAddress + i
345345
}
346346
}
347347
}
@@ -369,14 +369,17 @@ extension Slab where Element: ~Copyable {
369369
_ i: Int,
370370
_ j: Int
371371
) {
372-
guard i != j, indices.contains(i), indices.contains(j) else {
372+
guard i != j else {
373373
return
374374
}
375375

376-
let ithElement = mutableBuffer.moveElement(from: i)
377-
let jthElement = mutableBuffer.moveElement(from: j)
378-
mutableBuffer.initializeElement(at: i, to: jthElement)
379-
mutableBuffer.initializeElement(at: j, to: ithElement)
376+
_precondition(indices.contains(i), "Index out of bounds")
377+
_precondition(indices.contains(j), "Index out of bounds")
378+
379+
let ithElement = _mutableBuffer.moveElement(from: i)
380+
let jthElement = _mutableBuffer.moveElement(from: j)
381+
_mutableBuffer.initializeElement(at: i, to: jthElement)
382+
_mutableBuffer.initializeElement(at: j, to: ithElement)
380383
}
381384
}
382385

@@ -422,10 +425,10 @@ extension Slab where Element: ~Copyable {
422425
@available(SwiftStdlib 6.1, *)
423426
@_alwaysEmitIntoClient
424427
@_transparent
425-
public borrowing func _withUnsafeBufferPointer<Result, E: Error>(
428+
public borrowing func _withUnsafeBufferPointer<Result: ~Copyable, E: Error>(
426429
_ body: (UnsafeBufferPointer<Element>) throws(E) -> Result
427430
) throws(E) -> Result {
428-
try body(buffer)
431+
try body(_buffer)
429432
}
430433

431434
/// Calls the given closure with a pointer to the vector's mutable contiguous
@@ -471,9 +474,9 @@ extension Slab where Element: ~Copyable {
471474
@available(SwiftStdlib 6.1, *)
472475
@_alwaysEmitIntoClient
473476
@_transparent
474-
public mutating func _withUnsafeMutableBufferPointer<Result, E: Error>(
477+
public mutating func _withUnsafeMutableBufferPointer<Result: ~Copyable, E: Error>(
475478
_ body: (UnsafeMutableBufferPointer<Element>) throws(E) -> Result
476479
) throws(E) -> Result {
477-
try body(mutableBuffer)
480+
try body(_mutableBuffer)
478481
}
479482
}

test/DebugInfo/value-generics-embedded.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: %target-swift-frontend %s -target %target-cpu-apple-macos14 -emit-ir -g -enable-experimental-feature ValueGenerics -enable-experimental-feature Embedded -wmo -disable-availability-checking -o - | %FileCheck %s
22

3-
// REQUIR123ES: swift_feature_ValueGenerics
3+
// REQUIRES: swift_feature_Embedded
4+
// REQUIRES: swift_feature_ValueGenerics
45

56
// CHECK-DAG: !DICompositeType({{.*}}templateParams: ![[SLAB_PARAMS:.*]], {{.*}}identifier: "$es4SlabVy$0_4main8MySpriteVGD"
67
// CHECK-DAG: ![[SLAB_PARAMS]] = !{![[COUNT_PARAM:.*]], ![[ELEMENT_PARAM:.*]]}

test/Reflection/typeref_lowering.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -1271,10 +1271,12 @@ BD
12711271
// CHECK-32-NEXT: (builtin size=48 alignment=8 stride=48 num_extra_inhabitants=0 bitwise_takable=1)
12721272

12731273
$1_SiBV
1274-
// CHECK-64: (builtin_fixed_array size=2
1274+
// CHECK-64: (builtin_fixed_array
1275+
// CHECK-64-NEXT: (integer value=2)
12751276
// CHECK-64-NEXT: (struct Swift.Int))
12761277
// CHECK-64-NEXT: (array size=16 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1)
12771278

1278-
// CHECK-32: (builtin_fixed_array size=2
1279+
// CHECK-32: (builtin_fixed_array
1280+
// CHECK-32-NEXT: (integer value=2)
12791281
// CHECK-32-NEXT: (struct Swift.Int))
12801282
// CHECK-32-NEXT: (array size=8 alignment=4 stride=8 num_extra_inhabitants=0 bitwise_takable=1)

test/abi/macOS/arm64/stdlib.swift

+12
Original file line numberDiff line numberDiff line change
@@ -809,3 +809,15 @@ Added: _$ss13_SwiftifyInfoON
809809

810810
// Eager-lazy Array bridging
811811
Added: _$ss12_ArrayBufferV14associationKeySVvpZMV
812+
813+
// Slab metadata accessor
814+
Added: _$ss4SlabVMa
815+
816+
// Slab nominal type descriptor
817+
Added: _$ss4SlabVMn
818+
819+
// Slab.count property descriptor
820+
Added: _$ss4SlabVsRi__rlE5countSivpZMV
821+
822+
// Slab._storage _read accessor
823+
Added: _$ss4SlabVsRi__rlE8_storagexq_BVvr

0 commit comments

Comments
 (0)