Commit Graph

21434 Commits

Author SHA1 Message Date
Alex Martini
0958bdd312 Merge pull request #75383 from Jager-yoo/fix-compiler-protocols
[stdlib] Correct documentation formatting in CompilerProtocols
2024-07-26 17:20:33 -07:00
Holly Borla
7d65170614 Merge pull request #75495 from hborla/remove-redundant-sendable-stdlib 2024-07-26 06:38:19 -07:00
Holly Borla
dc3893d9ca [Concurrency] Remove redundant Sendable conformances in the standard library.
These conformances are all redundant because the `Sendable` conformance is
inherited from a superclass.
2024-07-25 21:51:56 -07:00
Alex Lorenz
c03627014e [android] fix path and cmake local build target tracking for posix_filesystem.apinotes
This apinote file needs to be accessible in the locally built Android SDK as it's being built with build.ps1, so that swift-foundation can be built with that file present. This change ensures that the file is copied over into the local build directory for that Android SDK, in addition to being included in the installed component

This change also places the component into lib/swift/apinotes, as that's where the clang importer already looks for API notes
2024-07-25 21:25:25 -07:00
Tim Kientzle
6fd0ddcec3 Merge pull request #75454 from tbkka/tbkka-reflection-performance-asan
When ASAN is visible, do not use page-aligned requests
2024-07-25 15:00:30 -07:00
Dave Lee
e0129799fa [Debug] Add user friendly diagnostic when @DebugDescription is atached to a generic (#75307)
Emit a user friendly diagnostic when `@DebugDescription` is attached to a generic 
definition.
2024-07-25 10:06:47 -07:00
Ben Rimmington
3c855da45d [stdlib] Fix coding style of AdditiveArithmetic (#75461)
Use explicit access modifiers instead of `public extension` inheritance.
2024-07-25 11:30:14 -04:00
Tim Kientzle
702f86c47d Merge pull request #75429 from tbkka/tbkka-mpe-improvements-2024-07-23
More MPE improvements
2024-07-24 21:55:30 -07:00
Tim Kientzle
3ffc3e8444 Use TC.targetPointerSize() for the pointer size 2024-07-24 16:23:17 -07:00
Ben Rimmington
fc8cc33777 [stdlib] Update documentation of integer types (#74973)
* [stdlib] Remove docs from default implementations

Customized docs were not removed:

  public static var isSigned: Bool
  public static var max: Self
  public static var min: Self
  public var description: String
  public var magnitude: Self
  public init<T: BinaryInteger>(_ source: T)
  public func distance(to other: Self) -> Int
  public func advanced(by n: Int) -> Self

* [stdlib] Remove unused docs for "unsafe" methods

* [stdlib] Remove inherited "ReportingOverflow" docs

* [stdlib] Remove inherited docs for operators

Customized docs were not removed.
(`+`, `-`, `*`, `+=`, `-=`, `*=`)

Non-inherited docs were not removed.
(`&+`, `&-`, `&+=`, `&-=`, `&*=`)

* [stdlib] Reattach doc comments to their APIs

Use `rstrip()` to remove the trailing newline.
<https://docs.python.org/3/library/stdtypes.html#str.rstrip>

* [stdlib] Remove inherited docs from integer types

* [stdlib] Remove FIXME(ABI) comments

* [stdlib] Remove unused docs for operators

* [stdlib] Update example code for `-=` and `*=`

* [stdlib] Update internal gyb comments

* [stdlib] Move docs to BinaryInteger overrides

* [stdlib] Remove unused gyb code

* [stdlib] Fix `&-` and `&*` examples
2024-07-24 17:31:15 -05:00
Tim Kientzle
9214ebd360 When ASAN is visible, do not use page-aligned requests 2024-07-24 14:58:16 -07:00
Allan Shortlidge
66e2f972ab Merge pull request #75432 from tshortli/maccatalyst-upstream
Upstream missing macCatalyst support
2024-07-24 09:58:04 -07:00
Tim Kientzle
706b0b0ed1 Whitespace changes to better match clang-format style 2024-07-24 09:08:51 -07:00
Alex Martini
736be735e6 DOCS: Add missing periods (#75407)
* Add missing period at end of sentence

* Add missing period

Co-authored-by: LamTrinh.Dev <me@lamtrinh.dev>

---------

Co-authored-by: LamTrinh.Dev <me@lamtrinh.dev>
2024-07-23 22:12:10 -07:00
Mike Ash
75fa43ebd8 [Concurrency] Clear current task TSD before enqueuing task in swift_task_switch. (#74736)
The executor may execute and free the task while the enqueue code is still finishing up. If that code tries to get an async backtrace (for example, if it calls malloc/free with malloc stack logging enabled) then it will find a dangling pointer in the current task TSD, and dereferencing it may crash.

rdar://130125017
2024-07-24 12:29:01 +09:00
Tim Kientzle
c19c73d74d Merge pull request #75415 from tbkka/tbkka-reflection-test-speedup
Huge speedup of RemoteMirror testing (in debug)
2024-07-23 19:50:46 -07:00
Allan Shortlidge
6fb6a56b20 SILGen: Introduce macCatalyst support for if #available.
Upstream the necessary changes to compile `if #available` queries correctly
when a `macabi` target triple or a `-target-variant` is specified.
2024-07-23 17:00:10 -07:00
Tim Kientzle
8d22ae449c More MPE improvements
This fills in a number of missing cases:
* MPEs with closure payloads
* MPEs with many non-payload cases
* MPEs with class existential payloads
* MPEs with existential metatype payloads

Resolves rdar://132270733
Resolves rdar://128705332
2024-07-23 16:08:57 -07:00
Tim Kientzle
9b7fcba72b Comments 2024-07-23 14:08:02 -07:00
Kavon Farvardin
2557ba96c8 Noncopyable: deprecate '@_moveOnly' attribute
This hidden attribute is a leftover from before the '~Copyable' syntax.

rdar://130526083
2024-07-23 11:05:33 -07:00
Tim Kientzle
8206c26c59 Remove some debugging code 2024-07-23 09:55:42 -07:00
Tim Kientzle
19cad5fbfb Huge speedup of RemoteMirror testing
**Background:**

Each RemoteMirror test runs two processes: A host process runs the
RemoteMirror library and queries memory data from a target process.  The host
and target communicate by passing strings back and forth with requests to read
particular information in memory.  The target is pure Swift; the host is
C/C++.

**What this change does:**

Without this, the host makes very many small requests to the target.
Each of those requests has to be individually parsed by the target
using String operations from the debug stdlib.  Actually transferring
the raw bytes is relatively quick.
With this, the host requests and caches "pages" of about 4k and
satisfies most requests from previously-fetched data.  This dramatically
reduces the total number of operations.

**Performance notes:**

The following notes only count the time to compile and run the 78 tests in the
validation-tests/Reflection directory using `lit.py`; it does not include time
to rebuild the project before running tests.

**Performance with debug stdlib:**

(That is: `build-script -ra --debug-swift-stdlib`) Before this change, I got
tired of waiting after about 15 minutes and it was about 1/4 done.  Some very
simplistic profiling showed >99% of the time being spent in stdlib String
operations in the target process.  Activity Monitor shows that individual tests
run for about 6 minutes of CPU time each.

With this change, the tests run in about 70s of wall time.  Almost all of the
time seems to spent compiling the tests; the tests themselves run too quickly to
even show up in the Activity Monitor.

**Performance with release stdlib:**

(That is: `build-script -ra`)
The tests run in about 70s of wall time with or without this change.
2024-07-23 09:50:41 -07:00
Mishal Shah
48d5aca28d Revert "Use associated objects to attach contiguous array buffers to lazy one…"
This reverts commit 7c011813f2.
2024-07-21 23:34:57 -07:00
Michael Ilseman
a0bf388bd5 UTF8-validation: speed up findInvalidRange (#75381)
Changes findInvalidRange from being O(n) to O(1).
2024-07-20 07:49:49 -06:00
Jaeho Yoo
ec78f498ec [stdlib] Correct documentation formatting in CompilerProtocols 2024-07-20 22:01:28 +09:00
David Smith
7c011813f2 Use associated objects to attach contiguous array buffers to lazy ones (#75148)
rdar://132124808
2024-07-19 23:21:41 -07:00
Alejandro Alonso
448596c03e Merge pull request #75366 from kim-minseong/main
[stdlib][public][core] Fix indentation in `Array`
2024-07-19 17:35:47 -07:00
Rintaro Ishizaki
2c63bf2b48 Merge pull request #75304 from rintaro/swiftsyntax-package-cmo
[SwiftSyntax] Enable Package CMO if possible
2024-07-19 17:34:09 -07:00
Mike Ash
fa0f2b2a37 Merge pull request #75274 from mikeash/fix-unsafe-continuation-validation
[Concurrency] Fix unsafe continuation validation when a continued task has been destroyed.
2024-07-19 17:06:24 -04:00
smonteiro2
684e9ebf0c [cxx-interop] Implements CxxMutableSpan, created from an UnsafeMutableBufferPointer
* Added tests for generic functions
* Add some tests for mutable spans
* Initialize ConstSpan from UnsafeMutableBufferPointer
* Change hardening flag
2024-07-19 10:38:52 +01:00
Minseong Kim
d5bcdca2b6 fix indentation from 1 space to 2 spaces 2024-07-19 16:41:58 +09:00
smonteiro2
15e1749594 Add precondition to prevent access out of bounds
The subscript function from CxxRandomAccessCollection did not perform any bounds-checks.
This means that C++ containers that don't provide the operator[] (or C++ containers used in generic contexts) didn't have bounds-checks.

Fixes rdar://126570011
2024-07-18 15:30:11 +01:00
Doug Gregor
ac0f574fdb Merge pull request #75127 from carlos4242/embedded-avr-cross-compile-stdlib
[AVR] standard library support for AVR
2024-07-17 22:17:42 -07:00
Rintaro Ishizaki
f0808e5335 [SwiftSyntax] Workaround a crash
The compiler crashes when compiling swift files importing package-cmo
enabled '.swiftmodule'. Avoid that by not-using '.swiftmodule'.
2024-07-17 14:29:28 -07:00
Alejandro Alonso
24a46c422b Merge pull request #74946 from Azoy/mutex-sending-inout
[stdlib] Adopt inout sending for Mutex
2024-07-17 10:56:57 -07:00
Carl Peto
de449c9611 revert atomics for now 2024-07-16 22:39:31 +01:00
Mike Ash
c1772eba50 [Concurrency] Fix unsafe continuation validation when a continued task has been destroyed.
SWIFT_DEBUG_VALIDATE_UNCHECKED_CONTINUATIONS works by tracking the context pointers of active continuations, and verifying that a resumed context is in the set of active continuations. However, the resume calls are passed the task pointer, not the context pointer. The context pointer is recovered from the task. If the task has been destroyed, the context pointer is invalid. This can result in a weird error message or it can crash if the context pointer is used before checking it against the active continuations.

Instead, track tasks that are suspended pending an unchecked continuation. If the task is destroyed, we'll still be passed the dangling pointer and check that pointer against the tracking info. We must be sure to check that before trying to use anything inside it.

rdar://131858544
2024-07-16 15:08:26 -04:00
Carl Peto
3689427834 [AVR] standard library support for AVR
- when compiling embedded cross compile target standard libraries, include AVR
- add 16-bit pointer as a conditional compilation condition and get the void pointer size right for gyb sources
- attempt to fix clang importer not importing __swift_intptr_t correctly on 16 bit platforms
- changed the unit test target to avr-none-none-elf to match the cmake build

[AVR] got the standard library compiling in a somewhat restricted form:

General
- updated the Embedded Runtime
- tweaked CTypes.swift to fix clang import on 16 bit platforms

Strings
- as discussed in https://forums.swift.org/t/stringguts-stringobject-internals-how-to-layout-on-16-bit-platforms/73130, I went for just using the same basic layout in 16 bit as 32 bit but with 16 bit pointers/ints... the conversation is ongoing, I think something more efficient is possible but at least this compiles and will probably work (inefficiently)

Unicode
- the huge arrays of unicode stuff in UnicodeStubs would not compile, so I skipped it for AVR for now.

Synchronization
- disabled building the Synchronization library on AVR for now. It's arguable if it adds value on this platform anyway.
2024-07-16 12:28:27 +01:00
Doug Gregor
a3bf1fc4c2 Merge pull request #75248 from DougGregor/unsafe-inherit-executor-the-rest
Extend _unsafeInheritExecutor_ to remaining @_unsafeInheritExecutor APIs
2024-07-15 18:46:38 -07:00
Doug Gregor
a47483c0ec Fix ABI issue with TaskLocal.withValue and update ABI test 2024-07-15 14:37:45 -07:00
Doug Gregor
f6ba1bbeaa Adopt _unsafeInheritExecutor_ workaround on the internal withValueImpl 2024-07-15 14:12:40 -07:00
Doug Gregor
d6b6bafe60 Extend _unsafeInheritExecutor_ to remaining @_unsafeInheritExecutor APIs
Extend the _unsafeInheritExecutor_ workaround to all remaining APIs in the
Concurrency library that have adopted `#isolation` default arguments to
(safely) stay in the caller's isolation domain...

... except one. Clock.measure() is currently running into problems with
the type checker workaround and needs a little more thought.

Fixes rdar://131760111.
2024-07-15 14:12:36 -07:00
Kenta Kubo
7b7110061f [stdlib][docs] Fix the SeeAlso documentation for withDiscardingTaskGroup (#72767)
The SeeAlso documentation for `withDiscardingTaskGroup` is missing trailing backticks.
2024-07-15 13:51:21 +09:00
Alejandro Alonso
bc7db0df4f Merge pull request #75205 from jmschonfeld/sync-shims-module-error
Fix build failure in _SynchronizationShims module
2024-07-13 23:17:15 +01:00
Nate Cook
846a861660 Improve RangeSet initialization performance (#75089)
When initializing a range set with a group of overlapping, identical,
or empty ranges, the initializer can exhibit poor performance due
to removing the unneeded ranges during processing. This change uses
a partitioning scheme instead, only removing the unnecessary ranges
at the end of initialization.
2024-07-12 15:01:38 -05:00
Jeremy Schonfeld
0216e62179 auto --> __swift_uint32_t 2024-07-12 10:07:42 -07:00
Jeremy Schonfeld
a3c614d924 Fix build failure in _SynchronizationShims module 2024-07-12 09:54:46 -07:00
Allan Shortlidge
373a3fe7de Merge pull request #75185 from tshortli/revert-aeic-diagnose-unavailable-code-reached
SILGen/stdlib: Remove `_diagnoseUnavailableCodeReached_aeic()`
2024-07-12 09:22:11 -07:00
Tim Kientzle
5916325b39 Merge pull request #75151 from tbkka/tbkka-harden-casting-failure
Tailored error reporting when dynamic casts have nonsensical type args
2024-07-11 15:14:10 -07:00
Allan Shortlidge
14200e412c SILGen/stdlib: Remove _diagnoseUnavailableCodeReached_aeic().
It should no longer be necessary to provide an `@_alwaysEmitIntoClient` version
of `_diagnoseUnavailableCodeReached()`. This workaround was originally added to
provide compatibility with projects that were misconfigured to compile against
a newer stdlib but link against an older one.

Resolves rdar://119892482.
2024-07-11 14:53:03 -07:00