Commit Graph

8969 Commits

Author SHA1 Message Date
Ben Cohen
c4f0b5fe94 [stdlib] Adopt conditional conformance for Indices, Slice, ReversedCollection (#12913)
* Refactor Indices and Slice to use conditional conformance

* Replace ReversedRandomAccessCollection with a conditional extension

* Refactor some types into struct+extensions

* Revise Slice documentation

* Fix test cases for adoption of conditional conformances.

* [RangeReplaceableCollection] Eliminate unnecessary slicing subscript operator.

* Add -enable-experimental-conditional-conformances to test.

* Gruesome workaround for crasher in MutableSlice tests
2017-11-30 09:10:22 -08:00
Saleem Abdulrasool
df54b2af11 reflection: handle LMA != VMA for ELF
ELF is segment mapped, where the segment which contains a particular
section may be mapped to an address which does not correspond to the
address on disk.  Since the reflection dumper does not use the loader to
load the image into memory, we must manually account for any section
offsets.  Calculate this value when we query the mmap'ed image and wire
it through to the relative direct pointer accesses.

When switching to the linker table approach for the ELF metadata
introspection, this was uncovered as the segment containing the orphaned
sections was coalesced into a separate PT_LOAD header which had a non-0
offset for the mapping.
2017-11-29 17:56:15 -08:00
Christian Bieniak
ec0d53f96f [stdlib] [SR-4005] Allow heterogenous comparisons in elementsEqual (#8045)
* [SR-4005] Allow heterogenous comparisons in elementsEqual

When a user is supplying a predicate to compare the type equivalence
isn’t required

* elementsEqualWithPredicate tests

Compares a string of a number with an integer value by using the
elementsEqualPredicate closure

* Update test expectations to use new sequence element types

* Update hardcoded test to reference sequence
2017-11-29 17:06:38 -08:00
Max Moiseev
66f8a9bbe0 Merge pull request #13007 from xwu/fused-multiply-add-stride
[stdlib] Eliminate intermediate rounding error in floating-point strides (and related gardening)
2017-11-29 11:35:14 -08:00
swift-ci
cdab55a202 Merge pull request #13124 from DougGregor/se-0143-experimental-flag 2017-11-28 16:59:27 -08:00
Doug Gregor
b59c30c1af [SE-0143] Put conditional conformances behind an "experimental" flag.
Conditional conformances aren't quite ready yet for Swift 4.1, so
introduce the flag `-enable-experimental-conditional-conformances` to
enable conditional conformaces, and an error when one declares a
conditional conformance without specifying the flag.

Add this flag when building the standard library (which will vend
conditional conformances) and to all of the tests that need it.

Fixes rdar://problem/35728337.
2017-11-28 16:01:51 -08:00
Hamish
4b3f0374c8 [stdlib] Don't check for native when known native in ensureNativeBuffer() 2017-11-28 19:34:01 +00:00
Nate Cook
04518afde3 [stdlib] Add conditional Hashable conformance for indices 2017-11-28 13:29:55 -06:00
Nate Cook
6c66cf3e61 [stdlib] Make stdlib index types Hashable
This adds Hashable conformance for the String, Dictionary,
and Set's index types.
2017-11-28 13:29:55 -06:00
Saleem Abdulrasool
0c42b57962 ELF: restructure image metadata registration
Restructure the ELF handling to be completely agnostic to the OS.
Rather than usng the loader to query the section information, use the
linker to construct linker tables and synthetic markers for the
beginning and of the table.  Save off the values of these pointers and
pass them along through the constructor to the runtime for registration.

This removes the need for the begin/end objects.  Remove the special
construction of the begin/end objects through the special assembly
constructs, preferring to do this in C with a bit of inline assembly to
ensure that the section is always allocated.

Remove the special handling for the various targets, the empty object
file can be linked on all the targets.

The new object file has no requirements on the ordering.  It needs to
simply be injected into the link.

Name the replacement file `swiftrt.o` mirroring `crt.o` from libc.  Merge
the constructor and the definition into a single object file.

This approach is generally more portable, overall simpler to implement,
and more robust.

Thanks to Orlando Bassotto for help analyzing some of the odd behaviours
when switching over.
2017-11-28 10:04:04 -08:00
Doug Gregor
208b2c180c [XCTest overlay] Remove extraneous XCAssert(Not)Equal overloads.
XCTest had XCAssert(Not)Equal overloads for optionals, arrays
(including contiguous arrays and array slices), and dictionaries to
work around the lack of conditional conformances to Equatable. Now
that we have the latter, remove the former.

Fixes rdar://problem/17924430.
2017-11-27 21:09:50 -08:00
Huon Wilson
39e0a951b8 [stdlib] Make Optional, Array and Dictionary conditionally Equatable. 2017-11-27 21:09:49 -08:00
Max Moiseev
3730115af2 Merge pull request #13062 from natecook1000/nc-dw-string
[stdlib] Improve large integer support
2017-11-27 16:09:24 -08:00
Guillaume Lessard
4427a66da8 [gardening] fix an inconsistency
This doc-comment's two paragraphs said in the first that the memory must be uninitialized before assignment, while in the second that it cannot be uninitialized.
2017-11-27 10:09:08 -07:00
Xiaodi Wu
2a5b0d4a61 Disable conditional conformance of Stride{To|Through} 2017-11-25 12:49:59 -06:00
Xiaodi Wu
06ef6736d5 Add conditional conformance for Stride{To|Through} 2017-11-25 12:31:54 -06:00
David Zarzycki
6a93b07cfb NFC: Use standardized locale header
On Linux, glibc removed xlocale.h, which was non-standard.
2017-11-25 13:09:06 -05:00
Xiaodi Wu
94e3677033 Remove uninhabitable _DisabledRangeIndex_ type 2017-11-25 11:52:08 -06:00
Xiaodi Wu
c53dc66de8 Simplify Strideable._step 2017-11-25 11:50:00 -06:00
Xiaodi Wu
d3fe5ac264 Support fused multiply-add and remove buggy Collection conformance in floating-point strides 2017-11-25 11:44:18 -06:00
Nate Cook
abb75bca1a Allow large integer literals for DoubleWidth 2017-11-24 22:48:35 -06:00
Nate Cook
390d4464ad Support larger integers in String(_:radix:) 2017-11-24 22:16:30 -06:00
Pavel Yaskevich
090acade11 [stdlib] Remove iterator type workaround from ClosedRange
After changes to stdlib and type-checker related to removing
of the `_Strideable` it's now possible to properly support
iterator types for *ClosedRange without any workarounds.

Resolves: rdar://problem/25584401
2017-11-23 18:51:35 -08:00
Jonathan Hagberg
81bf571989 Removes superfluous 'the' in documentation 2017-11-21 18:22:11 -08:00
Hamish
12416f94bb [stdlib] Don't use autoclosure on pointerToValue(forKey:insertingDefault:) methods
Previously we used @autoclosure on the _VariantDictionaryBuffer methods and forwarded closures directly.
However, this relied on an unintentional type-checker inconsistency, tracked by SR-5719.
2017-11-21 17:51:00 +00:00
Philip Ridgeway
6926fd3412 Removes a superfluous "the" in a documentation comment. 2017-11-20 11:04:04 -08:00
Hamish
76ea3a2ca4 [stdlib] Fix uniqueness check in nativePointerToValue(forKey:insertingDefault:)
The reasoning for this change is detailed in PR-13000.
2017-11-19 22:37:05 +00:00
Hamish
79d8209ffa [stdlib] Use addressor for Dictionary's subscript(_:default:) 2017-11-19 15:45:27 +00:00
swift-ci
53ddcb5079 Merge pull request #13000 from gottesmm/pr-6a0399e1ebd7ccad1979a2af165d0b09595fb2cb 2017-11-18 20:55:27 -08:00
Michael Gottesman
89cefe0a70 [stdlib] Use a different access pattern to check uniqueness to work around more conservative SILGen codegen.
Using && here causes us to go down a SILGen path that guarantees that self will
be evaluated over the entire && expression instead of just the LHS. This cause
the uniqueness check to always return false at -Onone. At -O, the optimizer is
smart enough to remove this issue.

rdar://33358110
2017-11-18 20:16:28 -07:00
taylor swift
c85880899d implement SE 184: add allocation methods to Unsafe buffer pointers, drop all parameters from deallocation, adjust namings, and add repeated-value assignment methods 2017-11-17 21:28:03 -08:00
Doug Gregor
9f1cd0bf6b [Stdlib] Move _OptionalNilComparisonType operators into an extension on Optional.
Because global operators are “meh”.
2017-11-17 20:41:43 -08:00
Huon Wilson
48baa3f472 [stdlib] Move Array and Optional == and != into static methods. 2017-11-17 16:09:20 -08:00
Joe Groff
925d6f61d3 Merge pull request #12796 from linux-on-ibm-z/master_s390x_KeyPath
fixed test case KeyPath.swift for s390x
2017-11-17 09:35:01 -08:00
eeckstein
73fc4b221b Merge pull request #12976 from eeckstein/remove-semantic
Remove @_semantics("optimize.sil.never")
2017-11-17 07:54:31 -08:00
Greg Parker
78501448b1 [runtime] Remove _swift_getSuperclass(). (#12988)
There are too many superclass-lookup functions.
This one does not pull its own weight.
2017-11-17 02:57:58 -08:00
Pavel Yaskevich
57ccdf7423 Merge pull request #12520 from xedin/remove-strideable
[stdlib] changes to remove `_Strideable` protocol.
2017-11-16 19:06:40 -08:00
Tony Parker
7b20be2c1c Merge pull request #12779 from parkera/parkera/json_key_strategy
Add key encoding strategy to JSONEncoder
2017-11-16 15:48:32 -08:00
Erik Eckstein
76f281510f Remove @_semantics("optimize.sil.never")
The replacement is @_optimize(none)
2017-11-16 14:11:52 -08:00
Pavel Yaskevich
98c6a7e127 [stdlib] Add + overload to LazyMapCollectionProtocol in Swift 3 mode
This overload is needed to re-enable Swift 3 source compatibility
related to a bugfix in ranking behavior of the constraint solver.
2017-11-16 13:38:24 -08:00
Pavel Yaskevich
b5584e0b1f [stdlib] Add contains(_ element:) Countable{Closed}Range
Solution ranking always prefers methods declared on concerete type
vs. in protocol extension, which means in order to to disambiguite
expressions like `(0 ..< 42).contains(7)` we need to have `contains(_:)`
method on both `Range` and `CountableRange` declared explicitly, that
ensures that `CountableRange` is prefered since `Strideable` inherits
from `Comparable` which makes it "more specialized".
2017-11-16 13:38:24 -08:00
Ben Cohen
35452c2e62 [stdlib] Remove _Strideable protocol 2017-11-16 13:38:24 -08:00
Greg Parker
1e894cd80b [runtime] Clean up symbols in error machinery. (#12853)
* [runtime] Clean up symbols in error machinery.

* [runtime] Clean up symbols in Foundation overlay.

* [runtime] Clean up symbols in collections and hashing.

* [runtime] Remove symbol controls from the Linux definition of swift_allocError.

* [tests] Add more stub functions for tests that link directly to the runtime.
2017-11-15 22:20:11 -08:00
Tony Parker
b87a8ea007 Add key encoding strategy to JSONEncoder 2017-11-15 16:44:28 -08:00
Greg Parker
e8475cc130 Revert "Use conditional conformances to implement Equatable for Optional, Array and Dictionary" 2017-11-15 14:17:22 -08:00
Tony Parker
b57a9cb8a9 Merge pull request #12898 from sashabelonogov/sashabelonogov/SR-6361
[SR-6361] Fix Data.withUnsafeMutableBytes() for slices with length < range.lowerBound
2017-11-15 11:26:49 -08:00
Stephen Canon
c7f1df4da6 Fix the value of Float80.pi (#12881)
Currently this is implemented as Float80(literal), which gets interpreted as Float80(Double(literal)), unfortunately. Switch to the correct spelling: literal as Float80.

Resolves rdar://problem/35459284
2017-11-15 09:32:20 -08:00
David Zarzycki
5015ee1107 Merge pull request #12895 from davezarzycki/cmake_localize_hack2
[CMake] Localize a build hack
2017-11-15 10:49:52 -05:00
Doug Gregor
e9b7336d44 [Stdlib] Move _OptionalNilComparisonType operators into an extension on Optional.
Because global operators are “meh”.
2017-11-14 16:23:20 -08:00
Huon Wilson
8524379352 [stdlib] Make Optional, Array and Dictionary conditionally Equatable. 2017-11-14 16:23:20 -08:00