From 914df85887a16ed33c2fc29345f00bea48cc5db2 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Thu, 14 Nov 2019 17:00:48 +0900 Subject: [PATCH 1/4] [katei] Hello, world work Revert stdlib/public/core/OutputStream.swift Revert stdlib/public/core/Mirror.swift Revert stdlib/public/core/ExistentialCollection.swift.gyb partially --- include/swift/Basic/RelativePointer.h | 1 + lib/Demangling/Remangler.cpp | 1 + lib/SIL/TypeLowering.cpp | 17 +- .../core/ExistentialCollection.swift.gyb | 360 +++++++++--------- 4 files changed, 197 insertions(+), 182 deletions(-) diff --git a/include/swift/Basic/RelativePointer.h b/include/swift/Basic/RelativePointer.h index 31cfd2971ece2..687edb82a159a 100644 --- a/include/swift/Basic/RelativePointer.h +++ b/include/swift/Basic/RelativePointer.h @@ -546,6 +546,7 @@ class RelativeDirectPointerIntPair { // The value is addressed relative to `this`. uintptr_t absolute = detail::applyRelativeOffset(this, offset); + printf("[katei in RelativeDirectPointerIntPair.getPointer] After applyRelativeOffset\n", offset); return reinterpret_cast(absolute); } diff --git a/lib/Demangling/Remangler.cpp b/lib/Demangling/Remangler.cpp index ecb972dcc0006..98e2e37453324 100644 --- a/lib/Demangling/Remangler.cpp +++ b/lib/Demangling/Remangler.cpp @@ -2433,6 +2433,7 @@ void Remangler::mangleAccessorFunctionReference(Node *node) { /// The top-level interface to the remangler. std::string Demangle::mangleNode(NodePointer node) { + puts("[katei in decodeMangledType] Before mangleNode\n"); return mangleNode(node, [](SymbolicReferenceKind, const void *) -> NodePointer { unreachable("should not try to mangle a symbolic reference; " "resolve it to a non-symbolic demangling tree instead"); diff --git a/lib/SIL/TypeLowering.cpp b/lib/SIL/TypeLowering.cpp index f124d37c7c4bc..5e6aad126de0a 100644 --- a/lib/SIL/TypeLowering.cpp +++ b/lib/SIL/TypeLowering.cpp @@ -2644,12 +2644,25 @@ TypeConverter::checkFunctionForABIDifferences(SILModule &M, return ABIDifference::NeedsThunk; } + // There is no ABI compatibility between non-throws and throws on WebAssembly, + // so need thunk. + if (M.getASTContext().LangOpts.Target.isOSBinFormatWasm()) { + if (!fnTy1->hasErrorResult() && fnTy2->hasErrorResult()) { + return ABIDifference::NeedsThunk; + } + } + auto rep1 = fnTy1->getRepresentation(), rep2 = fnTy2->getRepresentation(); if (rep1 != rep2) { if (rep1 == SILFunctionTypeRepresentation::Thin && - rep2 == SILFunctionTypeRepresentation::Thick) + rep2 == SILFunctionTypeRepresentation::Thick) { + // There is no ABI compatibility between thin and think on WebAssembly, + // so need thunk. + if (M.getASTContext().LangOpts.Target.isOSBinFormatWasm()) { + return ABIDifference::NeedsThunk; + } return ABIDifference::ThinToThick; - + } return ABIDifference::NeedsThunk; } diff --git a/stdlib/public/core/ExistentialCollection.swift.gyb b/stdlib/public/core/ExistentialCollection.swift.gyb index 5376d98040390..77ff0f96bf2a7 100644 --- a/stdlib/public/core/ExistentialCollection.swift.gyb +++ b/stdlib/public/core/ExistentialCollection.swift.gyb @@ -25,7 +25,7 @@ from gyb_stdlib_support import ( import SwiftShims @inline(never) -@usableFromInline + internal func _abstract( file: StaticString = #file, line: UInt = #line @@ -41,9 +41,9 @@ internal func _abstract( /// This iterator forwards its `next()` method to an arbitrary underlying /// iterator having the same `Element` type, hiding the specifics of the /// underlying `IteratorProtocol`. -@frozen + public struct AnyIterator { - @usableFromInline + internal let _box: _AnyIteratorBoxBase /// Creates an iterator that wraps a base iterator but whose type depends @@ -67,7 +67,7 @@ public struct AnyIterator { /// } /// /// - Parameter base: An iterator to type-erase. - @inlinable + public init(_ base: I) where I.Element == Element { self._box = _IteratorBox(base) } @@ -88,12 +88,12 @@ public struct AnyIterator { /// - Parameter body: A closure that returns an optional element. `body` is /// executed each time the `next()` method is called on the resulting /// iterator. - @inlinable + public init(_ body: @escaping () -> Element?) { self._box = _IteratorBox(_ClosureBasedIterator(body)) } - @inlinable + internal init(_box: _AnyIteratorBoxBase) { self._box = _box } @@ -104,7 +104,7 @@ extension AnyIterator: IteratorProtocol { /// exists. /// /// Once `nil` has been returned, all subsequent calls return `nil`. - @inlinable + public func next() -> Element? { return _box.next() } @@ -114,26 +114,26 @@ extension AnyIterator: IteratorProtocol { /// traversing the sequence consumes the iterator. extension AnyIterator: Sequence { } -@usableFromInline -@frozen + + internal struct _ClosureBasedIterator: IteratorProtocol { - @inlinable + internal init(_ body: @escaping () -> Element?) { self._body = body } - @inlinable + internal func next() -> Element? { return _body() } - @usableFromInline + internal let _body: () -> Element? } -@_fixed_layout -@usableFromInline + + internal class _AnyIteratorBoxBase: IteratorProtocol { - @inlinable // FIXME(sil-serialize-all) + // FIXME(sil-serialize-all) internal init() {} - @inlinable // FIXME(sil-serialize-all) + // FIXME(sil-serialize-all) deinit {} /// Advances to the next element and returns it, or `nil` if no next element /// exists. @@ -141,22 +141,22 @@ internal class _AnyIteratorBoxBase: IteratorProtocol { /// Once `nil` has been returned, all subsequent calls return `nil`. /// /// - Note: Subclasses must override this method. - @inlinable // FIXME(sil-serialize-all) + // FIXME(sil-serialize-all) internal func next() -> Element? { _abstract() } } -@_fixed_layout -@usableFromInline + + internal final class _IteratorBox< Base: IteratorProtocol >: _AnyIteratorBoxBase { - @inlinable + internal init(_ base: Base) { self._base = base } - @inlinable // FIXME(sil-serialize-all) + // FIXME(sil-serialize-all) deinit {} - @inlinable + internal override func next() -> Base.Element? { return _base.next() } - @usableFromInline + internal var _base: Base } @@ -165,8 +165,8 @@ internal final class _IteratorBox< % for Kind in ['Sequence', 'Collection', 'BidirectionalCollection', 'RandomAccessCollection']: -@_fixed_layout -@usableFromInline + + % if Kind == 'Sequence': internal class _AnySequenceBox % elif Kind == 'Collection': @@ -183,49 +183,49 @@ internal class _AnyRandomAccessCollectionBox { % if Kind == 'Sequence': - @inlinable // FIXME(sil-serialize-all) + // FIXME(sil-serialize-all) internal init() { } - @inlinable + internal func _makeIterator() -> AnyIterator { _abstract() } - @inlinable + internal var _underestimatedCount: Int { _abstract() } - @inlinable + internal func _map( _ transform: (Element) throws -> T ) rethrows -> [T] { _abstract() } - @inlinable + internal func _filter( _ isIncluded: (Element) throws -> Bool ) rethrows -> [Element] { _abstract() } - @inlinable + internal func _forEach( _ body: (Element) throws -> Void ) rethrows { _abstract() } - @inlinable + internal func __customContainsEquatableElement( _ element: Element ) -> Bool? { _abstract() } - @inlinable + internal func __copyToContiguousArray() -> ContiguousArray { _abstract() } - @inlinable + internal func __copyContents(initializing buf: UnsafeMutableBufferPointer) -> (AnyIterator,UnsafeMutableBufferPointer.Index) { _abstract() @@ -234,117 +234,117 @@ internal class _AnyRandomAccessCollectionBox % end % # This deinit has to be present on all the types - @inlinable // FIXME(sil-serialize-all) + // FIXME(sil-serialize-all) deinit {} % if Kind == 'Sequence': - @inlinable + internal func _drop( while predicate: (Element) throws -> Bool ) rethrows -> _AnySequenceBox { _abstract() } - @inlinable + internal func _dropFirst(_ n: Int) -> _AnySequenceBox { _abstract() } - @inlinable + internal func _dropLast(_ n: Int) -> [Element] { _abstract() } - @inlinable + internal func _prefix(_ maxLength: Int) -> _AnySequenceBox { _abstract() } - @inlinable + internal func _prefix( while predicate: (Element) throws -> Bool ) rethrows -> [Element] { _abstract() } - @inlinable + internal func _suffix(_ maxLength: Int) -> [Element] { _abstract() } % else: % override = 'override' if Kind != 'Collection' else '' - @inlinable + internal override func _drop( while predicate: (Element) throws -> Bool ) rethrows -> _Any${Kind}Box { _abstract() } - @inlinable + internal override func _dropFirst(_ n: Int) -> _Any${Kind}Box { _abstract() } - @inlinable + internal ${override} func _dropLast(_ n: Int) -> _Any${Kind}Box { _abstract() } - @inlinable + internal override func _prefix(_ maxLength: Int) -> _Any${Kind}Box { _abstract() } - @inlinable + internal ${override} func _prefix( while predicate: (Element) throws -> Bool ) rethrows -> _Any${Kind}Box { _abstract() } - @inlinable + internal ${override} func _suffix(_ maxLength: Int) -> _Any${Kind}Box { _abstract() } % end % if Kind == 'Collection': - @inlinable + internal subscript(i: _AnyIndexBox) -> Element { _abstract() } - @inlinable + internal func _index(after i: _AnyIndexBox) -> _AnyIndexBox { _abstract() } - @inlinable + internal func _formIndex(after i: _AnyIndexBox) { _abstract() } - @inlinable + internal func _index( _ i: _AnyIndexBox, offsetBy n: Int ) -> _AnyIndexBox { _abstract() } - @inlinable + internal func _index( _ i: _AnyIndexBox, offsetBy n: Int, limitedBy limit: _AnyIndexBox ) -> _AnyIndexBox? { _abstract() } - @inlinable + internal func _formIndex(_ i: inout _AnyIndexBox, offsetBy n: Int) { _abstract() } - @inlinable + internal func _formIndex( _ i: inout _AnyIndexBox, offsetBy n: Int, limitedBy limit: _AnyIndexBox ) -> Bool { _abstract() } - @inlinable + internal func _distance( from start: _AnyIndexBox, to end: _AnyIndexBox ) -> Int { @@ -364,7 +364,7 @@ internal class _AnyRandomAccessCollectionBox var isEmpty: Bool { get } */ - @inlinable // FIXME(sil-serialize-all) + // FIXME(sil-serialize-all) internal var _count: Int { _abstract() } // TODO: swift-3-indexing-model: forward the following methods. @@ -373,7 +373,7 @@ internal class _AnyRandomAccessCollectionBox func _customLastIndexOfEquatableElement(element: Element) -> Index?? */ - @inlinable + internal init( _startIndex: _AnyIndexBox, endIndex: _AnyIndexBox @@ -382,16 +382,16 @@ internal class _AnyRandomAccessCollectionBox self._endIndex = endIndex } - @usableFromInline + internal let _startIndex: _AnyIndexBox - @usableFromInline + internal let _endIndex: _AnyIndexBox % end % if Kind in ['Collection', 'BidirectionalCollection', 'RandomAccessCollection']: % override = 'override' if Kind != 'Collection' else '' - @inlinable + internal ${override} subscript( start start: _AnyIndexBox, end end: _AnyIndexBox @@ -399,9 +399,9 @@ internal class _AnyRandomAccessCollectionBox % end % if Kind == 'BidirectionalCollection': - @inlinable + internal func _index(before i: _AnyIndexBox) -> _AnyIndexBox { _abstract() } - @inlinable + internal func _formIndex(before i: _AnyIndexBox) { _abstract() } % end } @@ -423,132 +423,132 @@ internal class _AnyRandomAccessCollectionBox -@_fixed_layout -@usableFromInline + + internal final class _${Kind}Box: _Any${Kind}Box { - @usableFromInline + internal typealias Element = S.Element - @inline(__always) - @inlinable + + internal override func _makeIterator() -> AnyIterator { return AnyIterator(_base.makeIterator()) } - @inlinable + internal override var _underestimatedCount: Int { return _base.underestimatedCount } - @inlinable + internal override func _map( _ transform: (Element) throws -> T ) rethrows -> [T] { return try _base.map(transform) } - @inlinable + internal override func _filter( _ isIncluded: (Element) throws -> Bool ) rethrows -> [Element] { return try _base.filter(isIncluded) } - @inlinable + internal override func _forEach( _ body: (Element) throws -> Void ) rethrows { return try _base.forEach(body) } - @inlinable + internal override func __customContainsEquatableElement( _ element: Element ) -> Bool? { return _base._customContainsEquatableElement(element) } - @inlinable + internal override func __copyToContiguousArray() -> ContiguousArray { return _base._copyToContiguousArray() } - @inlinable + internal override func __copyContents(initializing buf: UnsafeMutableBufferPointer) -> (AnyIterator,UnsafeMutableBufferPointer.Index) { let (it,idx) = _base._copyContents(initializing: buf) return (AnyIterator(it),idx) } % if Kind == 'Sequence': - @inlinable + internal override func _dropFirst(_ n: Int) -> _AnySequenceBox { return _SequenceBox>(_base: _base.dropFirst(n)) } - @inlinable + internal override func _drop( while predicate: (Element) throws -> Bool ) rethrows -> _Any${Kind}Box { return try _SequenceBox>(_base: _base.drop(while: predicate)) } - @inlinable + internal override func _dropLast(_ n: Int) -> [Element] { return _base.dropLast(n) } - @inlinable + internal override func _prefix(_ n: Int) -> _AnySequenceBox { return _SequenceBox>(_base: _base.prefix(n)) } - @inlinable + internal override func _prefix( while predicate: (Element) throws -> Bool ) rethrows -> [Element] { return try _base.prefix(while: predicate) } - @inlinable + internal override func _suffix(_ maxLength: Int) -> [Element] { return _base.suffix(maxLength) } % else: - @inline(__always) - @inlinable + + internal override func _drop( while predicate: (Element) throws -> Bool ) rethrows -> _Any${Kind}Box { return try _${Kind}Box(_base: _base.drop(while: predicate)) } - @inline(__always) - @inlinable + + internal override func _dropFirst(_ n: Int) -> _Any${Kind}Box { return _${Kind}Box(_base: _base.dropFirst(n)) } - @inline(__always) - @inlinable + + internal override func _dropLast(_ n: Int) -> _Any${Kind}Box { return _${Kind}Box(_base: _base.dropLast(n)) } - @inline(__always) - @inlinable + + internal override func _prefix( while predicate: (Element) throws -> Bool ) rethrows -> _Any${Kind}Box { return try _${Kind}Box(_base: _base.prefix(while: predicate)) } - @inline(__always) - @inlinable + + internal override func _prefix(_ maxLength: Int) -> _Any${Kind}Box { return _${Kind}Box(_base: _base.prefix(maxLength)) } - @inline(__always) - @inlinable + + internal override func _suffix(_ maxLength: Int) -> _Any${Kind}Box { return _${Kind}Box(_base: _base.suffix(maxLength)) } % end - @inlinable // FIXME(sil-serialize-all) + // FIXME(sil-serialize-all) deinit {} % if Kind == 'Sequence': - @inlinable + internal init(_base: S) { self._base = _base } % else: - @inlinable + internal init(_base: S) { self._base = _base super.init( @@ -556,7 +556,7 @@ internal final class _${Kind}Box: _Any${Kind}Box endIndex: _IndexBox(_base: _base.endIndex)) } - @inlinable + internal func _unbox( _ position: _AnyIndexBox, file: StaticString = #file, line: UInt = #line ) -> S.Index { @@ -566,12 +566,12 @@ internal final class _${Kind}Box: _Any${Kind}Box fatalError("Index type mismatch!", file: file, line: line) } - @inlinable + internal override subscript(position: _AnyIndexBox) -> Element { return _base[_unbox(position)] } - @inlinable + internal override subscript(start start: _AnyIndexBox, end end: _AnyIndexBox) -> _Any${Kind}Box { @@ -580,12 +580,12 @@ internal final class _${Kind}Box: _Any${Kind}Box ) } - @inlinable + internal override func _index(after position: _AnyIndexBox) -> _AnyIndexBox { return _IndexBox(_base: _base.index(after: _unbox(position))) } - @inlinable + internal override func _formIndex(after position: _AnyIndexBox) { if let p = position as? _IndexBox { return _base.formIndex(after: &p._base) @@ -593,14 +593,14 @@ internal final class _${Kind}Box: _Any${Kind}Box fatalError("Index type mismatch!") } - @inlinable + internal override func _index( _ i: _AnyIndexBox, offsetBy n: Int ) -> _AnyIndexBox { return _IndexBox(_base: _base.index(_unbox(i), offsetBy: numericCast(n))) } - @inlinable + internal override func _index( _ i: _AnyIndexBox, offsetBy n: Int, @@ -613,7 +613,7 @@ internal final class _${Kind}Box: _Any${Kind}Box .map { _IndexBox(_base: $0) } } - @inlinable + internal override func _formIndex( _ i: inout _AnyIndexBox, offsetBy n: Int ) { @@ -623,7 +623,7 @@ internal final class _${Kind}Box: _Any${Kind}Box fatalError("Index type mismatch!") } - @inlinable + internal override func _formIndex( _ i: inout _AnyIndexBox, offsetBy n: Int, limitedBy limit: _AnyIndexBox ) -> Bool { @@ -636,7 +636,7 @@ internal final class _${Kind}Box: _Any${Kind}Box fatalError("Index type mismatch!") } - @inlinable + internal override func _distance( from start: _AnyIndexBox, to end: _AnyIndexBox @@ -644,18 +644,18 @@ internal final class _${Kind}Box: _Any${Kind}Box return numericCast(_base.distance(from: _unbox(start), to: _unbox(end))) } - @inlinable + internal override var _count: Int { return numericCast(_base.count) } % if Kind in ['BidirectionalCollection', 'RandomAccessCollection']: - @inlinable + internal override func _index(before position: _AnyIndexBox) -> _AnyIndexBox { return _IndexBox(_base: _base.index(before: _unbox(position))) } - @inlinable + internal override func _formIndex(before position: _AnyIndexBox) { if let p = position as? _IndexBox { return _base.formIndex(before: &p._base) @@ -666,25 +666,25 @@ internal final class _${Kind}Box: _Any${Kind}Box % end % end - @usableFromInline + internal var _base: S } % end -@usableFromInline -@frozen + + internal struct _ClosureBasedSequence { - @usableFromInline + internal var _makeUnderlyingIterator: () -> Iterator - @inlinable + internal init(_ makeUnderlyingIterator: @escaping () -> Iterator) { self._makeUnderlyingIterator = makeUnderlyingIterator } } extension _ClosureBasedSequence: Sequence { - @inlinable + internal func makeIterator() -> Iterator { return _makeUnderlyingIterator() } @@ -695,21 +695,21 @@ extension _ClosureBasedSequence: Sequence { /// An instance of `AnySequence` forwards its operations to an underlying base /// sequence having the same `Element` type, hiding the specifics of the /// underlying sequence. -@frozen + public struct AnySequence { - @usableFromInline + internal let _box: _AnySequenceBox /// Creates a sequence whose `makeIterator()` method forwards to /// `makeUnderlyingIterator`. - @inlinable + public init( _ makeUnderlyingIterator: @escaping () -> I ) where I.Element == Element { self.init(_ClosureBasedSequence(makeUnderlyingIterator)) } - @inlinable + internal init(_box: _AnySequenceBox) { self._box = _box } @@ -719,7 +719,7 @@ extension AnySequence: Sequence { public typealias Iterator = AnyIterator /// Creates a new sequence that wraps and forwards operations to `base`. - @inlinable + public init(_ base: S) where S.Element == Element { @@ -731,104 +731,104 @@ extension AnySequence: Sequence { extension Any${Kind} { % if Kind == 'Sequence': /// Returns an iterator over the elements of this sequence. - @inline(__always) - @inlinable + + public __consuming func makeIterator() -> Iterator { return _box._makeIterator() } - @inlinable + public __consuming func dropLast(_ n: Int = 1) -> [Element] { return _box._dropLast(n) } - @inlinable + public __consuming func prefix( while predicate: (Element) throws -> Bool ) rethrows -> [Element] { return try _box._prefix(while: predicate) } - @inlinable + public __consuming func suffix(_ maxLength: Int) -> [Element] { return _box._suffix(maxLength) } % else: /// Returns an iterator over the elements of this collection. - @inline(__always) - @inlinable + + public __consuming func makeIterator() -> Iterator { return _box._makeIterator() } - @inlinable + public __consuming func dropLast(_ n: Int = 1) -> Any${Kind} { return Any${Kind}(_box: _box._dropLast(n)) } - @inlinable + public __consuming func prefix( while predicate: (Element) throws -> Bool ) rethrows -> Any${Kind} { return try Any${Kind}(_box: _box._prefix(while: predicate)) } - @inlinable + public __consuming func suffix(_ maxLength: Int) -> Any${Kind} { return Any${Kind}(_box: _box._suffix(maxLength)) } % end - @inlinable + public var underestimatedCount: Int { return _box._underestimatedCount } - @inlinable + public func map( _ transform: (Element) throws -> T ) rethrows -> [T] { return try _box._map(transform) } - @inlinable + public __consuming func filter( _ isIncluded: (Element) throws -> Bool ) rethrows -> [Element] { return try _box._filter(isIncluded) } - @inlinable + public __consuming func forEach( _ body: (Element) throws -> Void ) rethrows { return try _box._forEach(body) } - @inlinable + public __consuming func drop( while predicate: (Element) throws -> Bool ) rethrows -> Any${Kind} { return try Any${Kind}(_box: _box._drop(while: predicate)) } - @inlinable + public __consuming func dropFirst(_ n: Int = 1) -> Any${Kind} { return Any${Kind}(_box: _box._dropFirst(n)) } - @inlinable + public __consuming func prefix(_ maxLength: Int = 1) -> Any${Kind} { return Any${Kind}(_box: _box._prefix(maxLength)) } - @inlinable + public func _customContainsEquatableElement( _ element: Element ) -> Bool? { return _box.__customContainsEquatableElement(element) } - @inlinable + public __consuming func _copyToContiguousArray() -> ContiguousArray { return self._box.__copyToContiguousArray() } - @inlinable + public __consuming func _copyContents(initializing buf: UnsafeMutableBufferPointer) -> (AnyIterator,UnsafeMutableBufferPointer.Index) { let (it,idx) = _box.__copyContents(initializing: buf) @@ -840,7 +840,7 @@ extension Any${Kind} { //===--- Index ------------------------------------------------------------===// //===----------------------------------------------------------------------===// -@usableFromInline + internal protocol _AnyIndexBox: class { var _typeID: ObjectIdentifier { get } @@ -851,61 +851,61 @@ internal protocol _AnyIndexBox: class { func _isLess(than rhs: _AnyIndexBox) -> Bool } -@_fixed_layout -@usableFromInline + + internal final class _IndexBox: _AnyIndexBox { - @usableFromInline + internal var _base: BaseIndex - @inlinable + internal init(_base: BaseIndex) { self._base = _base } - @inlinable + internal func _unsafeUnbox(_ other: _AnyIndexBox) -> BaseIndex { return unsafeDowncast(other, to: _IndexBox.self)._base } - @inlinable + internal var _typeID: ObjectIdentifier { return ObjectIdentifier(type(of: self)) } - @inlinable + internal func _unbox() -> T? { return (self as _AnyIndexBox as? _IndexBox)?._base } - @inlinable + internal func _isEqual(to rhs: _AnyIndexBox) -> Bool { return _base == _unsafeUnbox(rhs) } - @inlinable + internal func _isLess(than rhs: _AnyIndexBox) -> Bool { return _base < _unsafeUnbox(rhs) } } /// A wrapper over an underlying index that hides the specific underlying type. -@frozen + public struct AnyIndex { - @usableFromInline + internal var _box: _AnyIndexBox /// Creates a new index wrapping `base`. - @inlinable + public init(_ base: BaseIndex) { self._box = _IndexBox(_base: base) } - @inlinable + internal init(_box: _AnyIndexBox) { self._box = _box } - @inlinable + internal var _typeID: ObjectIdentifier { return _box._typeID } @@ -920,7 +920,7 @@ extension AnyIndex: Comparable { /// - Parameters: /// - lhs: An index to compare. /// - rhs: Another index to compare. - @inlinable + public static func == (lhs: AnyIndex, rhs: AnyIndex) -> Bool { _precondition(lhs._typeID == rhs._typeID, "Base index types differ") return lhs._box._isEqual(to: rhs._box) @@ -934,7 +934,7 @@ extension AnyIndex: Comparable { /// - Parameters: /// - lhs: An index to compare. /// - rhs: Another index to compare. - @inlinable + public static func < (lhs: AnyIndex, rhs: AnyIndex) -> Bool { _precondition(lhs._typeID == rhs._typeID, "Base index types differ") return lhs._box._isLess(than: rhs._box) @@ -960,12 +960,12 @@ protocol _AnyCollectionProtocol: Collection { /// An `${Self}` instance forwards its operations to a base collection having the /// same `Element` type, hiding the specifics of the underlying /// collection. -@frozen + public struct ${Self} { - @usableFromInline + internal let _box: _${Self}Box - @inlinable + internal init(_box: _${Self}Box) { self._box = _box } @@ -984,8 +984,8 @@ extension ${Self}: ${SelfProtocol} { /// - Parameter base: The collection to wrap. /// /// - Complexity: O(1). - @inline(__always) - @inlinable + + public init(_ base: C) where C.Element == Element { // Traversal: ${Traversal} // SubTraversal: ${SubTraversal} @@ -996,7 +996,7 @@ extension ${Self}: ${SelfProtocol} { /// Creates an `${Self}` having the same underlying collection as `other`. /// /// - Complexity: O(1) - @inlinable + public init(_ other: Any${SubProtocol}) { self._box = other._box } @@ -1009,7 +1009,7 @@ extension ${Self}: ${SelfProtocol} { /// `${SelfProtocol}`, the result is `nil`. /// /// - Complexity: O(1) - @inlinable + public init?(_ other: Any${collectionForTraversal(SuperTraversal)}) { guard let box = other._box as? _${Self}Box else { @@ -1022,7 +1022,7 @@ extension ${Self}: ${SelfProtocol} { /// The position of the first element in a non-empty collection. /// /// In an empty collection, `startIndex == endIndex`. - @inlinable + public var startIndex: Index { return AnyIndex(_box: _box._startIndex) } @@ -1032,7 +1032,7 @@ extension ${Self}: ${SelfProtocol} { /// /// `endIndex` is always reachable from `startIndex` by zero or more /// applications of `index(after:)`. - @inlinable + public var endIndex: Index { return AnyIndex(_box: _box._endIndex) } @@ -1041,37 +1041,37 @@ extension ${Self}: ${SelfProtocol} { /// /// - Precondition: `position` indicates a valid position in `self` and /// `position != endIndex`. - @inlinable + public subscript(position: Index) -> Element { return _box[position._box] } - @inlinable + public subscript(bounds: Range) -> SubSequence { return ${Self}(_box: _box[start: bounds.lowerBound._box, end: bounds.upperBound._box]) } - @inlinable + public func _failEarlyRangeCheck(_ index: Index, bounds: Range) { // Do nothing. Doing a range check would involve unboxing indices, // performing dynamic dispatch etc. This seems to be too costly for a fast // range check for QoI purposes. } - @inlinable + public func _failEarlyRangeCheck(_ range: Range, bounds: Range) { // Do nothing. Doing a range check would involve unboxing indices, // performing dynamic dispatch etc. This seems to be too costly for a fast // range check for QoI purposes. } - @inlinable + public func index(after i: Index) -> Index { return AnyIndex(_box: _box._index(after: i._box)) } - @inlinable + public func formIndex(after i: inout Index) { if _isUnique(&i._box) { _box._formIndex(after: i._box) @@ -1081,12 +1081,12 @@ extension ${Self}: ${SelfProtocol} { } } - @inlinable + public func index(_ i: Index, offsetBy n: Int) -> Index { return AnyIndex(_box: _box._index(i._box, offsetBy: n)) } - @inlinable + public func index( _ i: Index, offsetBy n: Int, limitedBy limit: Index ) -> Index? { @@ -1094,7 +1094,7 @@ extension ${Self}: ${SelfProtocol} { .map { AnyIndex(_box:$0) } } - @inlinable + public func formIndex(_ i: inout Index, offsetBy n: Int) { if _isUnique(&i._box) { return _box._formIndex(&i._box, offsetBy: n) @@ -1103,7 +1103,7 @@ extension ${Self}: ${SelfProtocol} { } } - @inlinable + public func formIndex( _ i: inout Index, offsetBy n: Int, @@ -1120,7 +1120,7 @@ extension ${Self}: ${SelfProtocol} { return false } - @inlinable + public func distance(from start: Index, to end: Index) -> Int { return _box._distance(from: start._box, to: end._box) } @@ -1134,18 +1134,18 @@ extension ${Self}: ${SelfProtocol} { /// % end /// - Complexity: ${'O(1)' if Traversal == 'RandomAccess' else 'O(*n*)'} - @inlinable + public var count: Int { return _box._count } % if Traversal == 'Bidirectional' or Traversal == 'RandomAccess': - @inlinable + public func index(before i: Index) -> Index { return AnyIndex(_box: _box._index(before: i._box)) } - @inlinable + public func formIndex(before i: inout Index) { if _isUnique(&i._box) { _box._formIndex(before: i._box) @@ -1159,7 +1159,7 @@ extension ${Self}: ${SelfProtocol} { extension ${Self}: _AnyCollectionProtocol { /// Uniquely identifies the stored underlying collection. - @inlinable + public // Due to language limitations only var _boxID: ObjectIdentifier { return ObjectIdentifier(_box) From e45ee9dca825a65ae6a65a6002ff51bdedcb5f6e Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Sun, 17 Nov 2019 08:51:11 +0900 Subject: [PATCH 2/4] Revert include/swift/Basic/RelativePointer.h --- include/swift/Basic/RelativePointer.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/swift/Basic/RelativePointer.h b/include/swift/Basic/RelativePointer.h index 687edb82a159a..31cfd2971ece2 100644 --- a/include/swift/Basic/RelativePointer.h +++ b/include/swift/Basic/RelativePointer.h @@ -546,7 +546,6 @@ class RelativeDirectPointerIntPair { // The value is addressed relative to `this`. uintptr_t absolute = detail::applyRelativeOffset(this, offset); - printf("[katei in RelativeDirectPointerIntPair.getPointer] After applyRelativeOffset\n", offset); return reinterpret_cast(absolute); } From bb14449e4dbf105785ea741d31ad08eab6004802 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Sun, 17 Nov 2019 08:57:18 +0900 Subject: [PATCH 3/4] Revert lib/Demangling/Remangler.cpp and include/swift/Basic/RelativePointer.h --- lib/Demangling/Remangler.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Demangling/Remangler.cpp b/lib/Demangling/Remangler.cpp index 98e2e37453324..ecb972dcc0006 100644 --- a/lib/Demangling/Remangler.cpp +++ b/lib/Demangling/Remangler.cpp @@ -2433,7 +2433,6 @@ void Remangler::mangleAccessorFunctionReference(Node *node) { /// The top-level interface to the remangler. std::string Demangle::mangleNode(NodePointer node) { - puts("[katei in decodeMangledType] Before mangleNode\n"); return mangleNode(node, [](SymbolicReferenceKind, const void *) -> NodePointer { unreachable("should not try to mangle a symbolic reference; " "resolve it to a non-symbolic demangling tree instead"); From 11ab3b9b96db8c435e64d6b88887c3a65642f87e Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Sun, 17 Nov 2019 08:58:30 +0900 Subject: [PATCH 4/4] Revert lib/Demangling/Remangler.cpp --- include/swift/Basic/RelativePointer.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/swift/Basic/RelativePointer.h b/include/swift/Basic/RelativePointer.h index 31cfd2971ece2..687edb82a159a 100644 --- a/include/swift/Basic/RelativePointer.h +++ b/include/swift/Basic/RelativePointer.h @@ -546,6 +546,7 @@ class RelativeDirectPointerIntPair { // The value is addressed relative to `this`. uintptr_t absolute = detail::applyRelativeOffset(this, offset); + printf("[katei in RelativeDirectPointerIntPair.getPointer] After applyRelativeOffset\n", offset); return reinterpret_cast(absolute); }