Commit Graph

8969 Commits

Author SHA1 Message Date
Saleem Abdulrasool
48dbd0d26c Merge pull request #12172 from compnerd/absptr-ntd
IRGen: switch to absolute pointers for nomimal type descriptors
2017-10-03 17:06:48 -07: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
Saleem Abdulrasool
086c12114d IRGen: switch to absolute pointers for nominal type descriptors
Alter the value metadata layout to use an absolute pointer for the
nominal type descriptor rather than a relative offset relative to the
complete type metadata.  Although this is slightly less efficient in
terms of load times, this is more portable across different
environments.  For example, PE/COFF does not provide a cross-section
relative offset relocation.  Other platform ports are unable to provide
a 64-bit relative offset encoding.

Given that the value witness table reference in the value metadata is
currently an absolute pointer, this page is most likely going to be
dirtied by the loader.
2017-10-03 14:45:45 -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
Roman Levenstein
0918780f61 Merge pull request #12191 from swiftix/sil-serialize-all-improvments
Stop using -sil-serialize-all when building the standard library
2017-10-02 19:46:45 -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
Roman Levenstein
9134153bd3 Stop using -sil-serialize-all when building the standard library
We can finally get rid of -sil-serialize-all when building the standard library! This option will be completely eliminated in the future commits.

Instead of serializing just everything as we did before, we now serialize only functions annotated with @_inlineable. This way we can selectively control what needs to be available to the clients. This is an important step towards building a resilient standard library.

While this is a huge change for the serialization of the stdlib, it should be virtually invisible to the clients. For example, there are no noticeable performance regressions on any of the benchmarks.
2017-10-02 14:34:14 -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
44572644d3 [Unit test library] Remove redundant constraints. 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
swift-ci
caffda1b58 Merge pull request #12188 from moiseev/floating-modulo-message 2017-09-29 13:19:03 -07:00
Max Moiseev
6ea3644568 [stdlib] Clarify an availability message for % on floating point types
<rdar://problem/27855641>
2017-09-29 12:18:15 -07:00
Max Moiseev
67005f4047 Add inlineable init/deinits to 🐟able 2017-09-29 11:26:56 -07:00
Max Moiseev
794a4072b5 Proper placing of inits/deinits in ExistentialCollections 2017-09-29 11:26:56 -07:00
Max Moiseev
4108884a11 Fix new compilation errors 2017-09-29 11:26:56 -07:00
Max Moiseev
568dfc75f6 More missing _inlineable's and deinit's 2017-09-29 11:26:56 -07:00
Maxim Moiseev
98b875a6e5 Fix compilation errors 2017-09-29 11:26:56 -07:00
Max Moiseev
ef6b5c4795 Add missing @_inlineable attributes and deinits 2017-09-29 11:26:56 -07:00
Max Moiseev
b30b937ed3 Revert making some enums public
The compiler problem was fixed: rdar://problem/34342955
2017-09-29 11:26:56 -07:00
Max Moiseev
29346cc52b Address watchOS build failures 2017-09-29 11:26:56 -07:00
Max Moiseev
53b8419279 [stdlib] Make all the stdlib APIs @_inlineable
This change in theory should allow us to remove a special stdlib-only
sil-serialize-all compilation mode.

<rdar://problem/34138683>
2017-09-29 11:26:56 -07:00
Ross Bayer
fc9dcc09a9 Added in missing imports to Accelerate and CoreFoundation overlays. (#12167) 2017-09-28 15:45:52 -07:00
Saleem Abdulrasool
f8cb62da36 Merge pull request #12159 from compnerd/va_list-switch
stdlib: swap conditional to make it easier to read (NFC)
2017-09-28 15:28:44 -07:00
Saleem Abdulrasool
1ce5c17337 stdlib: swap conditional to make it easier to read (NFC)
This changes the conditional for the definition of the _VaListBuilder.
This makes it easier to read as well as to extend to other platforms
which use a non-pointer va_list type.  NFC.
2017-09-28 09:34:39 -07:00
swift-ci
920e42f51f Merge pull request #12151 from moiseev/ns-substring 2017-09-27 22:58:27 -07:00
Max Moiseev
7322b63c44 [overlay] Fix Foundation extensions to Substring
When a substring gets bridged to NSString, it loses the initial offset,
therefore APIs that accept or return StringIndex ranges should handle
this case explicitly by adding/subtracting the substring start offset.

Fixes <rdar://problem/33873277>
2017-09-27 20:09:01 -07:00
Saleem Abdulrasool
62c9a3dd54 Merge pull request #12134 from compnerd/windows-icu
stubs: fix Windows link
2017-09-27 18:59:58 -07:00
Karoy Lorentey
cce185e257 Merge pull request #12129 from lorentey/retainCount
[stdlib] Implement -retainCount in _SwiftNativeNS*Base
2017-09-26 18:32:04 -07:00
Saleem Abdulrasool
05edabff5e stubs: fix Windows link
There is no icucore.lib in the official ICU distribution for Windows.
Remove the autolink directive for now.
2017-09-26 16:13:47 -07:00
Saleem Abdulrasool
13213efe6a stubs: fix architecture check for Windows
Fix a typo in the architecture check.  The missing `I` in the x86 check
prevented the x86 build from succeeding.
2017-09-26 16:11:34 -07:00
Karoy Lorentey
ed5b202c8f [stdlib] Implement -retainCount in _SwiftNativeNS*Base
Fixes rdar://problem/28002554.
2017-09-26 14:32:20 -07:00
Slava Pestov
a1ccab8a8d Merge pull request #12052 from slavapestov/remove-parent-field-from-type-metadata
Remove parent field from type metadata
2017-09-25 17:14:49 -07:00
Lance Parker
0787a4ec48 Merge pull request #12061 from lancep/CVarArgBoolConformance
[stdlib] Bool should conform to the CVarArg protocol
2017-09-25 16:06:37 -07:00
Slava Pestov
55cd329cb3 Reflection: Remove logic for the parent metadata source 2017-09-25 15:45:17 -07:00
Slava Pestov
3ab5b6fa19 IRGen/Runtime: Remove parent field from type metadata
We no longer need this for anything, so remove it from metadata
altogether. This simplifies logic for emitting type metadata and
makes type metadata smaller.

We still pass the parent metadata pointer to type constructors;
removing that is a separate change.
2017-09-25 15:45:17 -07:00
Slava Pestov
9bdb71b614 Runtime: Stop looking at parent type metadata in _buildDemanglingForNominalType()
Wean the routine that builds a mangling tree from metadata from
looking at the parent metadata pointer, instead using the nested
depth to partition the arguments into a list of arguments for
each nesting depth.
2017-09-25 15:45:16 -07:00