Commit Graph

315 Commits

Author SHA1 Message Date
Maxim Moiseev
938094cdd6 [stdlib] Fix the abi checker test for both assert and no-assert builds
A few internal functions were defined within the #if
INTERNAL_CHECKS_ENABLED block, which made the results different between
stdlib configurations with assertions enabled and without. Since these
fucntions are internal and are not @inlinable, it is OK to have them
unconditionally.

<rdar://problem/45880586>
2018-11-07 15:59:30 -08:00
Maxim Moiseev
e107fab25b [stdlib] Internalize _Buffer32 and _Buffer72 2018-11-07 11:25:31 -08:00
Karoy Lorentey
825ac93f17 [test] Describe ABI changes 2018-11-07 14:11:31 +00:00
Nate Cook
e5c1567957 [stdlib] Switch to a stable sort algorithm (#19717)
This switches the standard library's sort algorithm from an in-place
introsort to use a modified timsort, a stable, adaptive sort that
merges runs using a temporary buffer. This implementation performs
straight merges instead of adopting timsort's galloping strategy.

In addition to maintaining the relative order of equal/non-comparable
elements, this algorithm outperforms the introsort on data with any
intrinsic structure, such as runs of ascending or descending elements
or a significant number of equality collisions.
2018-11-07 00:05:04 -06:00
Maxim Moiseev
ca51626fd3 [stdlib] Move _stdlib_AtomicInt and friends out of the stdlib 2018-11-06 09:53:58 -08:00
Maxim Moiseev
90106444d3 [stdlib] Remove a bunch of unused functions from Runtime.swift.gyb
<rdar://problem/45746339>
2018-11-05 15:03:19 -08:00
Michael Ilseman
d112e5f20f [test] Dump in new API and ABI reference point
Put in the new API/ABI from UTF-8 String.
2018-11-04 10:42:44 -08:00
Brent Royal-Gordon
9bd1a26089 Implementation for SE-0228: Fix ExpressibleByStringInterpolation (#20214)
* [CodeCompletion] Restrict ancestor search to brace

This change allows ExprParentFinder to restrict certain searches for parents to just AST nodes within the nearest surrounding BraceStmt. In the string interpolation rework, BraceStmts can appear in new places in the AST; this keeps code completion from looking at irrelevant context.

NFC in this commit, but keeps code completion from crashing once TapExpr is introduced.

* Remove test relying on ExpressibleByStringInterpolation being deprecated

Since soon enough, it won’t be anymore.

* [AST] Introduce TapExpr

TapExpr allows a block of code to to be inserted between two expressions, accessing and potentially mutating the result of its subexpression before giving it to its parent expression. It’s roughly equivalent to this function:

  func _tap<T>(_ value: T, do body: (inout T) throws -> Void) rethrows -> T {
    var copy = value
    try body(&copy)
    return copy
  }

Except that it doesn’t use a closure, so no variables are captured and no call frame is (even notionally) added.

This commit does not include tests because nothing in it actually uses TapExpr yet. It will be used by string interpolation.

* SE-0228: Fix ExpressibleByStringInterpolation

This is the bulk of the implementation of the string interpolation rework. It includes a redesigned AST node, new parsing logic, new constraints and post-typechecking code generation, and new standard library types and members.

* [Sema] Rip out typeCheckExpressionShallow()

With new string interpolation in place, it is no longer used by anything in the compiler.

* [Sema] Diagnose invalid StringInterpolationProtocols

StringInterpolationProtocol informally requires conforming types to provide at least one method with the base name “appendInterpolation” with no (or a discardable) return value and visibility at least as broad as the conforming type’s. This change diagnoses an error when a conforming type does not have a method that meets those criteria.

* [Stdlib] Fix map(String.init) source break

Some users, including some in the source compatibility suite, accidentally used init(stringInterpolationSegment:) by writing code like `map(String.init)`. Now that these intializers have been removed, the remaining initializers often end up tying during overload resolution. This change adds several overloads of `String.init(describing:)` which will break these ties in cases where the compiler previously selected `String.init(stringInterpolationSegment:)`.

* [Sema] Make callWitness() take non-mutable arrays

It doesn’t actually need to mutate them.

* [Stdlib] Improve floating-point interpolation performance

This change avoids constructing a String when interpolating a Float, Double, or Float80. Instead, we write the characters to a fixed-size buffer and then append them directly to the string’s storage.

This seems to improve performance for all three types, but especially for Double and Float80, which cannot always fit into a small string when stringified.

* [NameLookup] Improve MemberLookupTable invalidation

In rare cases usually involving generated code, an overload added by an extension in the middle of a file would not be visible below it if the type had lazy members and the same base name had already been referenced above the extension. This change essentially dirties a type’s member lookup table whenever an extension is added to it, ensuring the entries in it will be updated.

This change also includes some debugging improvements for NameLookup.

* [SILOptimizer] XFAIL dead object removal failure

The DeadObjectRemoval pass in SILOptimizer does not currently remove reworked string interpolations as well as the old design because their effects cannot be described by @_effects(readonly). That causes a test failure on Linux. This change temporarily silences that test. The SILOptimizer issue has been filed as SR-9008.

* Confess string interpolation’s source stability sins

* [Parser] Parse empty interpolations

Previously, the parser had an odd asymmetry which caused the same function to accept foo(), but reject “\()”. This change fixes the issue.

Already tested by test/Parse/try.swift, which uses this construct in one of its throwing interpolation tests.

* [Sema] Fix batch-mode-only lazy var bug

The temporary variable used by string interpolation needs to be recontextualized when it’s inserted into a synthesized getter. Fixes a compilation failure in Alamofire.

I’ll probably follow up on this bug a bit more after merging.
2018-11-02 19:16:03 -07:00
Ben Cohen
dbc2e21522 Remove customization points from Sequence and Collection (#19995) 2018-10-31 18:58:00 -07:00
Karoy Lorentey
3ae170c1c1 [stdlib] Remove SipHash from ABI-visible names
Also, eliminate the (unused) SipHash24 implementation and nest most of Hasher’s internals under Hasher itself.
2018-11-01 00:45:40 +00:00
Karoy Lorentey
68b9b08cdd [stdlib] Add 256 bits of extra state to Hasher 2018-11-01 00:43:53 +00:00
Karoy Lorentey
80ebdfc17c [test] Update expected ABI changes 2018-10-31 12:19:52 +00:00
Ben Cohen
4381735269 Switch Zip2Sequence.init to be internal (#20148) 2018-10-30 18:08:06 -07:00
Ben Cohen
e8e169c11f Add removed methods to expected ABI breakage 2018-10-29 08:00:20 -07:00
Karoy Lorentey
21b75609b6 [test] Confess ABI changes 2018-10-27 01:12:26 +01:00
Karoy Lorentey
3aae412839 [test] Confess ABI changes 2018-10-27 00:17:56 +01:00
Karoy Lorentey
1195fcf0e0 [test] Update tests for _HeapBuffer changes 2018-10-26 23:53:34 +01:00
Karoy Lorentey
79b755c73c [test] Confess ABI changes 2018-10-26 21:49:39 +01:00
Xi Ge
49c16922dd swift-module-digester: diagnose type witness type changes when checking ABI stability. 2018-10-25 16:40:23 -07:00
Xi Ge
334c46aabd swift-module-digester: update API/ABI baselines after recent format changes. 2018-10-25 15:14:53 -07:00
Xi Ge
fcc4bf5be2 swift-module-digester: don't blindly include initializer decls. rdar://45418572 2018-10-25 15:14:17 -07:00
Xi Ge
da4fc05a0e swift-module-digester: model ProcotolConformance as a standalone node.
Modeling ProtocolConformance as a standalone node allows us to keep
track of all type witnesses and re-use existing matching algorithm
to diagnose type witness changes.
2018-10-25 15:14:17 -07:00
Ben Cohen
116dac1925 [stdlib] Uninline float description (#20038)
* Uninline float description

* Uninline _floatNNToString
2018-10-25 14:20:24 -07:00
Ben Cohen
f625f466c4 [stdlib] Simplify internal DropFirst/PrefixSequence types (#19970)
* Simplify internal DropFirstSequence type

* Simplify internal PrefixSequence type
2018-10-22 07:53:05 -07:00
Slava Pestov
4ef1904e88 AST: Don't allow declarations to shadow generic parameters
Associated type inference can synthesize type aliases with the same name
as a generic parameter. This is all fine since the underlying type of
the alias is the generic parameter type, however it might have been
synthesized in a constrained extension, resulting in bogus diagnostics
that depend on the order in which declarations are type checked, which
can vary between WMO and non-WMO, different batch mode settings, etc.

Instead, let's just check the generic parameter list first.

Fixes <rdar://problem/22587551>, <rdar://problem/44777661>.
2018-10-15 19:24:27 -07:00
Slava Pestov
ba066b8257 swift-api-digester: Don't drop value ownership when parameter has typealias type 2018-10-15 19:24:27 -07:00
Xi Ge
7177f4191b test: regenerate ABI/API stability baselines after recent fixes. 2018-10-08 14:05:17 -07:00
Xi Ge
c8c7fb39b0 swift-module-digester: exclude fixed binary order when checking API stability. 2018-10-08 13:59:30 -07:00
Xi Ge
847aa9b327 swift-module-digester: avoid including private protocol conformances when checking API stability. 2018-10-08 13:30:30 -07:00
Xi Ge
382e27f4ab swift-module-digester: diagnose adding/removing final as ABI/API breakages. 2018-10-08 13:19:54 -07:00
Xi Ge
bfadd46d57 swift-module-digester: diagnose non-final function changes in non-resilient classes. 2018-10-08 12:15:55 -07:00
Xi Ge
9ed3894667 Merge remote-tracking branch 'apple/master' into include-non-resilient-class 2018-10-08 10:51:26 -07:00
Karoy Lorentey
4967393618 Merge pull request #19688 from lorentey/hashed-bridgeobject
[stdlib] Set, Dictionary: Replace _Variant enums with _BridgeStorage
2018-10-08 12:07:40 +01:00
Xi Ge
c5550ce2f8 test: regenerate abi stability baseline after recent fixes. 2018-10-05 14:48:56 -07:00
Xi Ge
8a769a0460 swift-module-digester: include non-resilient class decls when checking ABI stability. 2018-10-05 14:48:00 -07:00
Jordan Rose
30d15682d5 Merge pull request #19522 from jrose-apple/lined-pockets
Remove unwanted exceptions from @inlinable checking
2018-10-05 14:28:21 -07:00
Xi Ge
9cfc0dee79 swift-module-digester: keep track of whether a property/subscript has didSet and willSet. 2018-10-05 13:02:31 -07:00
Jordan Rose
df1ef05c4c Remove unwanted exceptions from @inlinable checking
- Treat protocol requirements just like associated types in how they
  inherit usable-from-inline-ness, rather than special-casing them in
  the check for inlinable code.

- Enum elements are already treated this way, so we can remove a
  redundant check for that.

- Finally, start enforcing that 'dynamic' declarations need to be
  '@usableFromInline' to be used in inlinable functions...in Swift 5
  mode or resilient code. I didn't even add a warning in Swift 4/4.2
  because it was illegal to use '@usableFromInline' on a 'dynamic'
  declaration in Swift 4.2. (Oops.)
2018-10-05 12:21:01 -07:00
Karoy Lorentey
c47b922421 [test] Confess Set/Dictionary ABI changes 2018-10-05 14:07:10 +01:00
Xi Ge
a1e66a0515 swift-module-digester: diagnose value ownership changes for parameters. 2018-10-04 18:02:45 -07:00
Xi Ge
2d59078a0d [test] Regenerate ABI/API checker baseline by using stdlib without assertion enabled.
If we use a baseline generated from assertion build, the checker will report false-positives
when running in a non-assertion build since some decls only exist in the former.

resolves: rdar://45014723
2018-10-04 15:57:56 -07:00
Xi Ge
5bab518d5f swift-module-digester: include parameters' value ownership values in the digests. 2018-10-04 15:57:56 -07:00
Xi Ge
78271f19a0 swift-module-digester: diagnose self access kind changes for function decls. 2018-10-04 15:57:56 -07:00
Xi Ge
b7c9e5798a [test] regenerated ABI checker baseline to include decls with @usableFromInline. 2018-10-03 14:56:24 -07:00
Xi Ge
58b3c2173f swift-module-digester: use getEffectiveAccess() to get accessibility when checking ABI stability.
This allows us to include internal decls with @usableFromInline attribute, whose stored property
changes can effect ABI.
2018-10-03 14:06:53 -07:00
Ben Cohen
6cc6f4f182 Underscore @usableFromInlinable symbols (#19686) 2018-10-03 12:01:28 -07:00
Xi Ge
c2c04875d0 swift-module-digester: diagnose operator *fix notation changes. 2018-10-02 15:04:23 -07:00
Xi Ge
9364415eab swift-module-digester: use "stored property" instead of "fixed layout order" in diagnostics. 2018-10-02 11:15:20 -07:00
Xi Ge
784cb9e1a9 Revert "swift-module-digester: diagnose added associated types as ABI breakages even they have default type." 2018-10-02 11:12:37 -07:00
Xi Ge
a969486932 swift-module-digester: diagnose added associated types as ABI breakages even they have default type. 2018-10-01 16:00:36 -07:00