Commit Graph

13406 Commits

Author SHA1 Message Date
Erik Eckstein
117b1dafe6 Rename the two-parameter Builtin.condfail(c, message) to Builtin.condfail_message(c, message)
This is necessary to also support the old single paramter Builtin.condfail(c)
2019-07-17 17:41:59 +02:00
Michael Gottesman
f952ff0ee4 [ast] Move printing code from ASTPrinter onto a helper on BuiltinType and have ASTPrinter call that instead. 2019-07-16 23:26:01 -07:00
swift-ci
c76925c4ea Merge pull request #26152 from Catfish-Man/serrated-surrogates 2019-07-16 15:38:25 -07:00
David Smith
d091ecb009 Restore more-correct behavior of getting the full contents of bridged NSStrings containing invalid UTF-8 2019-07-16 12:05:56 -07:00
Saleem Abdulrasool
8b1079de45 Merge pull request #26163 from compnerd/correct-case-is-useful
Platform: fix library link names
2019-07-16 11:45:46 -07:00
Saleem Abdulrasool
a2ceae970b Platform: fix library link names
This adjusts the library link names so that linking works properly on
case sensitive file systems (e.g. ext4) when cross-linking.
2019-07-16 10:26:42 -07:00
Michael Munday
3844cb2177 Merge pull request #26144 from linux-on-ibm-z/runtime-enum-simplifications
Runtime: simplify loading and storing enum values
2019-07-16 18:19:53 +01:00
Erik Eckstein
6ed8a084d9 stdlib: Use the new failure message method for the "unexpected found nil while unwrapping an optional" failure message.
Advantage: the failure message is now also visible in release builds.
2019-07-16 14:51:18 +02:00
Erik Eckstein
3195bdc973 stdlib: let _precondition include the file+line info in debug builds.
For using the improved condfail messages in the stdlib, we need a function, like precondition(), just taking a StaticString instead of a String for the message.
The existing (underscored) _precondition is a perfect fit for this, except that it's not printing the location info in debug builds.
This change makes _precondition() equivalent to precondition, just taking a StaticString as argument.

The other alternative would be to add another variant of precondition, just taking a StaticString. But we already have so many failure functions in Assert.swift, so adapting an existing one seems to be a better solution.
This effectively undos a change from 5 years ago which intentionally removed the location info from _precondition (rdar://problem/16958193).  But this was at a time where swift was not open source yet. So I think today it's okay to always add location information, even if it's from inside the stdlib. It can be even very useful for expert users for looking up the location the stdlib source.
2019-07-16 14:51:18 +02:00
Erik Eckstein
b40ce6b34f SIL: add a failure message operand to Builtin.condfail
The SIL generation for this builtin also changes: instead of generating the cond_fail instructions upfront, let the optimizer generate it, if the operand is a static string literal.
In worst case, if the second operand is not a static string literal, the Builtin.condfail is lowered at the end of the optimization pipeline with a default message: "unknown program error".
2019-07-16 14:44:09 +02:00
Michael Munday
71fa7ece3f Runtime: simplify loading and storing enum values
This commit centralizes the code that converts variable length
tag values, stored in enum payloads and extra tag bytes, to and
from the 4-byte integer values that the runtime uses to represent
the enum case.

Note that currently big endian machines will store the tag value
in the first word of the destination. This reflects the current
behaviour of the compiler. I am however expecting to change this
so that the value is stored as a true variable-length big-endian
integer in the near future, so the tag value will be stored in
the last 4 bytes of payloads rather than the first 4 bytes like
they are on little-endian systems.
2019-07-16 09:47:46 +01:00
Harlan Haskins
bf6b01d3cf Merge pull request #26151 from apple/revert-25978-confail-messages
Revert "Better runtime failure messages (not yet enabled by default)"
2019-07-15 14:31:46 -07:00
Saleem Abdulrasool
70a79c4dc5 Merge pull request #26142 from compnerd/autolink-phase-2
Platform: extend WinSDK further
2019-07-15 14:01:37 -07:00
Brent Royal-Gordon
d5a2912a26 Revert "Better runtime failure messages (not yet enabled by default)" 2019-07-15 13:42:40 -07:00
Michael Munday
2f8b5ac9e2 Runtime: print type layout values correctly on big-endian systems
The memcpy in the type layout verifier was not correct for big-
endian systems. While we are here change 'long long' to a fixed
width unsigned type (uint64_t). It doesn't really make sense to
print the value as a signed number since we have zero extended
it from its original bit width using the memcpy.
2019-07-15 03:24:22 -04:00
Saleem Abdulrasool
13c1391138 SwiftShims: restrict AArch64 workaround to C++
`RefCount.h` can be included in a C context - e.g. building the
SwiftShims module.  Restrict the C++ overloads to the C++ context only.
This partially improves the build for Windows ARM64.
2019-07-14 14:01:40 -07:00
Saleem Abdulrasool
84f9eed9c8 Platform: extend WinSDK further
This extends the WinSDK module definition further to better modularise
the headers.  This should improve the header organisation as well as
setup additional autolink rules.
2019-07-14 13:54:37 -07:00
Karoy Lorentey
b0f30c8123 Merge pull request #26125 from lorentey/cutting-the-gordian-array-count
[stdlib] Simplify __SwiftNativeNSArrayWithContiguousStorage.count
2019-07-13 19:53:45 -07:00
Karoy Lorentey
d186e9ca91 [stdlib] Simplify __SwiftNativeNSArrayWithContiguousStorage.count 2019-07-12 16:43:03 -07:00
Michael Ilseman
e01a294da6 [stdlib] Introduce _invariantCheck_5_1 for 5.1 and later assertions.
Inlinable and non-inlinable code can cause 5.1 code to intermix with
5.0 code on older OSes. Some (weak) invariants for 5.1 should only be
checked when the OS's code is 5.1 or later, which is the purpose of
_invariantCheck_5_1.

Applied to String.Index._isScalarAligned, which is a new bit
introduced in 5.1 from one of the reserved bits from 5.0. The bit is
set when the index is proven to be scalar aligned, and we want to
assert on this liberally in contexts where we expect it to be
so. However, older OSes might not set this bit when doing scalar
aligning, depending on exactly what got inlined where/when.
2019-07-12 15:58:27 -07:00
Stephen Canon
dc5915cdb5 Replace stdlib and test/stdlib 9999 availability. (#26108)
* Replace stdlib and test/stdlib 9999 availability.

macOS 9999 -> macOS 10.15
iOS 9999 -> iOS 13
tvOS 9999 -> tvOS 13
watchOS 9999 -> watchOS 6

* Restore the pre-10.15 version of public init?(_: NSRange, in: __shared String)

We need this to allow master to work on 10.14 systems (in particular, to allow PR testing to work correctly without disabling back-deployment tests).
2019-07-12 16:30:36 -04:00
Erik Eckstein
bc48b3d69d stdlib: Use the new failure message method for the "unexpected found nil while unwrapping an optional" failure message.
Advantage: the failure message is now also visible in release builds.
2019-07-12 14:03:13 +02:00
Erik Eckstein
f8325add8f stdlib: let _precondition include the file+line info in debug builds.
For using the improved condfail messages in the stdlib, we need a function, like precondition(), just taking a StaticString instead of a String for the message.
The existing (underscored) _precondition is a perfect fit for this, except that it's not printing the location info in debug builds.
This change makes _precondition() equivalent to precondition, just taking a StaticString as argument.

The other alternative would be to add another variant of precondition, just taking a StaticString. But we already have so many failure functions in Assert.swift, so adapting an existing one seems to be a better solution.
This effectively undos a change from 5 years ago which intentionally removed the location info from _precondition (rdar://problem/16958193).  But this was at a time where swift was not open source yet. So I think today it's okay to always add location information, even if it's from inside the stdlib. It can be even very useful for expert users for looking up the location the stdlib source.
2019-07-12 14:03:13 +02:00
Erik Eckstein
3fd7eea96c SIL: add a failure message operand to Builtin.condfail
The SIL generation for this builtin also changes: instead of generating the cond_fail instructions upfront, let the optimizer generate it, if the operand is a static string literal.
In worst case, if the second operand is not a static string literal, the Builtin.condfail is lowered at the end of the optimization pipeline with a default message: "unknown program error".
2019-07-12 14:03:13 +02:00
Daniel Rodríguez Troitiño
82b4fe7dff Merge pull request #26079 from drodriguez/android-fix-cxx-interop-3
[android] Remove dependency from SwiftShims to Libc
2019-07-11 09:37:00 -07:00
Daniel Rodríguez Troitiño
c7d7115a58 [android] Remove dependency from SwiftShims to Libc
Seems that SwiftShims cannot import some system headers (checked by a
test in test/ParseableInterface/ModuleCache/SystemDependencies). So
adding <android/api-level.h> is not going to work.

The change reproduces the only piece necessary from the header, which is
interpreting that if no __ANDROID_API__ is defined, the level should be
the maximum allowed.
2019-07-10 16:37:23 -07:00
Saleem Abdulrasool
d3babb3737 Platform: start using autolink on Windows
Be more aggressive about using the autolinking functionality of modules
on Windows.  This makes it easier to use WinSDK in Swift as the link
dependencies are implicitly taken care of.
2019-07-09 22:59:07 -07:00
Daniel Rodríguez Troitiño
b77499f743 Merge pull request #26046 from drodriguez/android-fix-cxx-interop-2
[android] Include api-level.h for Android and C++ interop.
2019-07-09 18:57:48 -07:00
David Smith
68687e7408 Merge pull request #26007 from Catfish-Man/uninitialized-initialize-uppercase
Add a private implementation of a String initializer with access to uninitialized storage (https://github.com/apple/swift-evolution/pull/1022) and use it to speed up uppercased() and lowercased()
2019-07-09 17:58:42 -07:00
Daniel Rodríguez Troitiño
da3ff59a27 [android] Include api-level.h for Android and C++ interop.
When the header was used in Android, the usage of __ANDROID_API__ was
not set if the compiler wasn't setting it externally. There was a check
for __ANDROID_API__, which defaulted to zero, and so it didn't pass. The
external function definition was not being done, but in C mode, it
didn't matter because implicit functions are allowed. That's not true in
C++ mode, which fails to compile any code that tries to include this
header.

The solution is including android/api-level.h which will define
__ANDROID_API__ to a very high value if it is not defined already (which
is the default behaviour in the NDK).
2019-07-09 17:15:56 -07:00
David Smith
b06137b283 Add a private implementation of a String initializer with access to uninitialized storage (https://github.com/apple/swift-evolution/pull/1022) and use it to speed up uppercased() and lowercased() 2019-07-09 15:05:00 -07:00
Scott Perry
3924d1a99d Merge pull request #25825 from numist/numist/diff-inverse-master
add `CollectionDifference.inverse()` and test coverage
2019-07-09 14:46:20 -07:00
Karoy Lorentey
8a2960f7c6 Merge pull request #26029 from lorentey/fix-abi-breaks
[Darwin] Fix ABI breaks introduced since 5.0
2019-07-09 13:59:12 -07:00
Jordan Rose
659c49766b Merge pull request #25984 from jrose-apple/same-gamgee
[runtime] Handle same-type constraints when resolving generic params

rdar://problem/52364601
2019-07-09 13:43:24 -07:00
Karoy Lorentey
315e865d9f [Darwin] Fix ABI breaks introduced since 5.1
rdar://problem/52847498
(cherry picked from commit 9e94afdf83)
2019-07-09 12:48:34 -07:00
Matthew Johnson
0a8f154ab2 Add Identifiable protocol to the standard library 2019-07-09 14:17:20 -05:00
pschuh
4fd0671e54 Merge pull request #25870 from pschuh/cpp-1
Add -enable-cxx-interop flag and support for extern "C" {}
2019-07-09 11:37:31 -07:00
Dad @ GeekAndDad
749a9726ef Update example code to compile with Swift 5.0/5.1 (#25995)
* Update example code to compile with Swift 5.0/5.1

Took inspiration from Filter.swift as to modern syntax to use, though didn't convert `private` properties to `internal`.

* simplify example code as requested

Removed private scope on properties to enable synthesized initializers; removed previously added explicit initializers; add necessary parameter label.

* Update stdlib/public/core/LazySequence.swift

remove ill advised usability change

Co-Authored-By: Xiaodi Wu <xiaodi.wu@gmail.com>

* Update stdlib/public/core/LazySequence.swift

Co-Authored-By: Xiaodi Wu <xiaodi.wu@gmail.com>
2019-07-09 07:43:48 -05:00
Jordan Rose
4b8068d1df [runtime] Handle same-type constraints when resolving generic params
Generic parameters for a context are normally classified as "key",
meaning they have actual metadata provided at runtime, or non-key,
meaning they're derivable from somewhere else. However, a nested
context or constrained extension can take what would be a "key"
parameter in a parent context and make it non-key in a child context.
This messes with the mapping between the (depth, index) representation
of generic parameters and the flat list of generic arguments. Fix this
by (1) consistently substituting out extension contexts with the
contexts of the extended types, and (2) using the most nested context
to decide which parameters are key, instead of the context a parameter
was originally introduced in.

Note that (1) may have problems if/when extensions start introducing
their /own/ generic parameters. For now I tried to be consistent with
what was there.

rdar://problem/52364601
2019-07-08 17:46:14 -07:00
Jordan Rose
284b674900 [Runtime] Improve dump() for Metadata and (Type)ContextDescriptor
No functionality change.
2019-07-08 17:46:08 -07:00
Parker Schuh
fa69a73ee4 Add -enable-cxx-interop flag and support for extern "C" {} 2019-07-08 11:43:35 -07:00
Saleem Abdulrasool
28f2d80fd9 runtime: remove unused source (NFCI)
`StaticBinaryELF.cpp` was listed as an optional source but then unused
by any build target.  As a result, it escaped detection that the file
was no longer in use.
2019-07-06 21:13:47 -07:00
Saleem Abdulrasool
87aa923389 build: remove non-optional sources (NFC)
This just removes the files listed in the `LLVM_OPTIONAL_SOURCES` which
are in fact always built.  NFC
2019-07-06 15:49:21 -07:00
Xiaodi Wu
dfb90b7e1c Merge pull request #25745 from xwu/sync-decimal
[Foundation] Synchronize Decimal overlay with swift-corelibs-foundation
2019-07-05 14:42:16 -04:00
swift-ci
9ee3c0eab1 Merge pull request #25503 from stevebrun/stevebrun/NSLocalizedString-docs 2019-07-05 09:40:46 -07:00
Richard Wei
259571a7f7 Add default implementations for AdditiveArithmetic.{+=, -=}. (#25321)
This patch defines a default implementation for `+=` and `-=` in `extension AdditiveArithmetic` implemented in terms of `+` and `-`.
2019-07-04 22:57:27 -07:00
Ravi Kandhadai
7a3c6d58f5 [stdlib][oslog] Create an SPI _globalStringTablePointer that exposes
the builtin.globalStringTablePointer to the new OSLog overlay.

Modify the new OSLog implementation to use this SPI instead of
`withCString` to pass the (compiler-generated) format string to
the C os_log_impl ABI.

Move the OSLogOptimization pass before constant propagation in
the pass pipeline so that the SPI and the builtin it uses can be
folded to a string_literal instruction.

Update OSLogTests to work with the changes in the implementation.
2019-07-03 17:25:37 -07:00
Saleem Abdulrasool
8221c6735c Merge pull request #25960 from compnerd/nuclear-atomic-hammer
Runtime: add a workaround for Windows ARM64
2019-07-03 11:27:33 -07:00
Nate Cook
d0db904811 Revert "Capitalize the w in with"
This was my error — with should be lowercase in titles.
2019-07-03 11:52:22 -05:00
Saleem Abdulrasool
c0fb0036a3 Runtime: add a workaround for Windows ARM64
Unfortunately, `std::atomic` in msvcprt as of 14.21.27702 is broken for
double-width atomics on ARM64.  This has been reported to Microsoft and
is going to be fixed in VC++ 2019u3.  For the time being, add a partial
template specialisation for the two double-word sized types temporarily
as a workaround.  This allows the standard library build to get further.
2019-07-03 09:27:59 -07:00