Commit Graph

3744 Commits

Author SHA1 Message Date
Doug Gregor
5947ae9c00 Merge pull request #12645 from DougGregor/conformance-near-miss
Warn on “near-misses” when defaults are used for protocol witnesses.
2017-10-27 23:01:59 -07:00
Slava Pestov
7f73623532 stdlib: Fix for NSFastEnumerator breakage in resilient builds 2017-10-27 18:55:05 -07:00
Slava Pestov
a07e991093 SILOptimizer: Fix string switch optimization with resilient stdlib
Progress on <rdar://problem/34794790>, but since the build started failing
some other things broke.
2017-10-26 23:58:50 -07:00
Doug Gregor
e423640527 Merge pull request #12638 from glessard/umrbp-tweak
[stdlib] use Collection.isEmpty rather than Collection.count
2017-10-26 21:13:40 -07:00
Doug Gregor
10ae35d070 Minor tweak to the standard library to reduce near-miss false positives. 2017-10-26 17:05:04 -07:00
Guillaume Lessard
99e5570376 use Collection.isEmpty rather than Collection.count 2017-10-26 16:11:35 -06:00
Roman Levenstein
68d7778add Address post-commit review comments on PR #11910
- Use SWIFT_RUNTIME_EXPORT instead of SWIFT_RT_ENTRY_VISIBILITY for exposed functions
- Use `_swift_`  prefixes on the names of exposed functions
- Make the global counters and per-object counters cache thread-safe by using locks
2017-10-24 15:49:37 -07:00
Valentin Pertuisot
4b9d5d54db Improve lowercased comments documentation (#12579)
Differentiate better between a full string character lowercased and a first character only lowercased
2017-10-24 13:11:00 -05:00
Guillaume Lessard
515b455aa1 fix a typo 2017-10-19 04:22:36 -06:00
Greg Parker
72c65ffcaf Revert "[stdlib] Fix FloatingPoint.init(exactly:) (#11311)"
This reverts commit c9f4df84f6.
It is causing test failures on 32-bit iOS simulator and on Linux.
2017-10-18 01:17:08 -07:00
Nate Cook
c9f4df84f6 [stdlib] Fix FloatingPoint.init(exactly:) (#11311)
* [stdlib] Fix FloatingPoint.init(exactly:)

This initializer wasn't actually checking the exact conversion. Corrects
the tests as well.
2017-10-17 13:52:11 -05:00
Ben Cohen
a70e857d59 [stdlib] Fix issue with UTF16 index(_:offsetBy:limitedBy) (#12378)
* Fix issue with empty string ranges

* Add tests for basic offsetBy operation on UTF16View.Index
2017-10-16 13:44:51 -07:00
Max Moiseev
ba019f3dea Use _base._customContainsEquatableElement in LazyFilterX structs 2017-10-12 17:04:52 -07:00
Max Moiseev
dd5ba51a19 [stdlib] Implement _customContainsEquatableElement for LazySequence and LazyXCollection 2017-10-12 16:46:17 -07:00
Max Moiseev
2874662ffb [stdlib] Implement _preprocessingPass and _customContainsEquatableElement for StrideTo and StrideThrough 2017-10-12 16:46:17 -07:00
Max Moiseev
93afb243ca Merge pull request #11917 from natecook1000/nc-uint-advance
[stdlib] Fix strideable methods for large unsigned values
2017-10-11 10:08:29 -07:00
Slava Pestov
124251cf2c Merge pull request #9619 from allevato/synthesize-equatable-hashable
Synthesize Equatable/Hashable for complex enums, structs
2017-10-10 18:22:40 -07:00
Saleem Abdulrasool
03ecfe2867 Merge pull request #12350 from compnerd/calling-conv
stdlib: fix build for non-ObjC targets
2017-10-10 17:25:29 -07:00
Saleem Abdulrasool
5022dbc201 stdlib: fix build for LLP64 targets
When building the stdlib for Windows x86_64, we would see the following error:

  swift/stdlib/public/core/RuntimeFunctionCounters.swift:95:19: error: '(UnsafeRawPointer, Int64) -> Void' is not representable in Objective-C, so it cannot be used with '@convention(c)'
     @convention(c) (_ object: UnsafeRawPointer, _ functionId: Int64) -> Void
                    ^

This is caused by `Int64` not being mapped as on Windows x86_64, `CLong`
is mapped to `Int32` and `CLongLong` is mapped to `Int`.  This causes
the `Int64` to fail to be reverse-mapped to a C type causing the FFI
construction failure.
2017-10-10 12:21:08 -07:00
Nate Cook
37b4083ac7 [stdlib] Try inlining integer stride methods 2017-10-10 13:00:36 -05:00
Tony Allevato
715ba632dd Merge branch 'master' into synthesize-equatable-hashable 2017-10-09 15:57:36 -07:00
Nate Cook
0648aad14f [stdlib] Constrain SubSequence.IndexDistance == IndexDistance 2017-10-09 01:59:44 -05:00
Roman Levenstein
111499d2bf Merge pull request #12256 from swiftix/sil-serialize-all-improvments
Remove the -sil-serialize-all option
2017-10-05 22:03:41 -07:00
Michael Ilseman
94970496ba Merge pull request #12306 from milseman/spooky_bit_masques
[shims] Move bit masks to SwiftShims and include/swift/ABI.
2017-10-05 20:12:19 -07:00
Michael Ilseman
3d04fb5eac [shims] Move bit masks to SwiftShims and include/swift/ABI.
Move bits mask from Metadata.h to SwiftShims's HeapObject.h. This
exposes the bit masks to the stdlib, so that the stdlib doesn't have
to have its own magic numbers per-platform. This also enhances
readability for BridgeObject, whose magic numbers are mostly derived
from Swift's ABI.
2017-10-05 16:31:43 -07:00
Ben Cohen
e3a4ca22d5 [stdlib] Implement slice Indices using their base Indices (#12277)
* Implement slice Indices using their base Indices

* Fix expected type test for Slice
2017-10-05 10:46:04 -07:00
Karoy Lorentey
7dabd3ee1a Merge pull request #12249 from lorentey/rdar/34672149
[stdlib] Dictionary.Keys, .Values: Implement Custom[Debug]StringConvertible
2017-10-05 11:31:14 +01:00
Slava Pestov
c272d41e2f Re-apply "SIL: Remove special meaning for @_semantics("stdlib_binary_only")"
With -sil-serialize-all gone, this no longer means anything; just
don't declare the function as @_inlineable instead.

Fixes <rdar://problem/34564380>.
2017-10-04 14:07:52 -07:00
Jordan Rose
aab5f7aa4f Revert "SIL: Remove special meaning for @_semantics("stdlib_binary_only")" (#12270)
It still affects StdlibUnittest, which is still using -sil-serialize-all.
2017-10-04 12:49:21 -07:00
Karoy Lorentey
4ff5a41061 [stdlib] Dictionary.Keys, .Values: Implement Custom[Debug]StringConvertible.
This prevents a crash while printing these collections.

Resolves:
https://bugs.swift.org/browse/SR-6003
rdar://problem/34672149
2017-10-04 12:40:00 +01:00
Karoy Lorentey
e4ef5203d2 [stdlib] Extract Array._makeDescription into standalone function
This enables its use for collection types unrelated to Arrays.
Use the new function to replace Set’s implementation of
Custom[Debug]StringConvertible.
2017-10-04 12:40:00 +01:00
Slava Pestov
aed8c33a93 Merge pull request #12237 from slavapestov/kill-stdlib-binary-only
SIL: Remove special meaning for @_semantics("stdlib_binary_only")
2017-10-03 15:25:50 -07:00
Ben Cohen
31c1d8d52e Remove no-longer-used _Incrementable protocol (#12251) 2017-10-03 15:08:18 -07:00
Ben Cohen
aacb1edc7d Constrain AnySubSequence variants of Sequence methods (#12029) 2017-10-03 14:17:25 -07:00
Slava Pestov
0fad13eeba SIL: Remove special meaning for @_semantics("stdlib_binary_only")
With -sil-serialize-all gone, this no longer means anything; just
don't declare the function as @_inlineable instead.

Fixes <rdar://problem/34564380>.
2017-10-03 13:48:22 -07:00
swift-ci
2844583d7f Merge pull request #12229 from moiseev/resilience-fix 2017-10-02 16:01:27 -07:00
Max Moiseev
a24998a5b1 [stdlib] Add missing @_fixed_layout attributes to fix resilience build 2017-10-02 15:19:06 -07:00
Arnold Schwaighofer
cc176ef8d9 stdlib: Fix an assert that triggers after uniqueness hoisting
makeUnique hoisting can create a situation where we hit an assert in
_reserveCapacityAssumingUniqueBuffer that the buffer is not unique if we use
_makeMutableAndUniqueOrPinned to replace
_makeUniqueAndReserveCapacityIfNotUnique.

It is actually fine do to the replacement because we will make the buffer unique
_reserveCapacityAssumingUniqueBuffer if the capacity is zero so adjust the
assert accordingly.

do {
  if (someCond) {
    // array.append(...)
    _makeUniqueAndReserveCapacityIfNotUnique(&array)
    _reserveCapacityAssumingUniqueBuffer(&array)
    _appendElementAssumeUniqueAndCapacity(&array, …)
  } else {
   // array[i] = …
   _makeMutableAndUniqueOrPinned(&array)
   addr = _getElementAddress(&array)
   store 1, addr
  }
} while();

to:

_makeMutableAndUniqueOrPinned(&array) // does not replace empty arrays.
do {
  if (someCond) {
    // array.append(...)
    _reserveCapacityAssumingUniqueBuffer(&array) // hit the assert.
    _appendElementAssumeUniqueAndCapacity(&array, …)
  } else {
   // array[i] = …
   addr = _getElementAddress(&array)
   store 1, addr
  }
} while();

Tested by the performance test if we build the stdlib with assertions.

rdar://34149935
2017-10-02 14:23:17 -07:00
Doug Gregor
772352e524 Add requirement StringProtocol.SubSequence : StringProtocol 2017-10-01 15:08:23 -07:00
Doug Gregor
797df6e8d7 Eliminate the _*Indexable protocols.
The various _*Indexable protocols only exist to work around the lack of
recursive protocol constraints. Eliminate all of the *_Indexable protocols,
collapsing their requirements into the corresponding Collection protocol
(e.g., _MutableIndexable —> Collection).

This introduces a number of extraneous requirements into the various
Collection protocols to work around bugs in associated type
inference. Specifically, to work around the lack of "global" inference
of associated type witnesses. These hacks were implicitly present in
the *Indexable protocols; I've made marked them as ABI FIXMEs here so
we can remove them when associated type inference improves.

Fixes rdar://problem/21935030 and a number of ABI FIXMEs in the library.
2017-10-01 15:08:23 -07:00
Doug Gregor
42968b2069 Eliminate a number of uses of the *Indexable protocols. 2017-10-01 15:08:23 -07:00
Doug Gregor
fb253b182a Use a more efficient SubSequence type for lazy map and filter.
Rather than using the default slice type when slicing the collection produced
by a lazy map or filter, slice the base collection and form a new
lazy map/filter collection from it. This allows any optimizations provided by
the collection SubSequence type to kick in, as well as ensuring that slicing
a lazy collection provides the same type as producing a lazy collection of a
slice.

This is technically source-breaking, because someone could have spelled out
the types of slicing a lazy filter or map… but it seems unlikely to matter
in practice and the benefits could be significant.

Fixes ABI FIXME’s #28 and #46.
2017-10-01 15:08:23 -07:00
Doug Gregor
31ad22df45 Make Numeric.Magnitude conform to Numeric 2017-10-01 15:08:22 -07:00
Doug Gregor
9d2c9be04e Remove already-completed or separate-discussed ABI FIXMEs. 2017-10-01 15:08:22 -07:00
Doug Gregor
af48bdc539 Use Collection protocols in IndexingIterator and Default*Indices constraints.
Eliminates a few explicit uses of the Indexable protocols.
2017-10-01 15:08:22 -07:00
Doug Gregor
52eb618abc [Collections] Constrain Indices type to Collection.
Make the Indices types conform to the appropriate Collection protocol:
* Collection.Indices: Collection
* BidirectionalCollection.Indices: BidirectionalCollection
* RandomAccessCollection.Indices: RandomAccessCollection
2017-10-01 15:08:22 -07:00
Doug Gregor
6b51806b54 [SE-0157] Make *Collection.SubSequence conform to corresponding *Collection.
Introduce (recursive) constraints that make the *Collection constraint
of SubSequence match that of its enclosing *Collection, e.g.,
MutableCollection.SubSequence conforms to MutableCollection.

Fixes rdar://problem/20715031 and more of SR-3453.
2017-10-01 15:08:22 -07:00
Doug Gregor
e5f893bc59 [Sequence] Make Sequence.SubSequence conform to Sequence.
Addressed ABI FIXME’s #4, #5, #104 and #105, making Sequence’s
SubSequence conform to Sequence, with the same element type, and for
which the SubSequence of a SubSequence is the same SubSequence.

Fixes SR-318 / rdar://problem/31418206.
2017-10-01 15:08:22 -07:00
Xiaodi Wu
d88836bbf8 [stdlib] Fix strideable methods for large unsigned values
Int is still an insufficient stride type for binary integers,
but this improves the situation for values at the extremes of the
concrete integer types.
2017-09-29 22:58:11 -05:00
Roman Levenstein
a05cd35a7f Merge pull request #11933 from moiseev/inlineable-marked
[stdlib] Make all the stdlib APIs `@_inlineable`
2017-09-29 17:24:59 -07:00