Commit Graph

3606 Commits

Author SHA1 Message Date
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
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
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
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
Jordan Rose
e0ddb219d0 [stdlib] Eliminate the last direct use of Builtin.UnknownObject (#11984)
At the Swift level, this is equivalent to AnyObject, which we've done
much more testing of. This commit paves the way for taking UnknownObject
out of the SIL type system and just using it as type metadata. Filed
https://bugs.swift.org/browse/SR-5926 to track that work.
2017-09-25 13:51:22 -07:00
Lance Parker
07b9232235 Correctly handle big endian systems, updated the comment for va_arg usage 2017-09-25 12:38:18 -07:00
Tony Allevato
3618164330 [stdlib] Add _mixForSynthesizedHashValue to stdlib 2017-09-24 08:55:45 -07:00
Lance Parker
5fe76898d5 Make Bool conform to CVarArg protocol 2017-09-22 09:51:52 -07:00
Saleem Abdulrasool
2a7e1be7b3 Merge pull request #11999 from compnerd/windows-tls-cc
stubs: fix Windows x86 TLS callback CC violation
2017-09-21 14:52:50 -07:00
Saleem Abdulrasool
42c98e63d0 stubs: fix Windows x86 TLS callback CC violation
Windows x86 requires that the TLS destructor callback uses the "stdcall"
calling convention.  Provide a shim which will adjust the calling
convention and call back into the swift portion of the code code with
the expected calling convention.
2017-09-21 11:29:56 -07:00
swift-ci
79a3f9c415 Merge pull request #11670 from natecook1000/nc-rev-77-2 2017-09-19 10:15:59 -07:00
Erik Eckstein
ba1a5f9cae Produce more efficient code for the init(rawValue: String) constructor of string enums, part 2.
Use a dictionary for string lookup, which is initialized the first time the constructor is called.
This is more efficient than just iterating of the string table.

Unfortunately it's still not as fast as the original version (where all the string comparisons are inlined into the constructor) for enums with < 100 strings.
But this will improve once we can pass the string and string table as borrowed parameters and we can reduce the ARC overhead.
2017-09-18 17:50:24 -07:00
Erik Eckstein
0bdd91a039 Produce more efficient code for the init(rawValue: String) constructor of string enums.
Instead of inlining a series of string comparisons, we call a library function which does the string lookup on a table of static strings.
This reduces the code size of those initializers dramatically.
Performance wise it's slower than before, because the string comparisons are not inlined anymore.
2017-09-18 17:50:24 -07:00
Roman Levenstein
937352a03b Merge pull request #11910 from swiftix/resilience-performance1
Add experimental support for tracking the invocations of runtime functions
2017-09-18 16:23:00 -07:00
Saleem Abdulrasool
b38ed2f8fc Merge pull request #11949 from compnerd/windows-tls
stdlib: generalise TLS to support Windows
2017-09-18 14:21:13 -07:00
Slava Pestov
df75e536e6 Merge pull request #11969 from slavapestov/versioned-inherited-initializers
Sema: Inherited initializers inherit the @_versioned attribute
2017-09-16 17:17:48 -07:00
Robert Widmann
74f02ad16b Merge pull request #11623 from CodaFi/fundef
[stdlib]Custom message for recursive Strideable witness
2017-09-16 11:02:09 -04:00
Slava Pestov
f3e9aa35a7 Sema: Inherited initializers inherit the @_versioned attribute
Fixes <rdar://problem/34398148>.
2017-09-16 00:23:14 -07:00
Roman Levenstein
045dc34955 Address review comments related to the Swift standard library part of the PR 2017-09-15 15:17:34 -07:00
Saleem Abdulrasool
ba8cbe137c stdlib: generalise TLS to support Windows
Rename the explicit `pthread` to `thread` to indicate that this is not
`pthread` specifically.  This allows us to implement the TLS support for
Windows using Fibers.
2017-09-15 10:56:50 -07:00
Joe Groff
b7566dacdb IRGen: Lowering for key paths with indices. 2017-09-15 10:24:28 -07:00
Robert Widmann
d0bc2a8611 Custom message for recursive Strideable witness
Strideable declares a default witness for Equatable and Comparable

extension Strideable {
  @_inlineable
  public static func < (x: Self, y: Self) -> Bool {
    return x.distance(to: y) > 0
  }

  @_inlineable
  public static func == (x: Self, y: Self) -> Bool {
    return x.distance(to: y) == 0
  }
}

This witness is implemented recursively because the expectation
is that Stride != Self.  However, it is possible to implement
SignedNumeric and Strideable together and inherit this conformance
which will cause undefined behavior - usually a crash.

Provide an overload when Stride == Self and crash with custom message
that mentions that Equatable and Comparable have to be implemented
in this case.

- It's better than nothing.
2017-09-15 12:31:09 -04:00
Roman Levenstein
a4d5cad3a5 Fix creation of UnsafeRawPointer for found references 2017-09-14 19:14:03 -07:00
Roman Levenstein
a590e4902e Add experimental Swift standard library support for tracking the invocations of runtime functions
It allows for collecting the state of runtime function counters, which are used to determine how many times a given runtime function was called.

It is possible to get the global counters, which represent the total number of invocations, or per-object counters, which represent the number of runtime functions calls for a specific object.
2017-09-14 16:43:13 -07:00
Doug Gregor
0793f6c8c5 Revert "[Sequence] Make Sequence.SubSequence conform to Sequence."
This reverts commit 7dc8737c9c.
2017-09-14 09:12:56 -07:00
Arnold Schwaighofer
5326fb73f7 Merge pull request #11877 from aschwaighofer/replace_array_witnesses
Use array copy runtime implementation instead of the array value witnesses
2017-09-13 07:54:13 -07:00
Michael Ilseman
fdb1cab12d Merge pull request #11862 from milseman/message_init_view
[stdlib] Better message for unavailable String.init(_:UTF8Buffer)
2017-09-12 15:48:03 -05:00
Arnold Schwaighofer
8a85a9efd5 Use array copy runtime implementation instead of the array value witnesses
And add builtins for the added runtime functions (assign-take, assign-copy).

rdar://27412867
SR-3376
2017-09-12 12:43:26 -07:00
Nate Cook
4a1b74c266 [stdlib] Additional revisions
- Incorporate feedback from @xwu
- Add parameters for `dump`
- Duplicate some missing integer comments
2017-09-12 11:21:54 -05:00