Skip to content

Commit ad64827

Browse files
committed
---
yaml --- r: 348665 b: refs/heads/master c: b72c7fe h: refs/heads/master i: 348663: a8ee905
1 parent 2c1271c commit ad64827

File tree

9 files changed

+744
-32
lines changed

9 files changed

+744
-32
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 6e6de9eba34c8bf67741f5a7d817ce42d4dfd1ea
2+
refs/heads/master: b72c7fe660e2a1d81240c70c8b28457e6fa638aa
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/include/swift/Remote/MetadataReader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ class MetadataReader {
787787
baseSize = sizeof(TargetAnonymousContextDescriptor<Runtime>);
788788
if (AnonymousContextDescriptorFlags(flags.getKindSpecificFlags())
789789
.hasMangledName()) {
790-
baseSize += sizeof(TargetMangledContextName<Runtime>);
790+
metadataInitSize = sizeof(TargetMangledContextName<Runtime>);
791791
}
792792
break;
793793
case ContextDescriptorKind::Class:

trunk/include/swift/SIL/SILConstants.h

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ class SILValue;
2828
class SILBuilder;
2929
class SerializedSILLoader;
3030

31-
struct APIntSymbolicValue;
32-
struct ArraySymbolicValue;
31+
struct SymbolicArrayStorage;
3332
struct DerivedAddressValue;
3433
struct EnumWithPayloadSymbolicValue;
3534
struct SymbolicValueMemoryObject;
@@ -256,6 +255,12 @@ class SymbolicValue {
256255

257256
/// This represents an index *into* a memory object.
258257
RK_DerivedAddress,
258+
259+
/// This represents the internal storage of an array.
260+
RK_ArrayStorage,
261+
262+
/// This represents an array.
263+
RK_Array,
259264
};
260265

261266
union {
@@ -299,6 +304,31 @@ class SymbolicValue {
299304
/// When this SymbolicValue is of "DerivedAddress" kind, this pointer stores
300305
/// information about the memory object and access path of the access.
301306
DerivedAddressValue *derivedAddress;
307+
308+
// The following fields are for representing an Array.
309+
//
310+
// In Swift, an array is a non-trivial struct that stores a reference to an
311+
// internal storage: _ContiguousArrayStorage. Though arrays have value
312+
// semantics in Swift, it is not the case in SIL. In SIL, an array can be
313+
// mutated by taking the address of the internal storage i.e., through a
314+
// shared, mutable pointer to the internal storage of the array. In fact,
315+
// this is how an array initialization is lowered in SIL. Therefore, the
316+
// symbolic representation of an array is an addressable "memory cell"
317+
// (i.e., a SymbolicValueMemoryObject) containing the array storage. The
318+
// array storage is modeled by the type: SymbolicArrayStorage. This
319+
// representation of the array enables obtaining the address of the internal
320+
// storage and modifying the array through that address. Array operations
321+
// such as `append` that mutate an array must clone the internal storage of
322+
// the array, following the semantics of the Swift implementation of those
323+
// operations.
324+
325+
/// Representation of array storage (RK_ArrayStorage). SymbolicArrayStorage
326+
/// is a container for a sequence of symbolic values.
327+
SymbolicArrayStorage *arrayStorage;
328+
329+
/// When this symbolic value is of an "Array" kind, this stores a memory
330+
/// object that contains a SymbolicArrayStorage value.
331+
SymbolicValueMemoryObject *array;
302332
} value;
303333

304334
RepresentationKind representationKind : 8;
@@ -348,6 +378,12 @@ class SymbolicValue {
348378
/// This value represents the address of, or into, a memory object.
349379
Address,
350380

381+
/// This represents an internal array storage.
382+
ArrayStorage,
383+
384+
/// This represents an array value.
385+
Array,
386+
351387
/// These values are generally only seen internally to the system, external
352388
/// clients shouldn't have to deal with them.
353389
UninitMemory
@@ -471,6 +507,32 @@ class SymbolicValue {
471507
/// Return just the memory object for an address value.
472508
SymbolicValueMemoryObject *getAddressValueMemoryObject() const;
473509

510+
/// Create a symbolic array storage containing \c elements.
511+
static SymbolicValue
512+
getSymbolicArrayStorage(ArrayRef<SymbolicValue> elements, CanType elementType,
513+
SymbolicValueAllocator &allocator);
514+
515+
/// Create a symbolic array using the given symbolic array storage, which
516+
/// contains the array elements.
517+
static SymbolicValue getArray(Type arrayType, SymbolicValue arrayStorage,
518+
SymbolicValueAllocator &allocator);
519+
520+
/// Return the elements stored in this SymbolicValue of "ArrayStorage" kind.
521+
ArrayRef<SymbolicValue> getStoredElements(CanType &elementType) const;
522+
523+
/// Return the symbolic value representing the internal storage of this array.
524+
SymbolicValue getStorageOfArray() const;
525+
526+
/// Return the symbolic value representing the address of the element of this
527+
/// array at the given \c index. The return value is a derived address whose
528+
/// base is the memory object \c value.array (which contains the array
529+
/// storage) and whose accesspath is \c index.
530+
SymbolicValue getAddressOfArrayElement(SymbolicValueAllocator &allocator,
531+
unsigned index) const;
532+
533+
/// Return the type of this array symbolic value.
534+
Type getArrayType() const;
535+
474536
//===--------------------------------------------------------------------===//
475537
// Helpers
476538

@@ -545,7 +607,6 @@ struct SymbolicValueMemoryObject {
545607
SymbolicValueMemoryObject(const SymbolicValueMemoryObject &) = delete;
546608
void operator=(const SymbolicValueMemoryObject &) = delete;
547609
};
548-
549610
} // end namespace swift
550611

551612
#endif

0 commit comments

Comments
 (0)