Commit Graph

219 Commits

Author SHA1 Message Date
Rick van Voorden
f8ae46b3f3 [inclusive-language] changed sanity to soundness 2024-01-25 18:18:02 -08:00
Mike Ash
f2a0dbb471 [Test] Temporarily disable genericMetadataBuilder.swift on ARM64e.
The validation is getting confused by ptrauth. Disable the test there while we fix it.

rdar://121029024
2024-01-16 10:33:37 -05:00
Mike Ash
f5b25776a0 [Test] Fix genericMetadataBuilder.swift requirements.
It requires executable_test and a just-built stdlib.

rdar://120908563
2024-01-12 12:38:39 -05:00
Mike Ash
29c350e813 [Runtime] Create an external generic metadata builder.
Create a version of the metadata specialization code which is abstracted so that it can work in different contexts, such as building specialized metadata from dylibs on disk rather than from inside a running process.

The GenericMetadataBuilder class is templatized on a ReaderWriter. The ReaderWriter abstracts out everything that's different between in-process and external construction of this data. Instead of reading and writing pointers directly, the builder calls the ReaderWriter to resolve and write pointers. The ReaderWriter also handles symbol lookups and looking up other Swift types by name.

This is accompanied by a simple implementation of the ReaderWriter which works in-process. The abstracted calls to resolve and write pointers are implemented using standard pointer dereferencing.

A new SWIFT_DEBUG_VALIDATE_EXTERNAL_GENERIC_METADATA_BUILDER environment variable uses the in-process ReaderWriter to validate the builder by running it in parallel with the existing metadata builder code in the runtime. When enabled, the GenericMetadataBuilder is used to build a second copy of metadata built by the runtime, and the two are compared to ensure that they match. When this environment variable is not set, the new builder code is inactive.

The builder is incomplete, and this initial version only works on structs. Any unsupported type produces an error, and skips the validation.

rdar://116592420
2024-01-11 09:15:02 -05:00
Doug Gregor
b9c5aca15f Enable SE-0413 "Typed Throws" by default 2024-01-02 15:34:07 -08:00
Alastair Houghton
3d9533de0d Merge pull request #69570 from al45tair/eng/PR-117470489
[Linux] Disable fatalError() backtraces when the runtime backtracer is active.
2023-11-09 17:53:53 +00:00
Alejandro Alonso
8ac7f0b10f Merge pull request #69138 from Azoy/generics-are-hard
[Runtime] Refactor _gatherWrittenGenericParameters
2023-11-06 19:27:54 -08:00
Alejandro Alonso
d73c812a2d Simplify _gatherWrittenGenericParameters 2023-11-06 12:51:06 -08:00
Alejandro Alonso
a0c8465f0c Refactor _gatherWrittenGenericParameters
Fix some bugs
2023-11-06 10:31:20 -08:00
Alastair Houghton
d84c47121a [Backtracing] Disable backtracer for Runtime/backtrace test.
The Runtime/backtrace test is a test of the fatalError() backtracer,
which gets turned off when we have the new backtracer enabled.  So,
to make this test work, we need to turn off the new backtracer.

rdar://117470489
2023-11-01 13:45:17 +00:00
Doug Gregor
1b42ca3673 Handle any Error and Never thrown error types during runtime uniquing.
When forming runtime metadata for a function type that has either `any
Error` or `Never` as the specified thrown error type, drop the thrown
error type and normalize down to (untyped) `throws` or non-throwing,
as appropriate.
2023-10-29 19:29:09 -07:00
Doug Gregor
40e07cf900 [Typed throws] IR generation and runtime support for function type metadata
Extend function type metadata with an entry for the thrown error type,
so that thrown error types are represented at runtime as well. Note
that this required the introduction of "extended" function type
flags into function type metadata, because we would have used the last
bit. Do so, and define one extended flag bit as representing typed
throws.

Add `swift_getExtendedFunctionTypeMetadata` to the runtime to build
function types that have the extended flags and a thrown error type.
Teach IR generation to call this function to form the metadata, when
appropriate.

Introduce all of the runtime mangling/demangling support needed for
thrown error types.
2023-10-29 09:12:32 -07:00
Alejandro Alonso
de8233a5d6 Revert "Merge pull request #68844 from Azoy/gather-no-parameters"
This reverts commit ccaf427fc3, reversing
changes made to bf45c55530.
2023-10-10 19:36:20 -07:00
Alejandro Alonso
ccaf427fc3 Merge pull request #68844 from Azoy/gather-no-parameters
[Runtime] Wrap _checkGenericRequirements for _instantiateCheckedGenericMetadata
2023-10-10 11:08:33 -07:00
Alejandro Alonso
3ddec4fd83 Wrap _checkGenericRequirements instead for _instantiateCheckedGenericMetadata 2023-10-09 15:02:29 -07:00
Karl Wagner
ab4f80ed95 [SE-0404] Allow protocols to be nested in non-generic contexts 2023-10-06 21:04:03 +02:00
Kavon Farvardin
54e5205194 Merge pull request #68600 from kavon/optional-try-coercion-bug-v2
[SILGen] fix SR-14882: Assertion failed: (!concreteBuffer && "concrete buffer already formed?!")
2023-09-19 09:42:04 -07:00
Kavon Farvardin
583f127de7 fix [SR-14882]: Assertion failed: (!concreteBuffer && "concrete buffer already formed?!")
The problem was that in the by-address emission, we were calling
 `getAddressForInPlaceInitialization` twice, triggering the assert.

The first time in `emitExprInto` for the normal result case.

The second time to obtain the address again when generating the
catch block to inject a `.none` into that same address.

This patch does a light refactoring to more closely mirror
`visitOptionalEvaluationExpr`, which avoids calling the asserting method.

fixes rdar://80277465
2023-09-18 15:41:43 -07:00
Alejandro Alonso
80187e8096 Expect caller heap pack and rename
Fix comment
2023-09-06 21:37:00 -07:00
Alejandro Alonso
3dbad6e1fd Add a runtime function to check type creation 2023-09-06 11:32:22 -07:00
Mike Ash
b249d3bea5 [Test] Reenable disabled test in associated_type_demangle_private.swift.
This was disabled due to a weird failure on iOS 10, which is no longer a supported target.

rdar://97996884
2023-07-14 15:38:46 -04:00
Daniel Rodríguez Troitiño
8f0382c109 [test] Replace swift_obj_root for alternates that work in LLVM unified builds (#66167)
In LLVM unified builds `%swift_obj_root` points to `<LLVM build dir>/tools/swift`,
and folders like `bin`, `lib` and `share` are not under `swift_obj_root`, which
makes some tests fail.

For the cases in which `%swift_obj_root/lib` was used, replace it by
using `%swift-lib-dir` instead. Replicate `%swift-lib-dir` to create
`%swift-bin-dir` and `%swift-share-dir`, and use those instead of
`%swift_obj_root/bin` and `%swift_obj_root/share`.

This alternates work both in Swift build-script builds and also in LLVM
unified builds.
2023-05-26 08:39:31 -07:00
swift-ci
eaf53dfee2 Merge pull request #65107 from mikeash/reenable-custom-rr-test
[Test] Reenable custom_rr_abi.swift.
2023-05-12 11:22:17 -07:00
Mike Ash
17c32f4997 [Test] Reenable custom_rr_abi.swift.
CI has updated macOS and we should no longer have the issue of dyld stubs using our nonstandard argument registers.

rdar://102912772
2023-05-11 17:30:55 -04:00
Yuta Saito
a9998653e9 [Test] Disable concurrent test under single thread assumption 2023-04-29 13:47:24 +00:00
Alastair Houghton
9833e09b58 [Tests] Disable path lookup test for OS stdlib.
Path lookup needs the new stdlib.

rdar://107399270
2023-03-30 09:39:40 +01:00
Konrad `ktoso` Malawski
41f99fc2ae [Executors][Distributed] custom executors for distributed actor (#64237)
* [Executors][Distributed] custom executors for distributed actor

* harden ordering guarantees of synthesised fields

* the issue was that a non-default actor must implement the is remote check differently

* NonDefaultDistributedActor to complete support and remote flag handling

* invoke nonDefaultDistributedActorInitialize when necessary in SILGen

* refactor inline assertion into method

* cleanup

* [Executors][Distributed] Update module version for NonDefaultDistributedActor

* Minor docs cleanup

* we solved those fixme's

* add mangling test for non-def-dist-actor
2023-03-15 23:42:55 +09:00
Saleem Abdulrasool
9df349e0da test: adjust Runtime Paths test for unified builds
When building the toolchain in unified mode, we fail to search for
headers and libraries.  Adjust the invocation to account for the layout
differences.
2023-03-09 13:33:22 -08:00
Alastair Houghton
fdb010433d [Remote Test] Fix remote-run to process environment variables.
`remote-run` should look in the environment for input/output paths as
well as considering command line arguments.

With this change, `test/Runtime/Paths.cpp` should work for remote testing
and device testing.

rdar://106294557
2023-03-07 16:01:10 +00:00
Alastair Houghton
35a2f17d35 [Backtracing] Add missing void cast to the paths test.
We need to cast in order to call `free()`.

rdar://103071801
2023-03-01 13:43:15 +00:00
Alastair Houghton
69bad8cb09 [Backtracing] Rename a couple of functions, some comment changes.
Renamed a couple of functions following review feedback.  Also added some
extra words to the comments.

rdar://103071801
2023-03-01 13:43:15 +00:00
Alastair Houghton
f02f62f1e3 [Backtracing] Add support for looking up paths for auxiliary executables.
We need to be able to locate `swift-backtrace` relative to the current
location of the runtime library.

This needs to work:

* In a Swift build directory.
* On Darwin, where we're installed in /usr/lib/swift and /usr/libexec/swift.
* On Linux, where we're in /usr/lib/swift/linux and /usr/libexec/swift/linux.
* On Windows, where we may be in a flat directory layout (because of limitations
  of Windows DLL lookups).

rdar://103071801
2023-03-01 13:43:15 +00:00
Mike Ash
80bb78d01d [Test] Change the -target line on some tests to use a minimum of macOS 10.13.
These tests were targeting 10.9 or 10.10, but the minimum deployment target now supported by Xcode is 10.13. Bump them up to match:

test/Concurrency/Backdeploy/linking.swift
test/Concurrency/Backdeploy/linking_maccatalyst.swift
test/Runtime/stable-bit-backward-deployment.swift
2023-02-21 13:48:33 -05:00
Mike Ash
591e3a371c [Test] Fix deinit_escape test.
When compiled with optimizations, the compiler saw that C() doesn't escape and stack promoted it, which breaks the check. Deliberately escape the object into a global array beforehand to ensure it has to be on the heap.

rdar://103369708
2022-12-15 13:22:28 -05:00
Mike Ash
108f7805e5 [Runtime] Fatal error if self escapes from deinit.
When deallocating a class instance, we check the retain count of the instance and error if it's greater than 1.

Self is allowed to be temporarily passed to other code from deinit, but there's no way to extend the lifetime of the object. Retaining it no longer extensd the lifetime. If self escapes from deinit, the result is a dangling pointer and eventual crash.

Instead of crashing randomly due to a dangling pointer, crash deliberately when destroying an object that has escaped.

rdar://93848484
2022-12-07 12:42:41 -05:00
Evan Wilde
d01760a4df Disable custom_rr_abi.swift
Failing in Swift Incremental RA - macOS - Apple Silicon

https://ci.swift.org/job/oss-swift-incremental-RA-macos-apple-silicon/2266/

```
[ RUN      ] CustomRRABI.retain
stderr>>> CRASHED: SIGSEGV
the test crashed unexpectedly
[     FAIL ] CustomRRABI.retain
CustomRRABI: Some tests failed, aborting
UXPASS: []
FAIL: ["retain"]
SKIP: []
To debug, run:
$ /Users/ec2-user/jenkins/workspace/oss-swift-incremental-RA-macos-apple-silicon/build/buildbot_incremental/swift-macosx-arm64/test-macosx-arm64/Runtime/Output/custom_rr_abi.swift.tmp/a.out --stdlib-unittest-in-process --stdlib-unittest-filter "retain"
```

rdar://102912772
2022-12-02 11:47:36 -08:00
Mike Ash
fefe33fd7d [Runtime] Add missing bridgeObjectRR_xN entrypoints.
We're supposed to expose bridgeObjectRetain/Release_xN variants, but they were missing. This fixes the custom_rr_abi.swift test. Also remove the redundant extern "C" on the entrypoint definitions, which fixes some warnings.

rdar://102793667 rdar://102783074
2022-11-30 10:50:14 -05:00
Mike Ash
58a519a5c1 [Test] Disable custom_rr_abi test until we can fix it. (#62304) 2022-11-29 14:07:37 -08:00
Mike Ash
b677b5676a [Runtime] Add register-specific entrypoints for retain/release calls on ARM64.
This will allow emitted code to condense a sequence like:

    mov x0, x21
    bl swift_retain

To:

    bl swift_retain_x21

Saving code size.

rdar://98884198
2022-11-15 09:53:49 -05:00
Mike Ash
f8e8fa0dc8 [Test] Re-fix Runtime/protocol_conformance_collision.swift.
rdar://98989894
2022-10-07 12:42:45 -04:00
Evan Wilde
64b19f7f45 Backdeploy task_wait_future fix to Swift 5.6 (#61254)
* Backdeploy swift_task_future_wait

This patch adds the implementation for `swift_task_future_wait`
entrypoint to the backdeploy library.

This involves pulling in `AsyncTask::waitFuture`, which relies on a fair
bit.

Please note, this pulls in the `StaticMutex` implementation from Swift
5.6. There are some challenges here. The concurrency version of the
`StaticMutex` involves a fairly nasty set of ODR violations in the
normal setup. See `public/Concurrency/Mutex.cpp`, which includes the
Mutex implementations cpp files directly, while defining a single macro
to replace the implementation of swift::fatalError with
swift_concurrency_fatalError. We only need the concurrency mutex (at
least for now), so I have hard-coded the `swift_concurrency_fatalError`
version into this library. If we should need the other implementation,
we are forced to include ODR-related undefined behavior.

We need symbols from C++, so I've added an implicit linker flag whenever
the static library is used, namely, it passes `-lc++` to the linker.
Since we only backdeploy on Apple platforms, this should be fine.

Some of the platform runtimes we need to backdeploy to have the
enter/exitThreadLocalContext functions defined, while others don't. We
define our own backdeploy56 shim function that dlsym's the function
pointer for these symbols if we have exclusivity checking available.
Otherwise, it doesn't do anything. If concurrency exclusivity checking
is available, we'll use it, otherwise we wont'.

The same dlsym check is done for `swift_task_escalate`. Not all
platforms we need to backdeploy to have a concurrency runtime. The
symbols that do need to use pieces of the concurrency runtime should not
be getting hit when deploying to systems that don't have concurrency. In
the event that you've gotten around the language blocking you from
calling these symbols and you've managed to call concurrency pieces
without using concurrency, we'll abort because something is seriously
wrong.

* Backdeploy swift_task_future_wait_throwing

Drop the remaining pieces in for adding
`swift_task_future_wait_throwing`.

* Apply task_wait_future fix

Actually apply the fix from ef80a315f8.

This deviates slightly from the original patch.

AsyncTask::PrivateStorage::_Status() does not exist in the Swift 5.6
library. Instead I am using `AsyncTask::PrivateStorage::Status`.

* Workaround missing compiler-rt linking

Working around the missing link against compiler-rt in these test.
They are a bit brittle as if anything in them uses compiler-rt, they
will start failing. The backdeploy 5.6 library uses some symbols from
compiler-rt, thus causes them to fail to link.

Disabling the runtime compatibility version checking to avoid these
symbols. This should be fine for the MicroStdlib test, but we should fix
'%target-ld' to handle this better in the future.
rdar://100868842
2022-10-07 09:36:17 -07:00
Mike Ash
ed7b7ca854 [Test] Don't test concurrentTypeByName.swift against old, unfixed runtimes. 2022-10-03 15:08:21 -04:00
Mike Ash
e15783ecd4 [Runtime] Fix concurrent lookups of types by name (again).
Fix a potential false positive if we check a class for a protocol conformance and its superclasses aren't yet instantiated.

This was partially fixed before, but we were incorrectly saying that all superclasses had been instantiated if they had been instatiated by the LAST check in conformsToProtocol. That left us open for a possible false positive in an earlier check to go unnoticed.

This change fixes it by checking for uninstantiated superclasses after each iteration over superclasses, not just the last one.

This change also makes the concurrentTypeByName test much more robust. The original test caught this bug only rarely, but the new one catches it it reliably. We now look up 1000 types per test run. Testing locally, we typically hit the race after less than 100 types.

rdar://82364236
2022-09-23 16:45:30 -04:00
Anthony Latsis
1b121e5527 Merge pull request #60921 from AnthonyLatsis/migrate-test-suite-to-gh-issues-18
Gardening: Migrate test suite to GH issues p. 18
2022-09-09 12:07:51 +03:00
Mike Ash
1220321756 [Test] Fix protocol_conformance_collision.swift.
Use 2021 OS versions instead of far-future OS versions. We have versions with the fix now, so we don't need the far-future versions. Using them breaks things when building against a newer SDK and running on an older OS, because the system assumes stuff on the newer OS is available when it isn't.
2022-09-02 12:16:01 -04:00
Anthony Latsis
4002bd5217 Gardening: Migrate test suite to GH issues: Runtime 2022-09-02 06:12:45 +03:00
Mike Ash
82e479896d [Test] Reenable associated_type_demangle_private.swift.
The "nested private generic types in associated type witnesses" test is failing in back-deployment tests. Disable that one test, and re-enable the rest.
2022-08-09 10:33:08 -04:00
Meghana Gupta
a8dbc5f40b Merge pull request #60365 from meg-gupta/disableruntimetest
Disable test associated_type_demangle_private.swift failing in CI
2022-08-03 09:49:06 -07:00
Meghana Gupta
18411bf116 Disable test associated_type_demangle_private.swift failing in CI 2022-08-02 15:05:07 -07:00
Mike Ash
5f5caebf04 [Test] Reenable "failed to demangle" portion of associated_type_demangle_private.swift.
This test was disabled a while ago but the problem seems to have been fixed sometime since then.

rdar://51959305
2022-07-29 15:05:36 -04:00