File tree Expand file tree Collapse file tree 4 files changed +57
-11
lines changed
include/swift/RemoteInspection Expand file tree Collapse file tree 4 files changed +57
-11
lines changed Original file line number Diff line number Diff line change
1
+ // ===--- GenericMetadataCacheEntry.h ----------------------------*- C++ -*-===//
2
+ //
3
+ // This source file is part of the Swift.org open source project
4
+ //
5
+ // Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors
6
+ // Licensed under Apache License v2.0 with Runtime Library Exception
7
+ //
8
+ // See https://swift.org/LICENSE.txt for license information
9
+ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10
+ //
11
+ // ===----------------------------------------------------------------------===//
12
+ //
13
+ // Declares a struct that mirrors the layout of GenericCacheEntry in
14
+ // Metadata.cpp and use a static assert to check that the offset of
15
+ // the member Value match between the two.
16
+ //
17
+ // ===----------------------------------------------------------------------===//
18
+
19
+ #ifndef SWIFT_REFLECTION_GENERICMETADATACACHEENTRY_H
20
+ #define SWIFT_REFLECTION_GENERICMETADATACACHEENTRY_H
21
+
22
+ #include < cstdint>
23
+
24
+ namespace swift {
25
+
26
+ template <typename StoredPointer>
27
+ struct GenericMetadataCacheEntry {
28
+ StoredPointer TrackingInfo;
29
+ uint16_t NumKeyParameters;
30
+ uint16_t NumWitnessTables;
31
+ uint16_t NumPacks;
32
+ uint16_t NumShapeClasses;
33
+ StoredPointer PackShapeDescriptors;
34
+ uint32_t Hash;
35
+ StoredPointer Value;
36
+ };
37
+
38
+ } // namespace swift
39
+
40
+ #endif // SWIFT_REFLECTION_GENERICMETADATACACHEENTRY_H
Original file line number Diff line number Diff line change 30
30
#include " swift/Concurrency/Actor.h"
31
31
#include " swift/Remote/MemoryReader.h"
32
32
#include " swift/Remote/MetadataReader.h"
33
+ #include " swift/RemoteInspection/GenericMetadataCacheEntry.h"
33
34
#include " swift/RemoteInspection/Records.h"
34
35
#include " swift/RemoteInspection/RuntimeInternals.h"
35
36
#include " swift/RemoteInspection/TypeLowering.h"
@@ -1289,22 +1290,14 @@ class ReflectionContext
1289
1290
StoredPointer allocationMetadataPointer (
1290
1291
MetadataAllocation<Runtime> Allocation) {
1291
1292
if (Allocation.Tag == GenericMetadataCacheTag) {
1292
- struct GenericMetadataCacheEntry {
1293
- StoredPointer LockedStorage;
1294
- uint8_t LockedStorageKind;
1295
- uint8_t TrackingInfo;
1296
- uint16_t NumKeyParameters;
1297
- uint16_t NumWitnessTables;
1298
- uint32_t Hash;
1299
- StoredPointer Value;
1300
- };
1301
1293
auto AllocationBytes =
1302
1294
getReader ().readBytes (RemoteAddress (Allocation.Ptr ),
1303
1295
Allocation.Size );
1304
1296
if (!AllocationBytes)
1305
1297
return 0 ;
1306
- auto Entry = reinterpret_cast <const GenericMetadataCacheEntry *>(
1307
- AllocationBytes.get ());
1298
+ auto Entry =
1299
+ reinterpret_cast <const GenericMetadataCacheEntry<StoredPointer> *>(
1300
+ AllocationBytes.get ());
1308
1301
return Entry->Value ;
1309
1302
}
1310
1303
return 0 ;
Original file line number Diff line number Diff line change 28
28
#include " swift/Basic/Range.h"
29
29
#include " swift/Basic/STLExtras.h"
30
30
#include " swift/Demangling/Demangler.h"
31
+ #include " swift/RemoteInspection/GenericMetadataCacheEntry.h"
31
32
#include " swift/Runtime/Casting.h"
32
33
#include " swift/Runtime/EnvironmentVariables.h"
33
34
#include " swift/Runtime/ExistentialContainer.h"
@@ -427,6 +428,16 @@ namespace {
427
428
};
428
429
} // end anonymous namespace
429
430
431
+ namespace swift {
432
+ struct StaticAssertGenericMetadataCacheEntryValueOffset {
433
+ static_assert (
434
+ offsetof (GenericCacheEntry, Value) ==
435
+ offsetof(swift::GenericMetadataCacheEntry<InProcess::StoredPointer>,
436
+ Value),
437
+ "The generic metadata cache entry layout mismatch");
438
+ };
439
+ }
440
+
430
441
namespace {
431
442
class GenericMetadataCache :
432
443
public MetadataCache<GenericCacheEntry, GenericMetadataCacheTag> {
Original file line number Diff line number Diff line change @@ -1583,6 +1583,8 @@ class VariadicMetadataCacheEntryBase :
1583
1583
bool matchesKey (const MetadataCacheKey &key) const {
1584
1584
return key == getKey ();
1585
1585
}
1586
+
1587
+ friend struct StaticAssertGenericMetadataCacheEntryValueOffset ;
1586
1588
};
1587
1589
1588
1590
template <class EntryType , uint16_t Tag>
You can’t perform that action at this time.
0 commit comments