Commit Graph

7182 Commits

Author SHA1 Message Date
Guillaume Lessard
4481cbd864 Merge pull request #68715 from glessard/rdar115912430 2023-09-23 13:11:41 -07:00
Tim Kientzle
659d1cfb13 Make ObjC isEqual: delegate to Equatable when Hashable isn't available
When a Swift struct gets bridged to Obj-C, we box it into an opaque
`_SwiftValue` Obj-C object.  This object previously supported the
Obj-C `isEqual:` and `hash` selectors by dispatching to the Swift
Hashable conformance, if present.

This does not work if the Swift struct conforms to Equatable but
does not conform to Hashable.  This case seems to have been
overlooked in PR #4124.

This PR extends the earlier work to support `isEqual:` by
first checking for a Hashable conformance, then falling back
on an Equatable conformance if there is no Hashable conformance.

Resolves rdar://114294889
2023-09-22 17:58:22 -07:00
Guillaume Lessard
61080e1f46 [stdlib] remove pointer conversion from inlined runtime code
This removes an inout-to-pointer conversion for runtime code that is completely expressed in Swift.
2023-09-22 15:39:00 -07:00
Kuba (Brecka) Mracek
96ef644e04 Merge pull request #68658 from kubamracek/embedded-pointer-conversions
[embedded] Un-fatalError array to pointer conversion APIs, add test
2023-09-21 14:52:14 -07:00
Kavon Farvardin
a69bcf8a61 Merge pull request #67930 from kavon/copyable-requirement
Copyable as a Requirement Against the Machine
2023-09-21 11:49:23 -07:00
Kavon Farvardin
cc7a41fc2c [stdilb] introduce Copyable protocol
This replaces the old, unavailable `_Copyable`.

rdar://110420673
2023-09-21 00:55:17 -07:00
Kuba Mracek
9898fc2a27 [embedded] Un-fatalError array to pointer conversion APIs, add test 2023-09-20 15:31:46 -07:00
Kuba Mracek
a56a4875c2 [embedded] Make StaticString versions assert/precondition/fatalError available in embedded Swift 2023-09-20 09:35:34 -07:00
Kuba (Brecka) Mracek
d6a8845633 Merge pull request #68614 from kubamracek/embedded-arrays
[embedded] Avoid use of a metatype in array implementation for embedded Swift
2023-09-20 07:07:28 -07:00
Kuba (Brecka) Mracek
ad9f316599 Merge pull request #68613 from kubamracek/embedded-exec-tests-on-x86
[embedded] Build the stdlib for x86_64 too, and run executable tests on x86_64
2023-09-20 07:02:32 -07:00
Philippe Hausler
029e296b34 Allow Identifiable and correct ObjectIdentifier for embedded variants (#68597) 2023-09-19 13:25:32 -07:00
Kuba Mracek
65d706db0d [embedded] Avoid use of a metatype in array implementation for embedded Swift 2023-09-18 20:36:53 -07:00
Kuba Mracek
e898a9a4fd [embedded] Build the stdlib for x86_64 too, and run executable tests on x86_64 2023-09-18 20:25:32 -07:00
Guillaume Lessard
469a614eef Merge pull request #68606 from kubamracek/embedded-int128
[embedded] Workaround a build failure in non-assertion embedded stdlib builds, unblock CI
2023-09-18 19:59:41 -07:00
Kuba Mracek
d0cbd893b9 [embedded] Workaround a build failure in non-assertion embedded stdlib builds, unblock CI 2023-09-18 17:37:54 -07:00
Kuba Mracek
5616368f06 [embedded] To unblock failing CI jobs, only build the embedded stdlib when building the compiler for now 2023-09-18 17:06:27 -07:00
Kuba Mracek
89bdcb8dc6 [embedded] Ifdef newly added _assertionFailure + isKnownUniquelyReferenced variants to avoid exposing new APIs outside of embedded Swift 2023-09-17 19:58:15 -07:00
Kuba Mracek
169ed58bee [embedded] Revert change on FixedWidthInteger protocol requirements, use an empty protocol instead 2023-09-17 17:23:08 -07:00
Kuba Mracek
aa9a881211 [embedded] Drop unintentional change in AssertCommon.swift 2023-09-16 13:45:03 -07:00
Kuba Mracek
c0735eee75 [embedded] Drop unnecessary #if in _makeCollectionDescription 2023-09-16 13:43:43 -07:00
Kuba Mracek
65a57c7811 [embedded] Add an explaining message into StaticString's fatalError 2023-09-16 13:40:43 -07:00
Kuba Mracek
92b075b518 [embedded] Drop several #ifs and fatalError()s by adding an unavailable ExpressibleByStringInterpolation String conformance 2023-09-16 13:40:25 -07:00
Kuba Mracek
cba7cdfad6 [embedded] Drop an unnecessary change in Integers.swift 2023-09-16 13:25:21 -07:00
Kuba Mracek
829967436e [embedded] Simplify AnyObject/Builtin.NativeObject split in arrays by using a typealias 2023-09-16 13:21:46 -07:00
Kuba Mracek
544ee14c47 [embedded] Provide alternate === and !== implementations instead of trying to switch away from existentials in a unified way 2023-09-16 12:47:34 -07:00
Kuba Mracek
ae2e903574 [embedded] Build an initial embedded Swift standard library
This isn't a "complete" port of the standard library for embedded Swift, but
something that should serve as a starting point for further iterations on the
stdlib.

- General CMake logic for building a library as ".swiftmodule only" (ONLY_SWIFTMODULE).
- CMake logic in stdlib/public/core/CMakeLists.txt to start building the embedded stdlib for a handful of hardcoded target triples.
- Lots of annotations throughout the standard library to make types, functions, protocols unavailable in embedded Swift (@_unavailableInEmbedded).
- Mainly this is about stdlib functionality that relies on existentials, type erasure, metatypes, reflection, string interpolations.
- We rely on function body removal of unavailable functions to eliminate the actual problematic SIL code (existentials).
- Many .swift files are not included in the compilation of embedded stdlib at all, to simplify the scope of the annotations.
- EmbeddedStubs.swift is used to stub out (as unavailable and fatalError'd) the missing functionality.
2023-09-16 12:38:46 -07:00
Kuba Mracek
b625bf9e25 [stdlib] Remove the essential/non-essential file split in the stdlib 2023-09-13 16:31:58 -07:00
Guillaume Lessard
561890f3ce [se-0405] tie deprecation to swift 6 language mode 2023-09-13 09:47:34 -07:00
Guillaume Lessard
0c916f507d [stdlib] replace uses of String(validatingUTF8:)
- use the new name `String(validatingCString:)`
2023-09-11 14:17:05 -07:00
Guillaume Lessard
1f0f30219c [se-0405] rename String.init?(validatingUTF8:) 2023-09-11 14:17:05 -07:00
Mike Ash
acbcd5f557 [Stdlib] Fix bridgedStorage lifetime in SwiftNativeNSArray._destroyBridgedStorage.
Extend the lifetime of bridgedStorage until after the contents are deinitialized. When two threads race in withUnsafeBufferOfObjects, the loser uses _destroyBridgedStorage to destroy its candidate buffer, and we need to extend the lifetime of that buffer since the parameter is the only extant reference to it.

rdar://99565140
2023-09-08 15:21:21 -04:00
nate-chandler
e7783563ce Merge pull request #68285 from nate-chandler/effects-diagnostic
[Diagnostics] Require explicit releasenone.
2023-09-08 07:04:31 -07:00
Nate Chandler
2637c41e26 [stdlib] Explicitly annotate with releasenone.
Annotated all functions with arguments that are consumed and are
annotated `@_effects(readnone)` or `@_effects(readonly)` with
`@_effects(releasenone)`.
2023-09-05 08:18:06 -07:00
Manu
02b5fa2c8e Fix some typos in the codebase 2023-08-31 18:50:10 -03:00
Nate Chandler
504ce43753 [stdlib] Delete bad @_effects(readonly) annotation
`Dictionary.init(dictionaryLiteral:)` was annotated
`@_effects(readonly)` which means among other things that it doesn't
release any references. Being an init, however, it consumes its
arguments, and so does in fact release.

rdar://114699006
2023-08-30 12:33:58 -07:00
Karoy Lorentey
c7658428f5 Merge pull request #68067 from lorentey/fix-Set.insert-overload-decl
[stdlib] Add @discardableResult to Set.insert’s AnyHashable overload
2023-08-24 14:30:10 -07:00
Nishith Kumar M Shah
056b4943a3 Fix String.hasPrefix and String.hasSuffix when self and arg are in NFC form (#67729) 2023-08-23 11:23:59 -05:00
Karoy Lorentey
4a8d23d303 [stdlib] Add @discardableResult to Set.insert’s AnyHashable overload
Unlike the core Set.insert, this utility declaration wasn’t declared @discardableOverload, introducing an undesirable inconsistency.

rdar://114008680
2023-08-22 13:44:51 -07:00
swift-ci
978395bc11 Merge pull request #62959 from meg-gupta/simplifycfgossapr3
Migrate simple and dominator based jump threading to OSSA
2023-08-18 17:18:10 -07:00
Meghana Gupta
8fafdd1148 Add @always(__inline) to _parseInteger(UnsafeBufferPointer<UInt8>, Int)
Integer parsing seems to be very sensitive to inlining.
With simplifycfg, _parseInteger function gets bigger and ends up not being inlined
causing significant performance regression in the integer parsing benchmarks.

Add @always(__inline) to recover the performance.
2023-08-18 14:32:14 -07:00
Ben Rimmington
98ada1b200 [stdlib] Fix buffer size of small-capacity strings (#67929) 2023-08-16 10:00:42 +01:00
David Smith
dade932a85 Revert "Try using withContiguousStorageIfAvailable in RangeReplaceableCollection.append(contentsOf:) before falling back to a slow element-by-element loop. Fixes rdar://109059874" (#67842)
This reverts commit 465aa22b81.
2023-08-10 01:39:20 -07:00
Stephen Canon
20a11db290 Revert "[stdlib] Fix calling convention mismatch for debugger utility functions" 2023-08-09 07:31:58 -04:00
Max Desiatov
cc72301a87 Merge pull request #66531 from swiftwasm/pr-8addaa1d85ba6750d500373b55bd9451e869c8e6
[stdlib] Fix calling convention mismatch for debugger utility functions
2023-08-01 09:49:37 +01:00
Max Desiatov
819d9847a5 stdlib/public/core: use UInt(bitPattern:) to make sure casts work 2023-07-31 16:50:52 +01:00
Stéphan Kochen
7b460ce495 build: fix accidental cmake expansions
As of CMake 3.25, there are now global variables `LINUX=1`, `ANDROID=1`,
etc. These conflict with expressions that used these names as unquoted
strings in positions where CMake accepts 'variable|string', for example:

- `if(sdk STREQUAL LINUX)` would fail, because `LINUX` is now defined and
  expands to 1, where it would previously coerce to a string.

- `if(${sdk} STREQUAL "LINUX")` would fail if `sdk=LINUX`, because the
  left-hand side expands twice.

In this patch, I looked for a number of patterns to fix up, sometimes a
little defensively:

- Quoted right-hand side of `STREQUAL` where I was confident it was
  intended to be a string literal.

- Removed manual variable expansion on left-hand side of `STREQUAL`,
  `MATCHES` and `IN_LIST` where I was confident it was unintended.

Fixes #65028.
2023-07-17 21:50:50 +02:00
swift-ci
b158328ebc Merge pull request #67271 from glessard/string-init-from-substring-utf8view
[doc] adjust to reflect the current implementation.
2023-07-12 18:37:48 -07:00
Guillaume Lessard
8912098c01 [doc] adjust to reflect the current implementation. 2023-07-12 14:13:19 -07:00
Dario Rexin
29ce7a341d [Stdlib] Add some prespecializations to the stdlib (#66446)
* [Stdlib] Add some prespecializations to the stdlib

This adds prespecializations for commonly used types to the stdlib

* Add false positives to ABI checker ignore list

* Update multithread_module.swift

* Update multithread_module.swift

* Update multithread_module.swift
2023-07-06 15:27:09 -07:00
Guillaume Lessard
98c50c3504 Merge pull request #67003 from glessard/idiomatic-rebinding-7
Rebind Memory Idiomatically
2023-06-29 13:53:09 -07:00