Commit Graph

12522 Commits

Author SHA1 Message Date
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
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
Michael Ilseman
5ba5be3f43 [String] Speed up UTF-8 initialization from non-stdlib types
Avoid generic code paths if initializing for UTF-8 (the vast majority
of the time) from a non-stdlib type (such as Data).
2019-02-13 20:12:39 -08:00
Slava Pestov
2c015164cf Stop passing NodePointer by reference 2019-02-13 21:51:28 -05:00
Michael Ilseman
415cc8fb0c [String.Index] Deprecate encodedOffset var/init
String.Index has an encodedOffset-based initializer and computed
property that exists for serialization purposes. It was documented as
UTF-16 in the SE proposal introducing it, which was String's
underlying encoding at the time, but the dream of String even then was
to abstract away whatever encoding happend to be used.

Serialization needs an explicit encoding for serialized indices to
make sense: the offsets need to align with the view. With String
utilizing UTF-8 encoding for native contents in Swift 5, serialization
isn't necessarily the most efficient in UTF-16.

Furthermore, the majority of usage of encodedOffset in the wild is
buggy and operates under the assumption that a UTF-16 code unit was a
Swift Character, which isn't even valid if the String is known to be
all-ASCII (because CR-LF).

This change introduces a pair of semantics-preserving alternatives to
encodedOffset that explicitly call out the UTF-16 assumption. These
serve as a gentle off-ramp for current mis-uses of encodedOffset.
2019-02-13 18:42:40 -08:00
Konrad `ktoso` Malawski
f2baa7aa73 [docs][SR-9915] Compilation fix of docs snippet of type(of:)
Compilation of code sample snippets was broken due to using the same
identifier as the `type` function itself to store its result resulting
in:

```swift
func printGenericInfo<T>(_ value: T) {
    let type = type(of: value)
    print("'\(value)' of type '\(type)'")
}

// error: repl.swift:2:16: error: variable used within its own initial
// value
//    let type = type(of: value)
//               ^
```

Result:

- Snippets are more copy&paste friendly.
- Resolves https://bugs.swift.org/browse/SR-9915
2019-02-14 11:29:06 +09:00
Slava Pestov
d0c7b1547e ASTMangler: Mangle sugared types for the debugger
Fixes <rdar://problem/48004306>.
2019-02-13 19:17:25 -05:00
Saleem Abdulrasool
b2e8090feb Merge pull request #22586 from compnerd/point-me-to-a-fix
SwiftPrivateThreadExtras: fix casting due to API changes
2019-02-13 14:51:03 -08:00
Philippe Hausler
1fe1b86556 Add a safe API for NSValue and migrate NSValue value fetching to the size variants for validation (#22265) 2019-02-13 14:14:41 -08:00
Saleem Abdulrasool
59371dba24 SwiftPrivateThreadExtras: fix casting due to API changes
The recent changes to the UnsafemutablePointer prevented the "abuse" of
the type for casting.  Switch to `unsafeBitCast`.  This should repair
the Windows build.
2019-02-13 08:13:47 -08:00
swift-ci
e83974d4f6 Merge pull request #22581 from compnerd/sockets 2019-02-12 23:59:27 -08:00
Saleem Abdulrasool
cde0c32919 Windows: add some WinSock2 constants
This is the bare minimum of the WinSock2 constants that are needed for
the Foundation port to Windows which uses the socket APIs for
`-[NSTask run]` internal signalling.
2019-02-12 23:01:18 -08:00
swift-ci
aead660d91 Merge pull request #22147 from ravikandhadai/consteval-string-append 2019-02-12 16:11:41 -08:00
Andrew Trick
c90838a055 Merge pull request #22541 from atrick/speedup-array-init
Fix performance of array initialization from a generic sequence.
2019-02-12 12:45:30 -08:00
Ben Cohen
f15892c1a8 Merge pull request #22288 from airspeedswift/safe-conversion
[stdlib] Remove overly-permissive UnsafePointer init
2019-02-12 11:47:06 -08:00
swift-ci
498b72270b Merge pull request #22527 from Catfish-Man/literally-empty 2019-02-11 22:35:33 -08:00
Andrew Trick
638c3ea21c Merge pull request #22521 from atrick/fix-nil-buffer
Fix crashes in Unsafe[Raw]BufferPointer with nil baseAddress.
2019-02-11 22:00:43 -08:00
Andrew Trick
6d3397337d Fix performance of array initialization from a generic sequence.
This fixes a major perform bug involving array initialization from any
contiguously stored collection.	 This is not a recent regression. This fix
results in a 10,000X speedup (that's 4 zeros) for this code path:

func initializeFromSlice(_ a: [Int]) -> [Int] {
  return Array<Int>(a[...])
}

A benchmark is included.
2019-02-11 19:41:45 -08:00
Slava Pestov
c8effd26b3 Merge pull request #22408 from slavapestov/always-use-legacy-layouts
Always use legacy layouts
2019-02-11 19:10:02 -05:00
David Smith
bf32e78737 Make bridged empty NSDictionary and NSSet instances bridge to the empty singletons 2019-02-11 15:54:19 -08:00
David Smith
bf09c28b39 Make empty set literals use the singleton 2019-02-11 15:45:16 -08:00
David Smith
2a9aa16b3f Make empty dictionary literals use the singleton 2019-02-11 15:38:22 -08:00
Andrew Trick
28a529ceed Fix crashes in Unsafe[Raw]BufferPointer with nil baseAddress.
This fix updates various initializers to handle incoming empty buffers
that happen to have a nil base. They should simply create another
buffer with nil base rather than crashing!

It is valid for an Unsafe[Raw]BufferPointer can have a nil base
address. This allows round-tripping with C code that takes a
pointer/length pair and uses `0` as the pointer value.

The original design wrongly assumed that we would use a sentinel value
for empty buffers and was never updated for or tested with the current
design.

Fixes <rdar://problem/47946984> Regression in Foundation.Data's
UnsafeBufferPointer constructor.
2019-02-11 13:38:48 -08:00
Ben Cohen
0f339d3663 Merge branch 'master' into safe-conversion 2019-02-11 12:58:51 -08:00
Maxim Moiseev
d904d25fef Accelerate overlay does not seem to need -parse-stdlib 2019-02-11 10:50:16 -08:00
Nathan Lanza
4627ee72cc Fix swiftSwiftOnoneSupport.lib not being generated on windows debugbuilds 2019-02-08 17:54:21 -08:00
Slava Pestov
9f80a9cff0 Copy legacy layouts to stdlib build directory
This adds a new copy-legacy-layouts-${platform}-${arch} target for each
platform and architecture that the standard library is built for.

If the platform and architecture has a corresponding layout file in
stdlib/public/legacy_layouts/${platform}/layouts-${arch}.yaml, the
target copies this file to the build directory; otherwise, it does
nothing.

When building Swift code, the subroutines in SwiftSource.cmake add a
dependency on this target from each Swift code target.

Finally, we ensure that the YAML files are copied into the toolchain
package when building a toolchain.
2019-02-08 14:22:00 -05:00
Max Moiseev
093d48358d Merge pull request #22464 from moiseev/os-log-buffer-fix
[overlay] Size the os_log pack buffer appropriately
2019-02-08 10:11:40 -08:00
Saleem Abdulrasool
24dab81381 Merge pull request #22428 from drodriguez/fix-android-host-compiler-usage
[cmake] Recover original CMAKE_C/CXX_COMPILER after changing them.
2019-02-07 17:38:40 -08:00
Michael Ilseman
8dcfac6e87 Merge pull request #22168 from benrimmington/sr-6127
[stdlib] Fix memory leaks in readLine()
2019-02-07 14:25:22 -08:00