Commit Graph

14680 Commits

Author SHA1 Message Date
Egor Zhdan
6cd4b7c28f [cxx-interop] Make std::string::append usable from Swift
This adds a new Swift overload for `append` that takes another `std::string` as a parameter.

The original C++ overload for `append` is not exposed into Swift because it returns a mutable reference `string&`.

rdar://107018724
2023-06-19 20:51:27 +01:00
Alastair Houghton
bad716f2cd [Threading][TSan] Rearrange things again.
We need ThreadSanitizer.cpp in libswiftCore for the runtime case, but
we also need it in libswiftThreading for non-runtime cases.

rdar://1106655213
2023-06-19 17:00:39 +01:00
Yuta Saito
189dfc8590 Merge pull request #66545 from kateinoigakukun/pr-24ab097e23a1794d0cb5b29f35af64e90456b406 2023-06-20 01:00:26 +09:00
Alastair Houghton
8ed8a28478 [Threading][TSan] Move ThreadSanitizer.cpp into the main runtime.
On Darwin, `RTLD_NEXT` doesn't do what we need it to here, with the
result that if `libswiftCore`'s TSan initializer gets found first,
then `libswift_Concurrency` won't have its initializer called at all,
in spite of us using `RTLD_NEXT` to find the next definition.

Fix this by centralising the initializer in `libswiftCore` instead.

rdar://110665213
2023-06-19 15:33:36 +01:00
Alastair Houghton
ee5efff5b1 [Threading][TSan] Update after review comments.
* Use the longer name ThreadSanitizer rather than TSan for the new files.
* Don't implement `tsan::consume` at all for now.
* Do the `tsan::release` for `ulock_unlock()` at the head of the function,
  not at the tail.
* Add a comment to test/Sanitizers/tsan/once.swift to explain the test a
  little more clearly.

rdar://110665213
2023-06-19 15:32:50 +01:00
Alastair Houghton
41f46ec085 [Threading][TSan] Fix TSan errors from lazy init on Linux.
Move the TSan functionality from Concurrency into Threading.  Use it
in the Linux `ulock` implementation so that TSan knows about `ulock`
and will tolerate the newer `swift_once` implementation that uses it.

rdar://110665213
2023-06-19 15:32:50 +01:00
Yuta Saito
f527f72640 Merge pull request #66423 from kateinoigakukun/pr-0c7c2f57b05a694965ab652f57cbfead006a33d7
[static-stdlib] Move static-executable-args.lnk under stdlib/public/Resources/linux
2023-06-19 19:30:53 +09:00
Yuta Saito
8d84a64556 [wasm] Add metadata registration for WebAssembly
This patch adds the metadata registration for the wasm targets, and also
adds build support for it.
2023-06-19 06:13:20 +00:00
Kirby Turner
9abe0b9c68 Merge pull request #66636 from kirbyt/kirbyt/observation-docs-109798110
Observation reference documentation
2023-06-15 08:52:26 -04:00
Dario Rexin
d74c085fe8 [Runtime+IRGen] Add layout string support for generic singleton enums (#66647) 2023-06-14 20:13:15 -07:00
Kirby Turner
367a7f6453 Replace fenced code blocks with indentions. 2023-06-14 17:50:57 -04:00
Saleem Abdulrasool
df71ee08ba Merge pull request #66524 from hjyamauchi/dump-generic-metadata
Fix the swift-inspect dump-generic-metadata operation.
2023-06-14 14:48:07 -07:00
Kirby Turner
837f6e0999 Fix typo. 2023-06-14 17:40:57 -04:00
swift-ci
12b1843289 Merge pull request #66377 from mikeash/section-scan-signposts
[Runtime] Add tracing for section scans.
2023-06-14 13:50:28 -07:00
Kirby Turner
410b77024a Apply suggested coding style. 2023-06-14 16:37:50 -04:00
Kirby Turner
37e6741dd2 Apply review feedback. 2023-06-14 13:53:59 -04:00
Kirby Turner
bf5ecf00ce Add reference documentation to Observation symbols. 2023-06-14 13:26:48 -04:00
Dario Rexin
8b48a0d3e0 [Runtime+IRGen] Instantiate layout strings for generic multi payload enum (#66621)
Instantiating layout strings for generic types reduces code size and is expected to improve performance of generic value witnesses.
2023-06-14 09:31:11 -07:00
Mike Ash
110f428780 [Runtime] Add tracing for section scans.
Section scans (for metadata, protocols, etc.) can be costly. This change adds tracing calls to those scans so we can more easily see how much time is spent in these scans and where they're initiated.

This adds an os_signpost implementation controlled by SWIFT_STDLIB_TRACING, and a default empty implementation for when that's disabled.

rdar://110266743
2023-06-14 12:07:44 -04:00
Alastair Houghton
dd7acb1739 [Backtracing][Linux] Properly align the stacks.
We have two stacks that we set up during crash handling, both of
which were potentially misaligned.  This only tripped us up on
Ubuntu 20.04 on aarch64 - my guess is that maybe `clone()` aligns
the stack pointer on newer kernels which is why we didn't see it
on 22.04.

rdar://110743884
2023-06-14 13:40:51 +01:00
Egor Zhdan
5bddd518ef Merge pull request #66601 from apple/egorzhdan/borrow-cxxset-init
[cxx-interop] Optimize CxxSet initialization from a Swift Sequence
2023-06-14 12:44:42 +01:00
Dario Rexin
58ff42af16 [Runtime] Properly handle tuple types in layout string instantiation (#66603)
Tuple types contain metadata entries for each element, so we can handle them individually to avoid unnecessary indirection.
2023-06-13 13:48:05 -07:00
Egor Zhdan
042aff2a76 [cxx-interop] Optimize CxxSet initialization from a Swift Sequence
rdar://107909624
2023-06-13 18:04:20 +01:00
Egor Zhdan
74192c02d0 Merge pull request #65087 from apple/egorzhdan/cxx-set-init
[cxx-interop] Add `std::set` initializer that takes a Swift Sequence
2023-06-13 17:14:37 +01:00
Alastair Houghton
7145ff019d Merge pull request #66567 from al45tair/eng/PR-110653167
[Backtracing][Linux] Fix Ubuntu 20.04-aarch64 CI failures.
2023-06-13 15:50:01 +01:00
Saleem Abdulrasool
15e6c6f8c9 Merge pull request #66555 from compnerd/queued-status
Windows: add some defines from `WinUser.h`
2023-06-13 07:48:35 -07:00
Egor Zhdan
dd7e1775fc [cxx-interop] Add std::set initializer that takes a Swift Sequence
rdar://107909624
2023-06-13 14:51:28 +01:00
Stephen Canon
185820a148 Fix sign of fractional units in Duration initializers from Double. (#66582)
* Fix sign of fractional units in Duration initializers from Double.

When separating a double duration into integral and fractional parts, we got the sign wrong. This fixes that bug.

* Fixup variable name.
2023-06-13 08:46:46 -04:00
Dario Rexin
4ec82768ce [Runtime] Extract some layout string functionality into separate functions (#66577)
We want to re-use them for enum layout string instantiation, so best to pull them into separate functions.
2023-06-12 23:40:58 -07:00
Alastair Houghton
7e632c0ee0 [Backtracing][Linux] Fix Ubuntu 20.04-aarch64 CI failures.
These seem to be related to signal handling issues in threads that
have been started presumably by the C library or some other library.

Primarily this appears to affect Ubuntu 20.04 on aarch64, though I
have seen sporadic issues on 18.04 as well.

We address the problem by making the thread suspension mechanism
more robust in the face of threads with masked signals.

rdar://110653167
2023-06-12 18:54:05 +01:00
Saleem Abdulrasool
490c528104 Windows: add some defines from WinUser.h
Add the windows message queue status flags macros.  This should allow
the use of the macros when writing Windows code.
2023-06-12 07:34:36 -07:00
Doug Gregor
bcb01ce659 Merge pull request #66482 from DougGregor/requestify-has-storage
Requestify `AbstractStorageDecl::hasStorage()`.
2023-06-11 22:06:51 -07:00
Doug Gregor
1209ef89ec Ensure that macros within init accessors are expanded early enough
Now that we've made accessor macro expansion more lazy, ensure that
when querying for init accessors (e.g., to build a memberwise
initializer), we also expand any accessor macros that might produce an
init accessor.

This is a partial step toward the real goal, which is that
`AbstractStorageDecl::getAccessor()` should lazily expand macros if
needed.

Update the Observable macro to document that it produces an `init`
accessor.
2023-06-11 08:48:43 -07:00
Yuta Saito
97ac3985e2 [Concurrency] Fix signature mismatch of _startTaskOnMainActor
The function is defined in Task.cpp with a void return type, but
referenced in Task.swift with an pointer return type.
2023-06-11 12:29:11 +00:00
Yuta Saito
00705b4b2a [Concurrency] Fix calling convention mismatch in AsyncStream
Functions defined in AsyncStream.cpp are called from Swift with swiftcc
but are defined with the C calling convention.
2023-06-11 12:26:52 +00:00
Doug Gregor
a72fb83034 Requestify AbstractStorageDecl::hasStorage().
The `hasStorage()` computation is used in many places to determine the
signatures of other declarations. It currently needs to expand accessor
macros, which causes a number of cyclic references. Provide a
simplified request to determine `hasStorage` without expanding or
resolving macros, breaking a common pattern of cycles when using
macros.

Fixes rdar://109668383.
2023-06-10 08:28:06 -07:00
Yuta Saito
3198412db0 [wasm][stdlib] Fix return-address strategy selection
__GNUC__ can be defined on Wasm targets as well, so we need to check
__wasm__ first.
2023-06-10 10:15:34 +00:00
Yuta Saito
8124738fc2 [stdlib] Fix calling convention mismatch for debugger utility functions
The functions `swift_retainCount`, `swift_unownedRetainCount`, and
`swift_weakRetainCount` are declared in `HeapObject.h` as using
the C calling convention, but the Swift declarations referenced them
by `@_silgen_name`, which uses the Swift calling convention. This
patch fixes the mismatch without any ABI/API breakage by calling the
utility functions through C interop.
2023-06-10 07:40:50 +00:00
Dario Rexin
91d547f982 [Runtime] Properly handle unaligned reads in readTagBytes for layout strings (#66506) 2023-06-09 23:02:34 -07:00
Hiroshi Yamauchi
50ef384f88 Fix the swift-inspect dump-generic-metadata operation.
ReflectionContext::allocationMetadataPointer() was reading the
metadata pointer from a wrong offset because of the out-of-sync struct
layouts and dump-generic-metadata was not working correctly.

This change resync's the layouts and adds a static_assert to verify
that the offsets match between GenericMetadataCacheEntry and
GenericCacheEntry.
2023-06-09 18:33:06 -07:00
Philippe Hausler
4d1d8a9de5 [Observation] Add property definite initialization support (#65984)
* [Observation] Transition to peer macros instead of arbitrary members

* [Observation] Lift the initializer requirement by utilizing init accessors for fully formed definite initialization

* [Observation] Gate enabling of peer macros by flag

* [Observation] Enable feature for InitAccessors in the observation tests

* [Observation] Add tests to validate memberwise and definite initialization
2023-06-09 15:15:39 -07:00
Alastair Houghton
be7725f0fd [Backtracing][Linux] Include declarations for gettid() and tgkill().
Older glibc doesn't include these.  Nor does Musl, it seems.  The
previous fix put the gettid() declaration too far down the file.

rdar://110417355
2023-06-09 09:04:27 +01:00
Alastair Houghton
e6ca3f0469 Merge pull request #66449 from al45tair/eng/PR-110452324
[Backtracing][Linux] Replace regex with ProcMapsScanner.
2023-06-09 08:25:30 +01:00
Egor Zhdan
57bf922d18 Merge pull request #66425 from apple/egorzhdan/cxxstdlib-darwin-dependency
[cxx-interop] Declare CxxStdlib dependency on Darwin when building both
2023-06-08 15:59:09 +01:00
Alastair Houghton
d396656400 [Backtracing][Linux] Replace regex with ProcMapsScanner.
We were using a regular expression to scan `/proc/<pid>/maps`, but we
shouldn't really do that because it breaks non-bootstrapped builds.

rdar://110452324
2023-06-08 15:53:49 +01:00
Yuta Saito
2410da4259 [static-stdlib] Move static-executable-args.lnk under stdlib/public/Resources/linux
This is a preparatory change for adding a static executable support for WASI
2023-06-08 11:46:18 +00:00
Alastair Houghton
77de53b944 [Backtracing][Linux] Use syscall() to call gettid().
Older versions of Linux don't have gettid() in their headers, so
use syscall() to call it instead.

rdar://110417355
2023-06-07 21:24:32 +01:00
Egor Zhdan
60c91aa90a [cxx-interop] Declare CxxStdlib dependency on Darwin when building both
rdar://108188270
2023-06-07 20:17:24 +01:00
Alastair Houghton
861fd2fb53 Merge pull request #66406 from al45tair/eng/PR-110371557
[Backtracing] Use stderr by default unless interactive.
2023-06-07 16:52:39 +01:00
Doug Gregor
1ddecc00cc Merge pull request #66403 from DougGregor/remove-option-set 2023-06-07 06:49:39 -07:00