Commit Graph

3245 Commits

Author SHA1 Message Date
Guillaume Lessard
9457406d0b Merge pull request #38463 from wongzigii/SR-14886
Check withContiguousStorageIfAvailable before copying byte by byte
2021-07-30 09:40:09 -06:00
Guillaume Lessard
37a48eaeac Merge pull request #38699 from glessard/absurd-allocations 2021-07-30 07:32:13 -06:00
ZigiiWong
26b3c55c23 [SR-14886] Check wCSIA before copying byte by byte. 2021-07-30 11:04:15 +08:00
Guillaume Lessard
d03cb6daa1 [test] move two tests from from stdlib to runtime 2021-07-29 17:04:47 -06:00
Mike Ash
4efb9ac0ac [Tests] Mark some tests as unsupported in back deployment testing.
These tests require a newer runtime and fail on older OSes:

   test/Concurrency/Runtime/actor_detach.swift
   test/Concurrency/Runtime/actor_init.swift
   test/Interpreter/rdar80847020.swift
   test/stdlib/Reflection_objc.swift
2021-07-28 17:49:40 -04:00
Guillaume Lessard
4aaee48dae Merge pull request #38460 from glessard/absurd-allocations
[test] ensure allocation test from #38424 also runs on 32-bit architectures
2021-07-17 22:19:42 -06:00
Guillaume Lessard
04d9473e6d ensure test runs on 32-bit architectures too
(cherry picked from commit f28f492f93)
2021-07-17 07:46:32 -06:00
Guillaume Lessard
8fd1cd9289 Merge pull request #38424 from glessard/absurd-allocations
[runtime] Improve detection of memory allocation failures
2021-07-16 22:20:56 -06:00
Guillaume Lessard
a5feb1ab6b detect failed allocations from posix_memalign
- `posix_memalign` doesn't touch its pointer-to-pointer parameter when it
  fails, so `AlignedAlloc` ended up returning stack garbage in that case.
2021-07-15 19:17:14 -06:00
Pavel Yaskevich
d1e12785ed [Diagnostics] Diagnose ambiguous solutions with warnings like regular ambiguities
If solutions either have no fixes at all or all of the are warnings,
let's use `diagnoseAmbiguity` to diagnose such cases as-if there are
no fixes at all.

Resolves: rdar://79657350
2021-07-08 22:06:12 -07:00
Mishal Shah
0572b351d2 Merge pull request #38081 from xedin/unxfail-75006694
[stdlib] NFC: Un-XFAIL test/stdlib/Reflection_objc.swift on arm64
2021-06-24 09:46:17 -07:00
Pavel Yaskevich
791670040d [stdlib] NFC: Un-XFAIL test/stdlib/Reflection_objc.swift on arm64
Resolves: rdar://75006694
2021-06-24 09:45:12 -07:00
Ben Rimmington
d3d87e8447 [Concurrency] Deprecate typealias PartialAsyncTask (#38042)
Deprecate typealias PartialAsyncTask, and move it into the "SourceCompatibilityShims.swift" file.
2021-06-23 21:16:17 +01:00
eeckstein
53fc177261 Merge pull request #37945 from eeckstein/fix-cow-check-availability
stdlib: fix availability for internal COW checks.
2021-06-22 07:20:40 +02:00
David Zarzycki
3178ff0310 [testing] Add missing REQUIRES: foundation 2021-06-17 06:40:37 -04:00
Erik Eckstein
6f4192927e tests: refactor Array test files.
* move all ObjC array tests into a separate file ArraysObjc.swift.gyb
* merge the remaining Arrays.swift.gyb and ArrayNew.swift.gyb files
* move the utilities from ArrayTypesAndHelpers.swift into its only use into ArraysObjc.swift.gyb
2021-06-17 11:30:59 +02:00
Alastair Houghton
6ec0bbd49c Merge pull request #37949 from al45tair/problem/56473712
Print raw values for C/C++ enums.
2021-06-17 09:10:39 +01:00
Karoy Lorentey
5847452f54 Merge pull request #37914 from lorentey/fix-array-storage-access
[stdlib] Implement _copyContents on internal Array types
2021-06-16 18:06:33 -07:00
Karoy Lorentey
466e26a872 [stdlib] Implement _copyContents on internal Array types
`_copyContents(initializing:)` is a core method of Sequence, and it is used surprisingly often to copy stuff out of sequences. Array’s internal types currently have explicit implementations of it that trap (to prevent a performance bug due to the default iterator-based implementation. This has proved a bad idea, as not all code paths that end up calling `_copyContents` have actually been expunged — so we replaced a performance bug with a catastrophic correctness bug. 😥

Rather than trying to play whack-a-mole with code paths that end up in `_copyContents`, replace the traps with (relatively) efficient implementations, based on the ancient `_copyContents(subRange:initializing)` methods that have already been there all this time.

This resolves https://bugs.swift.org/browse/SR-14663.

I expect specialization will make this fix deploy back to earlier OSes in most (but unfortunately not all) cases.
2021-06-16 13:47:00 -07:00
Alastair Houghton
02a13e71c7 Print raw values for C/C++ enums.
When printing C/C++ enum values, in lieu of having proper metadata for the enum
type, try to display a raw value (see SR-6550)

rdar://56473712
2021-06-16 14:45:50 +01:00
Mike Ash
d435af4ea8 Merge pull request #37863 from mikeash/metadata-reader-sane-sizes
[Reflection] Sanity-check metadata sizes in MetadataReader before reading.
2021-06-14 17:34:28 -04:00
Mike Ash
ebd9c215ec [Reflection] Sanity-check metadata sizes in MetadataReader before reading.
MetadataReader can be given corrupt or garbage data and we need to be able to handle it gracefully. When reading metadata, the full size to read is calculated from partial data. When we're given bad data, these calculated sizes can be enormous, up to 4GB. Trying to read that much data can cause address space exhaustion which leads to unpleasantness.

To avoid this, fix a limit of 1MB on metadata sizes, and fail early if the size is larger. No real-world metadata should ever be that large.

We also switch these potentially large calls to use the readBytes variant that returns a unique_ptr, rather than allocating a buffer and reading into it. Our clients typically implement that as the primitive, so this avoids an unnecessary extra data copy and extra address space usage for them. Clients that implement reading into a provided buffer as the primitive should see the same performance as before.

rdar://78621784
2021-06-11 13:20:10 -04:00
Mishal Shah
23c3b15f5f Support Xcode 13 beta
* Updating availability versions
* Remove all remaining overlays in stdlib/public/Darwin/*:
   - ObjectiveC
   - Dispatch
   - CoreFoundation
   - CoreGraphics
   - Foundation
2021-06-07 12:04:31 -07:00
Eric Miotto
c4acb1704c Remove TestDecimal.swift (#37748)
Addresses rdar://61160009
2021-06-04 07:16:36 -07:00
Karoy Lorentey
9cf28dffa2 [SDK] Remove the obsolete XCTest overlay
The actual XCTest overlay has not been maintained in this repository for years. (It is distributed in Xcode (libXCTestSwiftSupport.dylib), along with XCTest.framework itself.)

The code we have here is badly out of date, and the fact that we have it on the module path in CI makes it interfere with the contents of recent SDKs.

Remove the XCTest overlay from this repository; pick it up from the SDK instead.

rdar://76915582
2021-05-21 17:21:12 -07:00
Alexis Laferrière
7487c12d05 Merge pull request #37269 from xymus/test-macro
[Concurrency] Define and use the SwiftStdlib 5.5 availability macro in tests
2021-05-10 10:46:53 -07:00
Arnold Schwaighofer
7bc446ed99 Disable test stdlib/PrintFloat.swift.gyb on arm64_32 watchos
It fails on a bot.

rdar://77087867
2021-05-07 07:53:25 -07:00
Alexis Laferrière
3310a55682 [Test] Use the SwiftStdlib 5.5 macro in Concurrency tests 2021-05-06 13:48:49 -07:00
John McCall
186c53000d Introduce basic support for custom executors.
- Introduce an UnownedSerialExecutor type into the concurrency library.
- Create a SerialExecutor protocol which allows an executor type to
  change how it executes jobs.
- Add an unownedExecutor requirement to the Actor protocol.
- Change the ABI for ExecutorRef so that it stores a SerialExecutor
  witness table pointer in the implementation field.  This effectively
  makes ExecutorRef an `unowned(unsafe) SerialExecutor`, except that
  default actors are represented without a witness table pointer (just
  a bit-pattern).
- Synthesize the unownedExecutor method for default actors (i.e. actors
  that don't provide an unownedExecutor property).
- Make synthesized unownedExecutor properties `final`, and give them
  a semantics attribute specifying that they're for default actors.
- Split `Builtin.buildSerialExecutorRef` into a few more precise
  builtins.  We're not using the main-actor one yet, though.

Pitch thread:
  https://forums.swift.org/t/support-custom-executors-in-swift-concurrency/44425
2021-04-30 03:11:56 -04:00
Pavel Yaskevich
46bc3b672d Merge pull request #37115 from xedin/disable-only-in-perf
[CSSimplify] Allow overload choices with missing labels to be considered for diagnostics
2021-04-29 10:25:16 -07:00
Dario Rexin
fe7ade852f [Linux] Add symbol to ignore list in symbol-visibility-linux test (#37001)
This test fails on linux-aarch64 because of the additional weak C++ symbol
2021-04-29 08:47:12 -07:00
Pavel Yaskevich
f36ecf2fa1 [CSSimplify] Allow overload choices with missing labels to be considered for diagnostics
Let's make use of a newly added "disable for performance" flag to
allow solver to consider overload choices where the only issue is
missing one or more labels - this makes it for a much better
diagnostic experience without any performance impact for valid code.
2021-04-28 12:04:57 -07:00
swift-ci
16532e3a0a Merge pull request #35759 from 3405691582/DispatchTestsUnsupported 2021-04-23 22:33:28 -07:00
Robert Widmann
b65777eabe Merge pull request #36963 from CodaFi/arm64_32
Add arm64_32 support for Swift
2021-04-20 17:42:56 -07:00
Robert Widmann
0149ccd0ca Add arm64_32 support for Swift
Commit the platform definition and build script work necessary to
cross-compile for arm64_32.

arm64_32 is a variant of AARCH64 that supports an ILP32 architecture.
2021-04-20 14:59:04 -07:00
Stephen Canon
8736683cf7 Prevent arbitrary objects from conforming to RNG. (#36969)
Me, sobbing: "Look, you can't just point at an empty struct and call it a RandomNumberGenerator."
Swift 5.4, pointing at anything: "RNG."
2021-04-20 16:39:16 -04:00
Erik Eckstein
e5e28ff4c4 SILGen: avoid reusing the same opened archetype in keypath setter and getter functions. 2021-04-14 08:36:10 +02:00
Nate Chandler
00f1c606ff [Test] Disabled several stdlib tests for back_deployment_runtime.
rdar://76568032
2021-04-13 15:42:33 -07:00
Mishal Shah
5af9100dc3 Disable SIMDConcreteFP.swift.gyb (76545659)
This test is taking 60+ mins to execute in https://ci.swift.org/job/oss-swift_tools-RA_stdlib-RDA_test-simulator/
2021-04-12 10:37:09 -07:00
swift-ci
ea23988b5d Merge pull request #36802 from mikeash/concurrentreadablearray-operator-new-delete 2021-04-09 08:56:36 -07:00
Mike Ash
70354af2b5 [Runtime] Avoid operator new/delete in ConcurrentReadableArray.
The callbacks made in ImageInspectionMachO.cpp are called in a dangerous context, with the dyld and ObjC runtime locks held. C++ allows programs to overload the global operator new/delete, and there's no guarantee that those overloads behave. Ideally, we'd avoid them entirely, but that's a bigger job. For now, avoid the worst trouble by avoiding STL and new/delete in these callbacks. That use came from ConcurrentReadableArray's free list, so we switch that from a std::vector to a linked list.

rdar://75036800
2021-04-09 09:29:20 -04:00
Slava Pestov
1e8ce52736 SIL: Strip [serialized] flag from functions even at -Onone
While the comment is correct to state that this won't enable any
new optimizations with -Onone, it does enable IRGen's lazy
function emission, which is important for 'reasync' functions,
which we don't want to emit at all even at -Onone.

This fixes debug stdlib builds with the new reasync versions
of the &&, || and ?? operators.
2021-04-08 01:47:27 -04:00
Xiaodi Wu
9ef5ed066b [SR-14424] Add 'moveInitialize' test case for small string 'init(unsafeUninitializedCapacity:initializingUTF8With:)' (#36742)
* [SR-14424] Add 'moveInitialize' test case for small string 'init(unsafeUninitializedCapacity:initializingUTF8With:)'

...and make an adjustment to an existing test case.

* [stdlib][test] Update test cases for small string unsafeUninitializedCapacity based on reviewer feedback.

* [fixup]
2021-04-04 15:16:20 -04:00
Michael Ilseman
9ab21d3215 Merge pull request #36623 from xwu/better-atoi
[stdlib][SR-7556] Re-implement string-to-integer parsing
2021-04-03 08:30:25 -06:00
Michael Ilseman
f495c02afe Merge pull request #36667 from milseman/small_differential
[stdlib] Fix bug in small string uninitialized init
2021-04-02 16:46:51 -06:00
Xiaodi Wu
92d492f58b [stdlib] Add a test for string-to-integer parsing for opaque strings. 2021-04-01 13:16:16 -04:00
Mike Ash
1173b737aa [Concurrency] Add availability to Concurrency APIs.
This allows programs to target older OSes while using Concurrency behind an availability check. When targeting older OSes, the symbols are weak-linked and the compiler will require the use of Concurrency features to be guarded by an availability check.

rdar://75850003
2021-04-01 10:42:08 -04:00
Karoy Lorentey
f7f44763eb [test] Add missing version guards to tests for new stdlib behavior
rdar://75837172
2021-03-30 22:06:55 -07:00
Michael Ilseman
49eddbf318 [stdlib] Fix bug in small string uninitialized init
Fix a bug and enforce the invariant that all bits between the last code unit
and the descriminator in a small string should be unset.
2021-03-30 18:24:28 -06:00
Erik Eckstein
f0641db51d tests: add a test for a fix of getting an ArraySlice of an CocoaArray
The problem was fixed in 375f289597.

rdar://74807247
2021-03-25 19:26:12 +01:00