Commit Graph

13406 Commits

Author SHA1 Message Date
Saleem Abdulrasool
06ec943d89 StdlibUnittest: add a workaround for Windows \r\n
Windows uses carriage returns and newlines.  The string matching is
sensitive to this.  Simply erase carriage returns from the standard
error stream to compensate.
2019-02-28 23:13:52 -08:00
Saleem Abdulrasool
d26ca1cd3c SwiftShims: update shims copying logic
Update the shims logic to make sure that it works for Xcode as well.
Rather than adding additional rules, just simplify it down to the one
canonical way in modern LLVM land.  The headers are always installed to
the LLVM_LIBRARY_OUTPUT_INTDIR which will be defined for us in both the
standalone and unified build mode.  This allows us to just remove all
the work to find the headers since they will always be in one location.
2019-02-28 17:11:30 -08:00
Michael Ilseman
438010d366 [gardening] Dead File Elimination 2019-02-28 10:11:11 -08:00
Max Moiseev
c903186fa4 Merge pull request #22885 from moiseev/os-log-unshadow
[os_log] Un-shadow buffer so the correct copy happens
2019-02-28 10:07:16 -08:00
Max Moiseev
3bc9ce123a Merge pull request #22964 from moiseev/nil-unwrap-location
Print nil unwrap location in no-assert builds of stdlib
2019-02-28 10:06:40 -08:00
Saleem Abdulrasool
48d8ebd1b0 Merge pull request #21606 from compnerd/you-may-not-assert
stdlib: remove some static assertions which may not hold
2019-02-28 09:49:48 -08:00
Maxim Moiseev
2ce0630b58 Print nil unwrap location in no-assert builds of stdlib
We've been collecting the location info for some time now, but
apparently never printed it in no-assert builds of the stdlib, which
means this functionality was never available to the users.

With this change, the location will be printed depending on the
debug/release build configuration of the program, not stdlib.

Somewhat addresses: <rdar://problem/42980523>
2019-02-27 16:04:30 -08:00
Saleem Abdulrasool
0983ea66ae stdlib: use placement new on Windows, disable asserts
The assertions here are based around the idea that `std::atomic` is
trivially constructible which is not a guarantee that the standard fully
provides.  The default initialization of the `std::atomic` type may
leave it in an undetermined state.  These were caught using the Visual
C++ preview runtime.

Ideally, the object constructor would use a placement new operator.
However, prior to C++17, the C++ standard mandated that there be a
NULL pointer check in the placement new operator.  This is something
which is no longer the case with C++17.  Switch to the placement new
operator for C++17 and newer and enable that codepath for Windows as
well (which seemingly elides the null-pointer check with clang-cl).
2019-02-27 15:29:06 -08:00
Scott Perry
6e3139b5da Incorporate feedback from @lorentey and @moiseev 2019-02-27 14:05:06 -08:00
David Smith
22c61e4b94 Merge pull request #22956 from mikeash/dont-require-taggedpointer-obfuscator
[Reflection] Fail gracefully when objc_debug_taggedpointer_obfuscator isn't present.
2019-02-27 13:58:20 -08:00
Mike Ash
dd170399e4 [Reflection] Add some (disabled by default) debug logging in swift-reflection-test.c. 2019-02-27 14:37:33 -05:00
Daniel Rodríguez Troitiño
3f76e63b6e Merge pull request #22899 from drodriguez/reflection-context-fix-2
Reflection: try holding 32/64 address offset in target machine pointers.
2019-02-27 11:34:36 -08:00
Daniel Rodríguez Troitiño
8bee95d232 Reflection: try holding 32/64 address offset in type big enough for all architectures.
When compiling for a 32 bit machine, uintptr_t from ReflectionInfo will
be the integer sized to hold a 32 bit pointer, so a 64 bit pointer might
not fit.

This commit removes the solution in
0f20c486e0 and does a runtime check that
the calculated offset will fit into the target machine uintptr_t, which
might not be true for 32 bits machines trying to read 64 bits images,
which should not be that common (and those images have to have offsets
bigger than what a 32 bits number can hold).
2019-02-26 13:31:35 -08:00
Max Moiseev
67f62a14f0 Merge pull request #22272 from moiseev/intents-warnings
Remove access specifiers on some extensions to avoid warnings
2019-02-25 12:53:31 -08:00
Maxim Moiseev
a0326f6514 Un-shadow buffer so the correct copy happens
Fixes: rdar://problem/48299301
2019-02-25 11:19:53 -08:00
Saleem Abdulrasool
90fd8a5d34 stdlib: define and use SWIFT_{,UN}LIKELY
Rather than directly using the extension `__builtin_expect`, use a macro
to permit the removal of the builtin on compilers which do not support
this (i.e. cl).  This permits us to build the swift compiler with MSVC
again.
2019-02-24 13:58:18 -08:00
Karoy Lorentey
fd32a3d14e [stdlib] Set availability of diffing APIs 2019-02-22 14:28:15 -08:00
Karoy Lorentey
57f4afbf84 [stdlib] Update diffing code to match stdlib coding conventions
- Add an underscore to private/internal symbols
- Make access levels explicit, even when they’re implied from context
- Conform to max line length of 80 characters
- Conformances declared on separate extensions that implement them
- Arrange member declarations so that stored properties appear first
- Expand single-letter function and type parameter names where there is an obvious name that’s more descriptive
- RangeReplaceableCollection.fastApplicationEnumeration → CollectionDifference._fastEnumeratedApply
2019-02-22 14:27:45 -08:00
Saleem Abdulrasool
3df60b4a84 SwiftRemoteMirror: fix static library builds for Windows
We were previously treating all the builds as shared, which is not the
case for the host library build of SwiftRemoteMirror.  The warnings were
lost in the interminable spew from the build which is now fixed and this
stands out.
2019-02-22 10:46:32 -08:00
Saleem Abdulrasool
0cfb54dbfa stdlib: make cl based compilation reasonable
`-Wall` with the clang-cl interface gives us `-Weverything` effectively,
which really reduces the effectiveness of the warnings.  Switch to `/W3`
which is roughly equivalent to `-Wall` in clang mode.
2019-02-21 22:38:02 -08:00
Saleem Abdulrasool
f58155924c stdlib: repair the Windows build
The recent change to enable the stack traces requires a dependency on
DbgHelp which we were not linking against.  Add the link.
2019-02-21 16:03:53 -08:00
Saleem Abdulrasool
cf6addc12b Merge pull request #22755 from jmittert/WindowsBacktrace
Fix StackTraces on Windows
2019-02-21 14:13:48 -08:00
Jason Mittertreiner
1abe971a16 Fix StackTraces on Windows 2019-02-20 12:59:54 -08:00
Saleem Abdulrasool
6e768e0998 WIndows: add an explicit cast
The constant value is imported as an unsigned value which means that we
cannot or the values together.  Add an explicit cast.
2019-02-20 09:44:19 -08:00
swift-ci
bbaf48a53a Merge pull request #22747 from compnerd/complexity-is-in-the-eye-of-the-beholder 2019-02-20 09:06:13 -08:00
Saleem Abdulrasool
ed4cf1a1b9 Windows: add a couple of constants to WinSDK
Add some WinUser.h (User32) constants to WinSDK to make it easier to use
the WinSDK for more purposes (e.g. SwiftWin32).
2019-02-20 07:46:21 -08:00
swift-ci
7ea8768127 Merge pull request #22569 from Catfish-Man/cheating-the-reaper 2019-02-19 21:58:19 -08:00
Saleem Abdulrasool
430a3bd645 Merge pull request #22716 from compnerd/reflect-the-reflection
SwiftRemoteMirror: resolve ambiguity in name lookup
2019-02-19 18:51:28 -08:00
David Smith
78c45e77b7 Add a flag to allow Swift objects (such as the singleton empty collections) to ignore refcounting 2019-02-19 18:22:39 -08:00
Michael Ilseman
f87960746c Merge pull request #22108 from milseman/en_gadus_offset
[String.Index] Obsolete encodedOffset var/init
2019-02-19 14:43:26 -08:00
Saleem Abdulrasool
70a7dda5b1 SwiftRemoteMirror: resolve ambiguity in name lookup
There are `swift::ReflectionContext` and `swift::reflection::ReflectionContext`
which makes the name lookup ambiguous on Windows.  Elaborate the type.
2019-02-19 11:37:03 -08:00
Michael Ilseman
de86e4f79e Merge pull request #22663 from milseman/indigenous_characters
[String] Naturalize Character
2019-02-19 10:52:04 -08:00
Lily Vulcano
802f0bd833 Merge pull request #22674 from compnerd/UB-is-your-friend
runtime: correct signature for `swift_swiftValueConformsTo`
2019-02-19 08:00:31 -08:00
Saleem Abdulrasool
4ef25383ce Merge pull request #22671 from compnerd/modularising-modules
WinSDK: improve module map further
2019-02-19 07:45:39 -08:00
Slava Pestov
6ac91701dd Runtime: Add precondition check to swift_updateClassMetadata()
This initialization pattern can only be used if there is a backward deployment
layout (IRGen calls this ClassMetadataStrategy::FixedOrUpdate) or if we are
running on a newer Objective-C runtime that supports class metadata update
hooks (IRGen calls this ClassMetadataStrategy::Update).

If neither condition holds, we must trap here to avoid undefined behavior.
2019-02-18 22:39:13 -05:00
Saleem Abdulrasool
4b44fed2e4 Merge pull request #22670 from compnerd/safer-bitcasting
SwiftPrivateThreadExtras: address improvement suggestions
2019-02-18 15:18:44 -08:00
eeckstein
bf909ca11b Merge pull request #22655 from eeckstein/stack-allocated-demangler
Make the demangler in the runtime use stack allocated memory.
2019-02-18 08:56:54 -08:00
Saleem Abdulrasool
3ec6e12520 runtime: correct signature for swift_swiftValueConformsTo
The swift side signature for `swift_swiftValueConformsTo` is:
`func swift_swiftValueConformsTo<T>(_: T.self) -> Bool`

This translates to:
`bool swift_swiftValueConformsTo(const Metadata *, const Metadata *)`

The elided parameter would be passed invalid values..  Running this on
Windows with optimizations triggered an optimization where the parameter
happened to be null as `rdx` is the second parameter rather than the 4th
parameter.
2019-02-16 21:24:36 -08:00
Saleem Abdulrasool
bba46b9a14 WinSDK: improve module map further
Split out the User32 interfaces from the previously owning module
(WinSock2).  This improves the debugging experience and more accurately
reflects the module structure but should not impact the ability to build
the swift runtime.
2019-02-16 14:21:34 -08:00
SpringsUp
ab36b51231 [stdlib] Make some trivial Substring methods inlinable 2019-02-16 19:52:21 +01:00
Saleem Abdulrasool
dcc10ba39f SwiftPrivateThreadExtras: address improvement suggestions
Use `ThreadHandle(bitPattern:)` rather than `unsafeBitCast` for the
conversion of the `uintptr_t` to the `HANDLE`.  Convert a variable from
`var` to `let` binding.
2019-02-16 10:31:04 -08:00
Michael Ilseman
83e1137e21 [String] Naturalize Character
Characters should always be native, and never shared.
2019-02-15 16:50:38 -08:00
Mike Ash
de805c0112 [Stdlib] Special-case major version 9999 as always available.
rdar://problem/43776049
2019-02-15 16:23:03 -05:00
Erik Eckstein
80e86fb5c3 Runtime: make the demangler use stack allocated memory.
This reduces the amount of mallocs significantly.
2019-02-15 09:29:49 -08:00
Erik Eckstein
58f2d373d4 Demangler: Reduce sizeof(Node) from 48 bytes to 24 bytes
This is done by disallowing nodes with children to also have index or text payloads.
In some cases those payloads were not needed anyway, because the information can be derived later.
In other cases the fix was to insert an additional child node with the index/text payload.

Also, implement single or double children as "inline" children, which avoids needing a separate node vector for children.

All this reduces the needed size for node trees by over 2x.
2019-02-15 09:29:49 -08:00
Saleem Abdulrasool
adbb7d7cbd build: simplify condition and IWYU CMake edition
Include a missing CMake module in a couple of locations that we were
using the function.  Simplify a condition to use `MATCHES` rather than
two `STREQUAL`.
2019-02-14 17:35:18 -08:00
swift-ci
98543efd03 Merge pull request #22575 from ktoso/wip-SR-9915-ktoso 2019-02-14 16:44:07 -08:00
Stephen Canon
6159ba810d Remove the (unused) SIMDOperators module. (#22530)
We originally planned to use this to hide some simd operators from the typechecker unless the user explicitly opted into having them but that scheme turned out to be ill-conceived, so we moved them
back into the stdlib. This change simply cleans up the empty vestigial module.
2019-02-14 16:37:41 -08:00
Michael Ilseman
5c19427a18 Merge pull request #22560 from milseman/name_brand_is_better
[String] Speed up UTF-8 initialization from non-stdlib types
2019-02-14 15:14:28 -08:00
Michael Ilseman
c4ff5a1a9f [NFC] Update StringObject comments 2019-02-13 20:12:39 -08:00