Commit Graph

12522 Commits

Author SHA1 Message Date
John McCall
724c192120 Propagate the XI count into the get/store XI tag callbacks.
This allows callers to avoid needing to reload these tags in common cases.
2018-12-11 22:18:44 -05:00
John McCall
2ba7090fe8 Remove the extra-inhabitant value witness functions.
This is essentially a long-belated follow-up to Arnold's #12606.
The key observation here is that the enum-tag-single-payload witnesses
are strictly more powerful than the XI witnesses: you can simulate
the XI witnesses by using an extra case count that's <= the XI count.
Of course the result is less efficient than the XI witnesses, but
that's less important than overall code size, and we can work on
fast-paths for that.

The extra inhabitant count is stored in a 32-bit field (always present)
following the ValueWitnessFlags, which now occupy a fixed 32 bits.
This inflates non-XI VWTs on 32-bit targets by a word, but the net effect
on XI VWTs is to shrink them by two words, which is likely to be the
more important change.  Also, being able to access the XI count directly
should be a nice win.
2018-12-11 22:18:44 -05:00
Michael Gottesman
b2ae3a8b2c [cmake] Move add_swift_target_executable into the new stdlib cmake directory.
This will ensure that additional target executables can not be added to the rest
of the swift project without anyone noticing since the non-stdlib parts of
Swift's cmake will not have visibility of the declaration unless they change the
cmake lookup paths.
2018-12-11 16:43:49 -08:00
Michael Gottesman
191a71e10d Merge pull request #21159 from gottesmm/pr-ba57cf951f8ebe4518b4b183429a5559480dc7bb
[cmake] tools/swift-reflection-test => stdlib/tools/swift-reflection-…
2018-12-11 16:33:54 -08:00
Philippe Hausler
d030354320 Initial draft of DataProtocol ContiguousCollection and new inline Data 2018-12-11 11:19:36 -08:00
Joe Groff
e30c86769a KeyPath: Allow existing context descriptors to be used as generic environment.
If a key path literal appears in a generic context with an existing context descriptor, this will allow us to
save some code size by not having to emit a separate GenericEnvironment descriptor.
2018-12-11 09:05:47 -08:00
Joe Groff
cfb46788c7 Merge pull request #21201 from jckarter/foundation-typeByName-no-symbolic-references
stdlib: Make _typeByName Foundation SPI reject symbolic references.
2018-12-11 07:31:04 -08:00
Karoy Lorentey
ef392c1277 Merge pull request #21056 from lorentey/error-hashing
[Foundation] Update hashing for bridged NSError protocols
2018-12-11 13:17:00 +00:00
Joe Groff
85eb634191 stdlib: Make _typeByName Foundation SPI reject symbolic references.
It's used for recovering type metadata from deserialized mangled names, which should never have symbolic
references in them.
2018-12-10 20:22:03 -08:00
Joe Groff
1f5f6dbb6d Merge pull request #21186 from jckarter/public-getTypeByMangledName
Runtime: Make getTypeByMangledNameIn(Context|Environment) a public entry point.
2018-12-10 18:58:53 -08:00
Michael Ilseman
6a18fb8d83 Merge pull request #21178 from milseman/string_storage_view
[String] UTF8View implements withContiguousStorageIfAvailable
2018-12-10 15:57:15 -08:00
Mike Ash
a39ee29f0e Merge pull request #21127 from mikeash/rename-anykeypath-and-valistbuilder
[Stdlib] Rename AnyKeyPath's ObjC name and _VaListBuilder to avoid conflicts with older stdlibs.
2018-12-10 18:11:23 -05:00
Joe Groff
021053d499 Runtime: Make getTypeByMangledNameIn(Context|Environment) a public entry point.
This can be used by compiler-generated code as a size optimization for metadata access, using a
mangled name instead of possibly many open-coded metadata calls. It can also allow reflection
libraries outside of the standard library to turn type reference strings into in-process metadata
pointers in a robust way. rdar://problem/46451849
2018-12-10 14:22:41 -08:00
Jordan Rose
c66a445ef7 [stdlib] Make some more *Pointer operations _transparent (#21126)
Not only was this affecting performance when building from parseable
interfaces, but we'd also want these to be inlined for any sort of
bounds-checking diagnostics / static analysis we might get in the
future.
2018-12-10 13:37:15 -08:00
Nate Cook
2bb0b5c842 Revise some documentation comments. 2018-12-10 14:31:28 -06:00
Stephen Canon
95d76cd195 Minor improvements to CGFloat (#21090)
* Minor improvements to CGFloat

Apparently init(exactly:) was never implemented for CGFloat, so let's fix that. Also includes minor cleanup for the .magnitude property.

* Add transparent annotations to some other CGFloat things.
2018-12-10 15:31:23 -05:00
Michael Ilseman
1d9032991b [String] UTF8View implements withContiguousStorageIfAvailable 2018-12-10 11:01:28 -08:00
Valeriy Van
0e5d18654e Fixes comment for binaryString example snippet in FixedWidthInteger 2018-12-10 17:12:31 +01:00
Mike Ash
6b9480252e [Stdlib] Change AnyKeyPath to use @_objcRuntimeName attribute for its rename.
rdar://problem/46546165
2018-12-10 10:35:37 -05:00
Mike Ash
a49e2ddde7 [Stdlib] Rename AnyKeyPath's ObjC name and _VaListBuilder to avoid conflicts with older stdlibs.
rdar://problem/46546165
2018-12-10 10:17:52 -05:00
Karoy Lorentey
23188afec1 [Foundation] CocoaError.Code, URLError.Code: Remove hashValue implementation
These implementations did not produce the same hash values as the raw value. RawRepresentable provides a correct hashing implementation by default, so let’s just use that.
2018-12-10 13:00:57 +00:00
Karoy Lorentey
21d31ea6d9 [Foundation] _Bridged[Stored]NSError: Remove explicit impls for hashValue/_rawHashValue
The compiler-synthesized / stdlib-provided default implementations seem perfectly fine for these.
2018-12-10 13:00:57 +00:00
Karoy Lorentey
bbaec3d8bd [Foundation] Update hashing for bridged Error/NSError types
Protocols in resilient libraries that wish to provide a default implementation of hashing need to do so by providing a hash(into:) implementation.

hashValue has been deprecated as a Hashable requirement in SE-0206. Implementing only it in a protocol extension curses conforming types to get deprecation warnings by default.
2018-12-10 13:00:56 +00:00
Jon Shier
c739498c9b Remove usage lines from docs. 2018-12-09 19:20:49 -05:00
Jon Shier
e4a700c32d Update inline documentation. 2018-12-09 19:08:41 -05:00
Michael Gottesman
089e3a8ecd [cmake] tools/swift-reflection-test => stdlib/tools/swift-reflection-test.
If one thinks about it, swift's build has two sections: a runtime or target
section (i.e. ./stdlib) and a host section (everything
else). swift-reflection-test is an abberation from that pattern since it is
built for target platforms but is in the section of host tools.

In this commit, I move it into ./stdlib. Beyond being a bitter location
conceptually this will additionally allow me to avoid a dependency cycle in
between the compiler and the stdlib build.

After this, there is only one more target in the compiler code: swift-lang. From
talking with Xi Ge, we can move that into its own separate project as a
package. Once that is done, I will not have any more cycles.
2018-12-09 02:20:33 -08:00
Slava Pestov
929bf610e0 Runtime: Fix demangling of function with single tuple-typed argument
While declaration mangling now does the right thing for parameter lists,
the function type mangling unfortunately still models the parameter list
as a single tuple node.

Change the runtime's behavior to match the AST mangler, which wraps
a single tuple-typed parameter in a tuple node, so that we can produce
different mangling trees for function types taking multiple arguments
versus a single tuple argument.
2018-12-08 23:57:21 -05:00
Pitiphong Phongpattranont
a75d98f68c Refactor the looking for existing container code and change the error message on the condition 2018-12-08 13:39:40 +07:00
Pitiphong Phongpattranont
d61830b266 Change the tab character to be space for the wrong indentation 2018-12-08 13:39:39 +07:00
Pitiphong Phongpattranont
80056e2fb9 Fixed the wrong indentation due to the GitHub editor 2018-12-08 13:39:39 +07:00
Pitiphong Phongpattranont
c7a2b31cd2 Fixed the wrong indentation 2018-12-08 13:39:39 +07:00
Pitiphong Phongpattranont
9a3038d3f0 Precondition for the mismatch container type when requesing for the nested container with the same key 2018-12-08 13:39:38 +07:00
Pitiphong Phongpattranont
1750e04186 Look up and reuse the container when asking for the nested container with the same key in PlistEncoder 2018-12-08 13:39:38 +07:00
Pitiphong Phongpattranont
32ef8773a2 Look up and reuse the container when asking for the nested container with the same key in JSONEncoder 2018-12-08 13:39:38 +07:00
Joe Groff
b2ceb4b753 Merge pull request #21102 from jckarter/unconditional-cast-source-loc-abi
Runtime: Provide ABI space for source location info in unconditional casts.
2018-12-07 19:04:59 -08:00
Ben Cohen
11769d2494 Add tests for withContiguousStorageIfAvailable 2018-12-07 17:30:13 -08:00
Bob Wilson
d24bb36aab Merge pull request #21119 from mikeash/existential-metatype-metadata-cast-fix
[Runtime] Fix incorrect cast in NonFixedExistentialMetatypeBox::Container::getNumWitnessTables.
2018-12-07 15:20:07 -08:00
Greg Parker
368ca184fa [runtime] Fix some bugs when the stable ABI's is-Swift bit is set. (#21114)
* cmake: Propagate SWIFT_DARWIN_ENABLE_STABLE_ABI_BIT to overlay builds.
* runtime: Clear the correct bit in getROData()
* test/IRGen/objc_class_export.swift: Allow either is-Swift bit.
* test/stdlib/SwiftObjectNSObject.swift: Allow either name for SwiftObject.
2018-12-07 12:47:39 -08:00
Max Moiseev
290e9025fa Merge pull request #21118 from benrimmington/remove-interval-group-info
[stdlib] Remove Interval.swift from GroupInfo.json
2018-12-07 11:16:55 -08:00
Ben Cohen
ad50a39b12 [stdlib] Add withContiguous{Mutable}StorageIfAvailable (#21092)
* Add MutableCollection.withContiguousMutableStorageIfAvailable

* Add withContiguousMutableStorageIfAvailable impls

* Add tests on concrete types

* Add Sequence.withContiguousStorageIfAvailable

* Implement withContiguousStorageIfAvailable in concrete types
2018-12-07 10:01:18 -08:00
Karoy Lorentey
b77351548a Merge pull request #21045 from lorentey/modify-vs-throw
[stdlib] Dictionary: Support throwing yields in _modify accessors
2018-12-07 17:08:42 +00:00
Mike Ash
2114ce011e [Runtime] Fix incorrect cast in NonFixedExistentialMetatypeBox::Container::getNumWitnessTables.
The incorrect cast led to absurd values for getNumWitnessTables which then caused crashes (or worse?) down the line.

SR-8158 rdar://problem/41725205
2018-12-07 09:51:12 -05:00
Ben Rimmington
4e667cb97b [stdlib] Remove Interval.swift from GroupInfo.json 2018-12-07 12:39:36 +00:00
Saleem Abdulrasool
6e7051eb1e Merge pull request #20944 from compnerd/os-family
stdlib: restructure for OS family layout of SDK overlay
2018-12-06 18:22:51 -08:00
Max Moiseev
51b9c52c23 Merge pull request #21097 from moiseev/test-error
Make an StdlibUnitTest error message a bit more useful
2018-12-06 16:40:14 -08:00
Joe Groff
bce1f5ef4a Runtime: Provide ABI space for source location info in unconditional casts.
Currently ignored, but this will allow future compilers to pass down source location information for cast
failure runtime errors without backward deployment constraints.
2018-12-06 14:58:14 -08:00
Maxim Moiseev
ebf90f78be Make an StdlibUnitTest error message a bit more useful 2018-12-06 14:11:57 -08:00
swift-ci
9596624981 Merge pull request #21082 from compnerd/house-of-cards 2018-12-06 12:46:33 -08:00
swift-ci
80abe8ca2f Merge pull request #21044 from mikeash/anyhashable-to-enum-fix 2018-12-06 12:31:45 -08:00
Saleem Abdulrasool
41d9c2cc59 stdlib: restructure for OS family layout of SDK overlay
The SDK directory is now confusing as the Windows target also has a SDK
overlay.  In order to make this more uniform, move the SDK directory to
Darwin which covers the fact that this covers the XNU family of OSes.
The Windows directory contains the SDK overlay for the Windows target.
2018-12-06 11:32:05 -08:00