Skip to content

[stdlib] Uninline mirror code #17476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion stdlib/public/core/AnyHashable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ extension AnyHashable : CustomStringConvertible {
}

extension AnyHashable : CustomDebugStringConvertible {
@inlinable // FIXME(sil-serialize-all)
public var debugDescription: String {
return "AnyHashable(" + String(reflecting: base) + ")"
}
Expand Down
2 changes: 0 additions & 2 deletions stdlib/public/core/CTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ extension OpaquePointer: Hashable {

extension OpaquePointer : CustomDebugStringConvertible {
/// A textual representation of the pointer, suitable for debugging.
@inlinable // FIXME(sil-serialize-all)
public var debugDescription: String {
return _rawPointerToString(_rawValue)
}
Expand Down Expand Up @@ -236,7 +235,6 @@ public struct CVaListPointer {

extension CVaListPointer : CustomDebugStringConvertible {
/// A textual representation of the pointer, suitable for debugging.
@inlinable // FIXME(sil-serialize-all)
public var debugDescription: String {
return value.debugDescription
}
Expand Down
1 change: 0 additions & 1 deletion stdlib/public/core/Character.swift
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,6 @@ extension Character : LosslessStringConvertible { }

extension Character : CustomDebugStringConvertible {
/// A textual representation of the character, suitable for debugging.
@inlinable // FIXME(sil-serialize-all)
public var debugDescription: String {
return String(self).debugDescription
}
Expand Down
2 changes: 0 additions & 2 deletions stdlib/public/core/ClosedRange.swift
Original file line number Diff line number Diff line change
Expand Up @@ -412,15 +412,13 @@ extension ClosedRange : CustomStringConvertible {

extension ClosedRange : CustomDebugStringConvertible {
/// A textual representation of the range, suitable for debugging.
@inlinable // FIXME(sil-serialize-all)
public var debugDescription: String {
return "ClosedRange(\(String(reflecting: lowerBound))"
+ "...\(String(reflecting: upperBound)))"
}
}

extension ClosedRange : CustomReflectable {
@inlinable // FIXME(sil-serialize-all)
public var customMirror: Mirror {
return Mirror(
self, children: ["lowerBound": lowerBound, "upperBound": upperBound])
Expand Down
1 change: 0 additions & 1 deletion stdlib/public/core/Codable.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ extension CodingKey {
}

/// A textual representation of this key, suitable for debugging.
@inlinable // FIXME(sil-serialize-all)
public var debugDescription: String {
return description
}
Expand Down
2 changes: 0 additions & 2 deletions stdlib/public/core/CollectionOfOne.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,12 @@ extension CollectionOfOne: RandomAccessCollection, MutableCollection {

extension CollectionOfOne : CustomDebugStringConvertible {
/// A textual representation of the collection, suitable for debugging.
@inlinable // FIXME(sil-serialize-all)
public var debugDescription: String {
return "CollectionOfOne(\(String(reflecting: _element)))"
}
}

extension CollectionOfOne : CustomReflectable {
@inlinable // FIXME(sil-serialize-all)
public var customMirror: Mirror {
return Mirror(self, children: ["element": _element])
}
Expand Down
5 changes: 0 additions & 5 deletions stdlib/public/core/Dictionary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,6 @@ extension Dictionary {
return _makeCollectionDescription(for: self, withTypeName: nil)
}

@inlinable // FIXME(sil-serialize-all)
public var debugDescription: String {
return _makeCollectionDescription(for: self, withTypeName: "Dictionary.Keys")
}
Expand Down Expand Up @@ -1419,7 +1418,6 @@ extension Dictionary {
return _makeCollectionDescription(for: self, withTypeName: nil)
}

@inlinable // FIXME(sil-serialize-all)
public var debugDescription: String {
return _makeCollectionDescription(for: self, withTypeName: "Dictionary.Values")
}
Expand Down Expand Up @@ -1551,7 +1549,6 @@ extension Dictionary: CustomStringConvertible, CustomDebugStringConvertible {

/// A string that represents the contents of the dictionary, suitable for
/// debugging.
@inlinable // FIXME(sil-serialize-all)
public var debugDescription: String {
return _makeDescription()
}
Expand Down Expand Up @@ -4661,7 +4658,6 @@ public struct DictionaryIterator<Key: Hashable, Value>: IteratorProtocol {

extension DictionaryIterator: CustomReflectable {
/// A mirror that reflects the iterator.
@inlinable // FIXME(sil-serialize-all)
public var customMirror: Mirror {
return Mirror(
self,
Expand All @@ -4671,7 +4667,6 @@ extension DictionaryIterator: CustomReflectable {

extension Dictionary: CustomReflectable {
/// A mirror that reflects the dictionary.
@inlinable // FIXME(sil-serialize-all)
public var customMirror: Mirror {
let style = Mirror.DisplayStyle.dictionary
return Mirror(self, unlabeledChildren: self, displayStyle: style)
Expand Down
1 change: 0 additions & 1 deletion stdlib/public/core/FloatingPointTypes.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ extension ${Self} : CustomStringConvertible {

extension ${Self} : CustomDebugStringConvertible {
/// A textual representation of the value, suitable for debugging.
@inlinable // FIXME(sil-serialize-all)
public var debugDescription: String {
if isFinite || isNaN {
return _float${bits}ToString(self, debug: true)
Expand Down
24 changes: 1 addition & 23 deletions stdlib/public/core/Mirror.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,13 @@
///
/// To customize the mirror representation of a custom type, add conformance to
/// the `CustomReflectable` protocol.
@_fixed_layout // FIXME(sil-serialize-all)
public struct Mirror {
/// Representation of descendant classes that don't override
/// `customMirror`.
///
/// Note that the effect of this setting goes no deeper than the
/// nearest descendant class that overrides `customMirror`, which
/// in turn can determine representation of *its* descendants.
@_frozen // FIXME(sil-serialize-all)
@usableFromInline // FIXME(sil-serialize-all)
internal enum _DefaultDescendantRepresentation {
/// Generate a default mirror for descendant classes that don't
/// override `customMirror`.
Expand Down Expand Up @@ -115,7 +112,6 @@ public struct Mirror {
/// though, the observability of mutations is unspecified.
///
/// - Parameter subject: The instance for which to create a mirror.
@inlinable // FIXME(sil-serialize-all)
public init(reflecting subject: Any) {
if case let customized as CustomReflectable = subject {
self = customized.customMirror
Expand Down Expand Up @@ -156,12 +152,10 @@ public struct Mirror {
case dictionary, `set`
}

@inlinable // FIXME(sil-serialize-all)
internal static func _noSuperclassMirror() -> Mirror? { return nil }

@_semantics("optimize.sil.specialize.generic.never")
@inline(never)
@usableFromInline
internal static func _superclassIterator<Subject>(
_ subject: Subject, _ ancestorRepresentation: AncestorRepresentation
) -> () -> Mirror? {
Expand Down Expand Up @@ -218,7 +212,6 @@ public struct Mirror {
/// - ancestorRepresentation: The means of generating the subject's
/// ancestor representation. `ancestorRepresentation` is ignored if
/// `subject` is not a class instance. The default is `.generated`.
@inlinable // FIXME(sil-serialize-all)
public init<Subject, C : Collection>(
_ subject: Subject,
children: C,
Expand Down Expand Up @@ -264,7 +257,6 @@ public struct Mirror {
/// - ancestorRepresentation: The means of generating the subject's
/// ancestor representation. `ancestorRepresentation` is ignored if
/// `subject` is not a class instance. The default is `.generated`.
@inlinable // FIXME(sil-serialize-all)
public init<Subject, C : Collection>(
_ subject: Subject,
unlabeledChildren: C,
Expand Down Expand Up @@ -315,7 +307,6 @@ public struct Mirror {
/// - ancestorRepresentation: The means of generating the subject's
/// ancestor representation. `ancestorRepresentation` is ignored if
/// `subject` is not a class instance. The default is `.generated`.
@inlinable // FIXME(sil-serialize-all)
public init<Subject>(
_ subject: Subject,
children: DictionaryLiteral<String, Any>,
Expand Down Expand Up @@ -348,14 +339,11 @@ public struct Mirror {
public let displayStyle: DisplayStyle?

/// A mirror of the subject's superclass, if one exists.
@inlinable // FIXME(sil-serialize-all)
public var superclassMirror: Mirror? {
return _makeSuperclassMirror()
}

@usableFromInline // FIXME(sil-serialize-all)
internal let _makeSuperclassMirror: () -> Mirror?
@usableFromInline // FIXME(sil-serialize-all)
internal let _defaultDescendantRepresentation: _DefaultDescendantRepresentation
}

Expand Down Expand Up @@ -393,16 +381,11 @@ extension Int : MirrorPath {}
extension String : MirrorPath {}

extension Mirror {
@_fixed_layout // FIXME(sil-serialize-all)
@usableFromInline // FIXME(sil-serialize-all)
internal struct _Dummy : CustomReflectable {
@inlinable // FIXME(sil-serialize-all)
internal init(mirror: Mirror) {
internal init(mirror: Mirror) {
self.mirror = mirror
}
@usableFromInline // FIXME(sil-serialize-all)
internal var mirror: Mirror
@inlinable // FIXME(sil-serialize-all)
internal var customMirror: Mirror { return mirror }
}

Expand Down Expand Up @@ -450,7 +433,6 @@ extension Mirror {
/// - rest: Any remaining mirror path components.
/// - Returns: The descendant of this mirror specified by the given mirror
/// path components if such a descendant exists; otherwise, `nil`.
@inlinable // FIXME(sil-serialize-all)
public func descendant(
_ first: MirrorPath, _ rest: MirrorPath...
) -> Any? {
Expand Down Expand Up @@ -584,7 +566,6 @@ extension PlaygroundQuickLook {
///
/// - Parameter subject: The instance to represent with the resulting Quick
/// Look.
@inlinable // FIXME(sil-serialize-all)
@available(*, deprecated, message: "PlaygroundQuickLook will be removed in a future Swift version.")
public init(reflecting subject: Any) {
if let customized = subject as? CustomPlaygroundQuickLookable {
Expand Down Expand Up @@ -712,7 +693,6 @@ public struct DictionaryLiteral<Key, Value> : ExpressibleByDictionaryLiteral {
///
/// The order of the key-value pairs is kept intact in the resulting
/// `DictionaryLiteral` instance.
@inlinable // FIXME(sil-serialize-all)
public init(dictionaryLiteral elements: (Key, Value)...) {
self._elements = elements
}
Expand Down Expand Up @@ -856,14 +836,12 @@ extension String {

/// Reflection for `Mirror` itself.
extension Mirror : CustomStringConvertible {
@inlinable // FIXME(sil-serialize-all)
public var description: String {
return "Mirror for \(self.subjectType)"
}
}

extension Mirror : CustomReflectable {
@inlinable // FIXME(sil-serialize-all)
public var customMirror: Mirror {
return Mirror(self, children: [:])
}
Expand Down
1 change: 0 additions & 1 deletion stdlib/public/core/Mirrors.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ for self_ty in all_integer_types(word_bits):

extension ${Type[0]} : CustomReflectable {
/// A mirror that reflects the `${Type[0]}` instance.
@inlinable // FIXME(sil-serialize-all)
public var customMirror: Mirror {
return Mirror(self, unlabeledChildren: EmptyCollection<Void>())
}
Expand Down
1 change: 0 additions & 1 deletion stdlib/public/core/ObjectIdentifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public struct ObjectIdentifier {

extension ObjectIdentifier : CustomDebugStringConvertible {
/// A textual representation of the identifier, suitable for debugging.
@inlinable // FIXME(sil-serialize-all)
public var debugDescription: String {
return "ObjectIdentifier(\(_rawPointerToString(_value)))"
}
Expand Down
2 changes: 0 additions & 2 deletions stdlib/public/core/Optional.swift
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ public enum Optional<Wrapped> : ExpressibleByNilLiteral {

extension Optional : CustomDebugStringConvertible {
/// A textual representation of this instance, suitable for debugging.
@inlinable // FIXME(sil-serialize-all)
public var debugDescription: String {
switch self {
case .some(let value):
Expand All @@ -284,7 +283,6 @@ extension Optional : CustomDebugStringConvertible {
}

extension Optional : CustomReflectable {
@inlinable // FIXME(sil-serialize-all)
public var customMirror: Mirror {
switch self {
case .some(let value):
Expand Down
2 changes: 0 additions & 2 deletions stdlib/public/core/Range.swift
Original file line number Diff line number Diff line change
Expand Up @@ -363,15 +363,13 @@ extension Range : CustomStringConvertible {

extension Range : CustomDebugStringConvertible {
/// A textual representation of the range, suitable for debugging.
@inlinable // FIXME(sil-serialize-all)
public var debugDescription: String {
return "Range(\(String(reflecting: lowerBound))"
+ "..<\(String(reflecting: upperBound)))"
}
}

extension Range : CustomReflectable {
@inlinable // FIXME(sil-serialize-all)
public var customMirror: Mirror {
return Mirror(
self, children: ["lowerBound": lowerBound, "upperBound": upperBound])
Expand Down
12 changes: 0 additions & 12 deletions stdlib/public/core/ReflectionMirror.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,14 @@
//
//===----------------------------------------------------------------------===//

@usableFromInline // FIXME(sil-serialize-all)
@_silgen_name("swift_reflectionMirror_normalizedType")
internal func _getNormalizedType<T>(_: T, type: Any.Type) -> Any.Type

@usableFromInline // FIXME(sil-serialize-all)
@_silgen_name("swift_reflectionMirror_count")
internal func _getChildCount<T>(_: T, type: Any.Type) -> Int

@usableFromInline // FIXME(sil-serialize-all)
internal typealias NameFreeFunc = @convention(c) (UnsafePointer<CChar>?) -> Void

@usableFromInline // FIXME(sil-serialize-all)
@_silgen_name("swift_reflectionMirror_subscript")
internal func _getChild<T>(
of: T,
Expand All @@ -32,11 +28,9 @@ internal func _getChild<T>(
) -> Any

// Returns 'c' (class), 'e' (enum), 's' (struct), 't' (tuple), or '\0' (none)
@usableFromInline // FIXME(sil-serialize-all)
@_silgen_name("swift_reflectionMirror_displayStyle")
internal func _getDisplayStyle<T>(_: T) -> CChar

@inlinable // FIXME(sil-serialize-all)
internal func getChild<T>(of value: T, type: Any.Type, index: Int) -> (label: String?, value: Any) {
var nameC: UnsafePointer<CChar>? = nil
var freeFunc: NameFreeFunc? = nil
Expand All @@ -49,20 +43,16 @@ internal func getChild<T>(of value: T, type: Any.Type, index: Int) -> (label: St
}

#if _runtime(_ObjC)
@usableFromInline // FIXME(sil-serialize-all)
@_silgen_name("swift_reflectionMirror_quickLookObject")
internal func _getQuickLookObject<T>(_: T) -> AnyObject?

@usableFromInline // FIXME(sil-serialize-all)
@_silgen_name("_swift_stdlib_NSObject_isKindOfClass")
internal func _isImpl(_ object: AnyObject, kindOf: AnyObject) -> Bool

@inlinable // FIXME(sil-serialize-all)
internal func _is(_ object: AnyObject, kindOf `class`: String) -> Bool {
return _isImpl(object, kindOf: `class` as AnyObject)
}

@inlinable // FIXME(sil-serialize-all)
internal func _getClassPlaygroundQuickLook(
_ object: AnyObject
) -> PlaygroundQuickLook? {
Expand Down Expand Up @@ -112,7 +102,6 @@ internal func _getClassPlaygroundQuickLook(
#endif

extension Mirror {
@inlinable // FIXME(sil-serialize-all)
internal init(internalReflecting subject: Any,
subjectType: Any.Type? = nil,
customAncestor: Mirror? = nil)
Expand Down Expand Up @@ -160,7 +149,6 @@ extension Mirror {
self._defaultDescendantRepresentation = .generated
}

@inlinable // FIXME(sil-serialize-all)
internal static func quickLookObject(_ subject: Any) -> PlaygroundQuickLook? {
#if _runtime(_ObjC)
let object = _getQuickLookObject(subject)
Expand Down
3 changes: 0 additions & 3 deletions stdlib/public/core/Set.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,6 @@ extension Set: CustomStringConvertible, CustomDebugStringConvertible {
}

/// A string that represents the contents of the set, suitable for debugging.
@inlinable // FIXME(sil-serialize-all)
public var debugDescription: String {
return _makeCollectionDescription(for: self, withTypeName: "Set")
}
Expand Down Expand Up @@ -3928,7 +3927,6 @@ public struct SetIterator<Element: Hashable>: IteratorProtocol {

extension SetIterator: CustomReflectable {
/// A mirror that reflects the iterator.
@inlinable // FIXME(sil-serialize-all)
public var customMirror: Mirror {
return Mirror(
self,
Expand All @@ -3938,7 +3936,6 @@ extension SetIterator: CustomReflectable {

extension Set: CustomReflectable {
/// A mirror that reflects the set.
@inlinable // FIXME(sil-serialize-all)
public var customMirror: Mirror {
let style = Mirror.DisplayStyle.`set`
return Mirror(self, unlabeledChildren: self, displayStyle: style)
Expand Down
Loading