Commit Graph

21434 Commits

Author SHA1 Message Date
Dario Rexin
82d7260ee1 Merge pull request #78818 from drexin/wip-143401725
[Runtime] Improve performance and memory footprint of compatibility o…
2025-01-24 15:11:19 -08:00
Alejandro Alonso
9af4a76b52 Use tuple comparison 2025-01-23 15:55:19 -08:00
Alejandro Alonso
8500d0cba1 Less than is a static function.. 2025-01-23 13:09:47 -08:00
Dario Rexin
96d5ed22db [Runtime] Improve performance and memory footprint of compatibility overrides
rdar://143401725

Replacing the (non-inlined) call to `swift_once` with a relaxed atomic significantly improves the generated code and reduces the memory footprint. The mechanism itself now does not cause a stack frame to be generated and the expected case (no override) should be perfectly predicted and executed in straight line code. The override case should also be well predicted, with only two branches on the same value.
2025-01-23 13:06:40 -08:00
Alejandro Alonso
22d5acd207 Fix logic around comparison 2025-01-23 11:55:21 -08:00
Alejandro Alonso
d5b131a436 Add Comparable conformance to WordPair 2025-01-23 10:08:52 -08:00
John McCall
623d063ad7 Fix remangling isolated(any) function types from type metadata. 2025-01-22 21:41:14 -05:00
Robert Widmann
0f94164d3b Replace Hand-Rolled MAX/MIN with std::max/std::min
We're using C++ 14+ at least now across the project so these should not be necessary. It's also kind of wild that the definitions we had across different subsystems had different definitions.
2025-01-22 11:18:35 -07:00
Mike Ash
29efab6ccc [Concurrency] Fix Task.sleep on values greater than Int64.max.
In the Dispatch implementation, clamp the delay to INT64_MAX. Swift's nanoseconds value is unsigned, but we ultimately use it with dispatch_time, which takes a signed int64_t. Extremely large values get interpreted as negative, which results in not sleeping.

INT64_MAX nanoseconds is about 292 years, so it should be difficult to notice a practical effect from sleeping for less time than requested due to the clamping.

rdar://143278824
2025-01-22 12:28:18 -05:00
Tony Allevato
400b21fc82 Merge pull request #78808 from allevato/strictness-fixes
[NFC] Include `<cstdlib>` and `<cstdint>` where necessary.
2025-01-22 11:54:45 -05:00
Alastair Houghton
12aee901c2 [Backtracing] Fix compact image map decoding bug.
If we ended up with a `/` at the beginning of a string segment, we
were erroneously not adding to the expansion dictionary when we
should have been.

rdar://124913332
2025-01-22 16:35:44 +00:00
Gábor Horváth
4d24b7d888 Merge pull request #78709 from swiftlang/gaborh/span-lifetimebound-overload
[cxx-interop] Support transforming lifetimebound spans
2025-01-22 14:21:57 +00:00
Tony Allevato
3bd71c9d62 [NFC] Include <cstdlib> and <cstdint> where necessary.
Our Bazel builds have become more strict about libc++
dependencies recently, so these are required to pick up
declarations of `malloc` and `uint32_t`, respectively.
2025-01-22 07:47:16 -05:00
Karoy Lorentey
d52ed4c602 [doc] Atomic.add, .subtract: Add note on codegen 2025-01-21 15:58:32 -08:00
Alastair Houghton
2300577b56 [Backtracing] Fix symbol lookup on Linux.
Also removed a spurious `print()` that got left in by accident,
and disabled the `CodableBacktrace.swift` test on Linux since we
need Foundation and we don't have it there.

rdar://124913332
2025-01-21 19:05:08 +00:00
Alejandro Alonso
11fbd94668 Merge pull request #78664 from Azoy/unicode-16
[stdlib] Unicode 16
2025-01-21 09:29:35 -08:00
Gabor Horvath
8c03a31d65 [cxx-interop] Support transforming lifetimebound spans
This PR adds basic support for storing lifetime dependence information,
transform Span return types, and generate lifetime annotations.

rdar://139074571
2025-01-21 10:51:04 +00:00
Allan Shortlidge
e45f671e5f Compatibility56: Suppress some -Wcast-function-type-mismatch warnings. 2025-01-20 20:25:40 -08:00
Allan Shortlidge
58a97f1603 Runtime: Suppress a -Winvalid-offsetof warning. 2025-01-20 20:22:51 -08:00
Saleem Abdulrasool
6135d506a7 Merge pull request #78710 from compnerd/pragma-complete
runtime: sprinkle some linker pragmas to autolink
2025-01-20 13:14:59 -08:00
David Smith
600dcd0828 Expose immortal String initialization for Foundation (#78661) 2025-01-19 07:43:13 -08:00
Saleem Abdulrasool
e9ec50132f runtime: sprinkle some linker pragmas to autolink
This prepares the runtime to be closed with its dependencies when
performing static linking. The pragma ensures that the linker will
automatically pick up the dependent libraries avoiding the need to
explicitly add the dependencies.
2025-01-17 08:58:42 -08:00
Alastair Houghton
dd84241d36 [Backtracing] CMake fixes.
Remove a `-disable-implicit-backtracing-module-import` that was added
in `Runtimes/Core/CMakeLists.txt`, and also remove the reference to
`swiftCxxStdlib` from `RuntimeModule` as that causes the build to fail
when attempting to build the static version of `swift-backtrace` on
Linux.

rdar://124913332
2025-01-17 14:31:16 +00:00
Alastair Houghton
4a7ca682d5 [Backtracing] Fix dependency for static swift-backtrace.
We'd missed renaming a CMake variable, which led to link errors.

rdar://124913332
2025-01-17 10:09:37 +00:00
Alastair Houghton
4826d60bc2 [Backtracing] Implement Codable for Backtrace.
Add support for Codable to Bactkrace.

rdar://124913332
2025-01-17 10:09:37 +00:00
Alastair Houghton
ffda416d36 [Backtracing] Add support for repeats to Compact Backtrace Format.
This lets us repeat a frame over and over; it only works for a single
frame, but that's the common case for infinite recursions.

rdar://124913332
2025-01-17 10:09:37 +00:00
Alastair Houghton
348a325d2a [Backtracing] Also try CFStringGetCharactersPtr when converting CFStrings.
We already try using `CFStringGetCStringPtr` to see if we can get ASCII;
we should also try `CFStringGetCharactersPtr` as the native encoding of
`CFNSString` is very often UTF-16.  While we're at it, try asking explicitly
for UTF-8 as well.  That won't work for `CFNSString` because AFAIK it's
currently never encoded that way, but it might work if something hands us
a Swift-backed string or if some future implementation of `CFString`
happens to support UTF-8 encoded data.

rdar://124913332
2025-01-17 10:09:36 +00:00
Alastair Houghton
0e3e9efcd3 [Backtracing] Add ImageMap instead of just using an Array.
We want to be able to efficiently serialise lists of images, and to do so
it makes most sense to create a separate `ImageMap` type.  This also provides
a useful place to put methods to e.g. find an image by address or by build
ID.

rdar://124913332
2025-01-17 10:09:36 +00:00
Alastair Houghton
760cc57bef [Backtracing] Rename _Backtracing to Runtime.
Move the backtracing code into a new Runtime module.  This means renaming
the Swift Runtime's CMake target because otherwise there will be a name
clash.

rdar://124913332
2025-01-17 10:09:36 +00:00
Alastair Houghton
18496c5626 [Backtracing] Remove support for implicit import of _Backtracing.
We're going to rename the module to Runtime, and it isn't going to be an
implicit import, so we don't need any of this.

rdar://124913332
2025-01-17 10:09:36 +00:00
finagolfin
6b2fb2e4b4 Merge pull request #78678 from finagolfin/icu
Linux: don't link libicu in static executables, as it is no longer built separately
2025-01-17 11:45:11 +05:30
Garth Snyder
610d07e9ed [stdlib] Fix doc comment refs to subranges(where:), now called indices(where:) (#78512)
Doc comments for DiscontiguousSlice, MutableCollection, RangeSet, and
RangeReplaceableCollection all refer to a Collection method subranges(where:)
which is intended to return a RangeSet of matching ranges. I believe this is
likely an old or formerly-contemplated spelling of the method now known as
indices(where:). This commit changes "subranges" to "indices".
2025-01-16 13:54:02 -08:00
Alastair Houghton
ad78a86ca9 [Backtracing] Don't include things inside a namespace.
We shouldn't be including `<stdint.h>` inside the namespace.
2025-01-16 14:38:22 +00:00
Finagolfin
abe9225065 Linux: don't link libicu in static executables, as it is no longer built separately
This was dropped in #40340.
2025-01-16 19:47:52 +05:30
Alastair Houghton
d6447284f8 Merge pull request #78514 from al45tair/eng/PR-137201928
[Backtracing] Update module maps.
2025-01-16 11:21:33 +00:00
Alejandro Alonso
708d72d2c3 Update tests for 6.1 Unicode 16 stdlib 2025-01-15 14:09:57 -08:00
Alejandro Alonso
d3146e37b3 Update Scalar names for Unicode 16 2025-01-15 14:08:30 -08:00
Alejandro Alonso
1f74aa1634 Update grapheme breaking logic to support Unicode 16 2025-01-15 14:08:18 -08:00
Alejandro Alonso
4e087653f2 Update Unicode data files in stdlib 2025-01-15 14:07:46 -08:00
Alastair Houghton
d3352ef272 [Backtracing] memserver_req/resp and thread are only for Linux.
These types only exist on Linux, so need to be conditionalised here.

rdar://137201928
2025-01-15 11:21:25 +00:00
Guillaume Lessard
c9c5253fb3 [stdlib] fix getting eager-lazy-bridged buffer 2025-01-14 16:18:24 -08:00
Evan Wilde
6dcf7c64cf Merge pull request #78617 from etcwilde/ewilde/value-generic-types
Values in generic types are only available in 6.2
2025-01-14 09:59:56 -08:00
Alastair Houghton
82076d600d [Backtracing] Fix runtime symbols.
The runtime functions must be marked `extern "C"` because the symbols
are not mangled when exported.

rdar://137201928
2025-01-14 16:48:04 +00:00
Alastair Houghton
f0974bd227 [Backtracing] Turn off MemberImportVisibility.
Also fixed a couple of other minor issues preventing this PR from
building on its own.

rdar://137201928
2025-01-14 12:13:58 +00:00
Saleem Abdulrasool
66921730ee Merge pull request #78251 from andrurogerz/swift-runtime-debugvars-android
[Runtime] load debug env vars from Android system properties
2025-01-13 13:14:04 -08:00
Evan Wilde
6f823dcebf Fix Slab availability annotation
Values in generic types are only available as part of 6.2, not 6.1.
Fix the availability annotations on the slab type to match.

rdar://142781302
2025-01-13 12:42:20 -08:00
Henrik G. Olsson
d7bd76e9f1 [Swiftify] Add return pointer support (#78571)
* Import __counted_by for function return values

Instead of simply passing a parameter index to _SwiftifyInfo, the
_SwiftifyExpr enum is introduced. It currently has two cases:
 - .param(index: Int), corresponding to the previous parameter index
 - .return, corresponding to the function's return value.

ClangImporter is also updated to pass this new information along to
_SwiftifyImport, allowing overloads with buffer pointer return types to
be generated. The swiftified return values currently return Span when
the return value is marked as nonescaping, despite this not being sound.
This is a bug that will be fixed in the next commit, as the issue is
greater than just for return values.

* Fix Span variant selection

There was an assumption that all converted pointers were either
converted to Span-family pointers, or UnsafeBufferPointer-family
pointers. This was not consistently handled, resulting in violating the
`assert(nonescaping)` assert when the two were mixed. This patch removes
the Variant struct, and instead each swiftified pointer separately
tracks whether it should map to Span or UnsafeBufferPointer.
This also fixes return pointers being incorrectly mapped to Span when
marked as nonescaping.
2025-01-13 08:08:36 -08:00
Alejandro Alonso
09d122af7c Merge pull request #76438 from Azoy/vector
[stdlib] Slab
2025-01-12 10:36:25 -08:00
John McCall
11ff5b4348 Merge pull request #78576 from rjmccall/demangle-sending-result-with-function-isolation
Fix the demangling of sending result types when combined with isolation
2025-01-11 12:35:55 -05:00
John McCall
fa932e736c Fix the demangling of sending result types when combined with isolation
Fixes the immediate problem, but the presence of demangling code in the
runtime means that we'll need a follow-up to fix the compiler so that it
doesn't try to use the demangler to materialize metadata for function types
that have both isolation and a sending result.

rdar://142443925
2025-01-10 21:11:45 -05:00