Commit Graph

12522 Commits

Author SHA1 Message Date
Saleem Abdulrasool
bc58e5bc3f stdlib: disable abort reporting on Windows
Avoid the dialog when an assertion fails on Windows.  This is important to
ensure that the tests do not create a large number of prompts.
2019-01-03 16:56:42 -08:00
Nate Cook
f19aca6cb0 [WIP] Revise documentation for Swift 5 stdlib additions (#21333)
* Revise the Unicode scalar/Character properties
* Minor revisions to `compactMapValues` docs.
* Add documentation for AdditiveArithmetic, revise Numeric
* Apply minor style updates to count(where:).
* Revise string interpolation docs.

- Convert table of interpolation examples to a list of examples. Tables
aren't supported by Swift markup, so this wouldn't render properly in
Xcode or on the web.
- Add a description of what a user must implement in a custom
string interpolation type to get the behavior they want.

* Revise isMultiple(of:) docs.

- In particular, add emphasis to mathematical symbols and equations to
match how we document such things elsewhere.
- I'm using asterisks for single symbols, and underscores for equations
because it's easier to read in-source when you don't have to escape
multiplication within emphasis.

* Add some abstracts to the SIMD vector types.

- Adds a dictionary of spelled out numbers. Only numbers < 10
  should be spelled out according to editorial.
- Adds abstracts to some of the basic members.
- Includes parameter descriptions for the xyzw properties and inits,
but not for the unlabeled initializers. Combined with the protocol
extension method abstracts, this should complete coverage of the concrete
types.
2019-01-03 18:19:20 -06:00
Max Moiseev
decd65d543 Merge pull request #21356 from compnerd/harness
StdlibUnittest: port the test harness to Windows
2019-01-03 15:42:38 -08:00
Andrew Trick
0b5fa792e1 Force manual allocation (via Unsafe*Pointer) to use >= 16 alignment.
This fixes the Windows platform, where the aligned allocation path is
not malloc-compatible. It won't have any observable difference on
Darwin or Linux, aside from manually allocated memory on Linux now
being consistently 16-byte aligned (heap objects will still be 8-byte
aligned on Linux).

It is unfortunate that we can't guarantee Swift-allocated memory via
Unsafe*Pointer is malloc compatible on Windows. It would have been
nice for that to be a cross platform guarantee since it's normal to
allocate in C and deallocate in Swift or vice-versa. Now we have to
tell developers to always use _aligned_malloc/_aligned_free when
transitioning between Swift/C if they expect their code to work on
Windows.

Even though this fix isn't required today on Darwin/Linux, it makes
good sense to guarantee that the allocation/deallocation paths are
consistent.

This is done by specifying a constant that stdlib can use to round up
alignment, _swift_MinAllocationAlignment. The runtime asserts that
this constant is greater than MALLOC_ALIGN_MASK for all platforms.
This way, manually allocated buffers will always use the aligned
allocation path. If users specify an alignment less than m

round up so users don't need
to pass the same alignment to deallocate the buffer). This constant
does not need to be ABI.

Alternatives are:

1. Require users of Unsafe*Pointer to specify the same alignment
   during deallocation. This is obviously madness.

2. Introduce new runtime entry points:
   swift_alignedAlloc/swift_alignedDealloc, introduce corresponding
   new builtins, and have Unsafe*Pointer always call those. This would
   make the runtime API a little more obvious but would introduce
   complexity in other areas of the compiler and it doesn't have any
   other significant benefit. Less than 16-byte alignment of manually
   allocated buffers on Linux is a non-goal.
2019-01-03 12:35:51 -08:00
Raj Barik
4be5ab167e Add inline(always) to AnyCollection routines like _suffix, _prefix, _drop 2019-01-03 11:33:09 -08:00
Michael Ilseman
e6586ac209 Merge pull request #21465 from linux-on-ibm-z/s390x-unicode-scalar-fix
[stdlib] Fix Unicode.Scalar to String cast on big endian machines
2019-01-03 11:32:23 -07:00
Johannes Weiss
f87ffd2077 conform Unsafe(Mutable)RawBufferPointer conform to _HasContiguousBytes 2019-01-03 18:23:08 +00:00
Harlan Haskins
b29f1ee1a2 Merge pull request #21527 from nordicio/stdlib_warning_stringstorage
[stdlib] fixes warning: result of call to 'initialize(from:)' is unused
2019-01-03 10:03:49 -08:00
Valeriy Van
a4496d51d8 Fixes typo in var name in example snippet (#21553)
imagePaths is declared in line 320
2019-01-02 16:21:42 -06:00
Dennis Vennink
45429ffa24 Add Zip2Sequence.underestimatedCount (#21530) 2019-01-02 12:46:49 -05:00
Saleem Abdulrasool
b7e21da2d0 StdlibUnittest: add a VEH for TRAP on Windows
Add a vectored exception handler for illegal instructions on Windows.
This allows us to emulate `signal(SIGTRAP, ...)`.  This allows better
coverage of tests.
2019-01-02 09:38:18 -08:00
Saleem Abdulrasool
9421d0189c StdlibUnittest: prevent abort dialog on Windows
Adjust the abort behaviour on Windows.  The aborts would cause a large
number of dialogs to appear.  This reduces the load a bit and is crucial
for getting tests to run without manual intervention.
2019-01-02 09:37:34 -08:00
Saleem Abdulrasool
3027784bf7 StdlibUnittest: add a workraound for DOS lineendings
Windows uses DOS line endings which appear through the PIPE endpoints.
We currently split on line feeds only, leaving the carriage return in
place.  Without this, the messages on the communication pipe would not
be interpreted correctly.
2019-01-02 09:37:34 -08:00
Saleem Abdulrasool
335ea14beb stdlib: port StdlibUnittest to Windows 2019-01-02 09:37:34 -08:00
Saleem Abdulrasool
b7aca2bd06 Merge pull request #21462 from compnerd/build-host-target
build: differentiate better between host and target
2019-01-02 08:35:51 -08:00
Saleem Abdulrasool
c9e2e8c0d9 Merge pull request #21495 from compnerd/swift-private-io
stdlib: implement _FDStreams in terms of HANDLES
2019-01-02 08:32:07 -08:00
Saleem Abdulrasool
608b79ecc4 Merge pull request #21514 from compnerd/i-am-sensitive-okay
build: correct case for STREQUAL
2019-01-02 08:28:07 -08:00
Saleem Abdulrasool
fe5fca72d8 Merge pull request #21532 from compnerd/the-mathematics-of-compatibility
Platform: add legacy compatibility macros to MSVCRT
2019-01-02 08:22:10 -08:00
Saleem Abdulrasool
5af85942d8 Merge pull request #21534 from compnerd/tee-ell-ess
runtime: correct `_stdlib_thread_key_create`
2019-01-02 08:21:54 -08:00
Saleem Abdulrasool
8d08d5cd70 Merge pull request #21552 from compnerd/circular-logic
SwiftShims: break circular dependency in MSVCRT
2019-01-02 08:20:36 -08:00
Saleem Abdulrasool
59ce3b1461 Merge pull request #21555 from compnerd/everyone-gets-a-standard
stubs: add workaround for Windows c++ runtime behaviour
2019-01-02 08:20:19 -08:00
Saleem Abdulrasool
65da2148e1 Merge pull request #21561 from compnerd/canonical-path-separator
build: convert paths to CMake paths before use
2019-01-02 08:19:56 -08:00
Saleem Abdulrasool
509060c78a build: convert paths to CMake paths before use
This converts the path separators to the CMake way.  This is primarily
important for Windows where the path separator is \ rather than /.  This
conversion allows the specification of the path in the proper windows
path style.
2018-12-30 12:27:16 -08:00
Saleem Abdulrasool
19a73ad135 SwiftShims: always define TARGET_IS_SIMULATOR
This is used as a conditional guard rather than checked for a
definition.  Ensure that a value is always defined.  Silences a -Wundef
warning.  NFC
2018-12-30 10:28:37 -08:00
Saleem Abdulrasool
1d22ee886c stubs: add workaround for Windows c++ runtime behaviour
The conversion routines in MSVCPRT return "0" for the conversion of
"-inf" et al.  Provde template specializations for `float`, `double`,
and `long double` to use `strtof`, `strtod`, and `strtold` respectively.
This fixes the lossless conversion of floating point constants.
2018-12-27 21:23:01 -08:00
Saleem Abdulrasool
39621a51e7 SwiftShims: break circular dependency in MSVCRT
The inclusion of Windows.h would cause the Shims to depend on WinSDK, which
would in turn depend on MSVCRT.  However, the SwiftShims are using in MSVCRT
causing a circular dependency between WinSDK and MSVCRT preventing a clean build
from succeeding.  Break the dependency by only including libc headers in the
shims header.
2018-12-26 14:11:04 -08:00
Saleem Abdulrasool
40da65a43f runtime: correct _stdlib_thread_key_create
The mapping of the return value of the `FlsAlloc` was flipped resulting
in the failure of the TLS key creation.  The test suite would fail to
generate the TLS key resulting in failures.
2018-12-23 10:02:49 -08:00
Saleem Abdulrasool
58429e7d06 Platform: add legacy compatibility macros to MSVCRT
Although technically these shouldn't be needed on Windows since there is
no compatibility to maintain since there is no version that exists
previously.  However, this will ease porting of sources to the platform.
It also ensures that future tests added cover windows as well.
2018-12-23 09:58:01 -08:00
Andreas Jönsson
121f15b2ac [stdlib] fixes warning: result of call to 'initialize(from:)' is unused 2018-12-23 00:20:01 +01:00
Saleem Abdulrasool
f1043e4aa7 build: correct case for STREQUAL (NFC)
The swift variables use the upper case spelling while CMake uses mixed
case.  Use the correct case to fix the build.  This is preferable to
using MATCH to avoid the unnecessary configure time penalties.
2018-12-21 15:51:57 -08:00
Saleem Abdulrasool
7ecaeb1727 stdlib: implement _FDStreams in terms of HANDLES
Use HANDLE on Windows to create the FDStreams.  This will be used by the
standard library unit test test harness.
2018-12-21 14:19:03 -08:00
Max Moiseev
1116525f92 Merge pull request #21475 from moiseev/atomic-int-func-public
[stdlib] Make a couple internal functions back public
2018-12-21 12:12:25 -08:00
swift-ci
6996da5510 Merge pull request #21494 from compnerd/invalid-handle 2018-12-21 12:00:38 -08:00
David Smith
4e4325d248 Merge pull request #21235 from Catfish-Man/cheaper-by-the-dozen
Adopt bulk Dictionary creation in bridging
2018-12-21 11:37:40 -08:00
Saleem Abdulrasool
362235c166 WindowsSDK: add definition for INVALID_HANDLE_VALUE
Since handle's are so common place on Windows and the clang importer cannot
import the complex macro for INVALID_HANDLE_VALUE, define it locally to provide
an easier path to writing swift code on Windows.  This repairs the Windows
builds.
2018-12-21 09:18:12 -08:00
swift-ci
edc20104e3 Merge pull request #21483 from DougGregor/runtime-demangle-use-after-free 2018-12-20 21:41:58 -08:00
Robert Widmann
2efbeb3912 Merge pull request #21451 from CodaFi/logicd
[SR-8272] Drop the last remnants of LogicValue
2018-12-20 23:33:20 -05:00
Doug Gregor
f223d0b886 [Runtime] Eliminate a use-after-free when comparing @objc type names.
We were creating a local Demangler instance, demangling a type name
using it, and then returning one of the resulting nodes to the caller.

Fixes rdar://problem/46817009.
2018-12-20 20:28:23 -08:00
David Smith
016ced2c44 Adopt the new bulk Dictionary initializer in bridging 2018-12-20 16:57:38 -08:00
swift-ci
0ae5dd409e Merge pull request #21461 from compnerd/shellwapi 2018-12-20 16:47:13 -08:00
John McCall
b773fac123 Merge pull request #21453 from rjmccall/future-proof-arm64
Future-proof the ARM64 ABI by not reserving the entire top byte
2018-12-20 17:37:28 -05:00
Maxim Moiseev
a550606412 Make a couple internal functions back public 2018-12-20 14:23:27 -08:00
Max Moiseev
ff47c303ad Merge pull request #21443 from compnerd/ilp32
core: remove unsupported architecture conditional
2018-12-20 13:49:40 -08:00
Saleem Abdulrasool
c764e8a273 build: differentiate better between host and target
Assume that the build currently targets only a single target.  Use the target to
determine the linked libraries for the target library (swiftCore).  This is more
precise and more importantly, is required to enable cross-compilation of various
targets.
2018-12-20 09:18:27 -08:00
Saleem Abdulrasool
f1c2a57557 build: link swiftCore against Shell32
We are now using Shell APIs for the command line parsing.  Ensure that we link
against the Shell32 library.  This is needed for the cross-compilation as on
Windows, the environment will set a default link against a number of libraries.
This is more precise and explicit.
2018-12-20 09:13:34 -08:00
Michael Munday
cdd5aa0624 [stdlib] Fix Unicode.Scalar to String cast on big endian machines
We need to explicity ensure that an integer is in the required byte
order (little-endian in this case) before accessing it as an array
of bytes through an unsafe pointer.
2018-12-20 14:58:16 +00:00
Doug Gregor
4cdfa7e07e [IRGen/Runtime] Anonymous context descriptors can (should be) generic.
Anonymous context descriptors were being treated as non-generic by
IRGen, which lead to problems for (file)private types within generic
types. Emit generic parameters and requirements for anonymous contexts
as well.

The runtime was mostly prepared for this, and the ABI already
accounted for it, so the runtime change is minor---it only affected
building a demangle tree from metadata.

Fixes rdar://problem/46853806.
2018-12-19 23:25:59 -08:00
John McCall
6936ce7d90 Future-proof the ARM64 ABI by not reserving the entire top byte.
Targets that want to use armv8.5a memory tagging will need this.
Hopefully nobody comes up with a brilliant reason they need to use
anything else.
2018-12-20 00:30:28 -05:00
Robert Widmann
426fe886dc [SR-8272] Drop the last remnants of LogicValue
Removes the _getBuiltinLogicValue intrinsic in favor of an open-coded
struct_extract in SIL.  This removes Sema's last non-literal use of builtin
integer types and unblocks a bunch of cleanup.

This patch would be NFC, but it improves line information for conditional expression codegen.
2018-12-19 23:14:59 -05:00
Michael Ilseman
0ac802a95b Merge pull request #21310 from milseman/4_bit_string
[String] Last-minute ABI adjustment: 4-bit discriminator
2018-12-19 16:42:20 -08:00