Commit Graph

3151 Commits

Author SHA1 Message Date
Dario Rexin
591c2cbb65 [Runtime] Add entry for native swift objc reference to initWithTakeTable in CVW runtime
rdar://139708680

The entry was missing in the function table, causing runtime crashes.
2024-11-12 15:12:19 -08:00
Evan Wilde
e160e23dde [CMake] Connecting more flags and options
Making a more in-depth pass over the definition macros and flags in
SwiftSource.cmake _add_target_variant_swift_compile_flags.
These are only flags that actually matter for swiftCore though. This
does not include concurrency flags.
2024-11-12 11:31:10 -08:00
Tim Kientzle
694c533c7f Merge pull request #77496 from tbkka/tbkka-rdar138132321
[ObjC Bridging] Consistently bridge block types verbatim
2024-11-11 08:41:56 -08:00
Tim Kientzle
c262248a27 [ObjC Bridging] Consistently bridge block types verbatim
A `@convention(block)` closure in Swift is completely compatible with Objective-C
and does not need to be wrapped in a `__SwiftValue` box for use.

Previously, it was bridged verbatim when appearing by itself, but
could end up boxed when it went through array bridging.

The test verifies that:
* Objective-C does not see a `__SwiftValue` box
* Swift `type(of:)` does not see a `__SwiftValue` box
* Objective-C can actually call the closure

Resolves rdar://138132321
2024-11-08 13:49:21 -08:00
Dario Rexin
4ea0c9bbee Merge pull request #77431 from drexin/wip-138487964
[IRGen+Runtime] Fix tag bit mask handling for objc, unknown objects a…
2024-11-07 15:55:08 -08:00
Dario Rexin
3c7b556cf1 [IRGen+Runtime] Fix tag bit mask handling for objc, unknown objects and blocks
rdar://138487964

On platforms that don't have reserved bits in objc (including unknown) pointers, we use the spare bits for Swift enums, so they have to be masked out. Blocks don't have reserved bits on any platform.
2024-11-07 09:55:40 -08:00
Mike Ash
7ef7f99490 [Runtime] Weak-check _objc_supportsLazyRealization.
It may not be available at runtime even if it was present at build time, so add a WEAK_CHECK/WEAK_USE to it.
2024-11-06 15:47:15 -05:00
Dario Rexin
4e7ce5a058 [IRGen+Runtime] Differentiate between pure Swift and regular ObjC references in CVW
rdar://139106139

Regular ObjC references do not have unused bits or extra inhabitants for storing enum tags, because they may be tagged pointers. However, ObjC classes that are implemented in Swift do, so we must differentiate between the two.
2024-11-04 18:52:26 -08:00
Allan Shortlidge
12d72bee73 Merge pull request #77275 from tshortli/rebranch-warnings
Gardening: Address some new warnings
2024-10-29 20:17:30 -07:00
Allan Shortlidge
2de8e5afc2 Gardening: Address -Wunused-but-set-variable warnings. 2024-10-29 15:52:53 -07:00
Alejandro Alonso
82743d7427 Add TypeDecoding for Builtin.FixedArray 2024-10-28 17:29:03 -07:00
Dario Rexin
c67b0c73e1 Merge pull request #77197 from drexin/wip-138085348
[Runtime] Fix SwiftError handling in CVW runtime
2024-10-24 13:13:24 -07:00
Alastair Houghton
e030e37d3a [Backtracing] Fix macro test.
The `TARGET_OS_` macros are always defined; you need to test their
values.

rdar://137551812
2024-10-24 11:21:37 +01:00
Dario Rexin
edd9955673 [Runtime] Fix SwiftError handling in CVW runtime
rdar://138085348

Even though errors are ObjC boxes, they can't be tagged pointers and in fact may use that bit to store enum tags, so treating them like regular ObjC references here can cause ref count issues.
2024-10-23 17:31:11 -07:00
Joe Groff
4a12979584 Merge pull request #77188 from al45tair/eng/PR-137551812-ios-fix
[Backtracing] Fix iOS build.
2024-10-23 08:09:00 -10:00
Joe Groff
8242110bbe Merge pull request #76831 from jckarter/builtin-vector
Builtin.FixedArray
2024-10-23 05:20:21 -10:00
Alastair Houghton
95aef6c972 [Backtracing] Fix iOS build.
The new code needs to not build for iOS.

rdar://137551812
2024-10-23 15:49:15 +01:00
Joe Groff
a184782a38 Introduce a Builtin.FixedArray type.
`Builtin.FixedArray<let N: Int, T: ~Copyable & ~Escapable>` has the layout of `N` elements of type `T` laid out
sequentially in memory (with the tail padding of every element occupied by the array). This provides a primitive
on which the standard library `Vector` type can be built.
2024-10-22 16:21:45 -07:00
Alastair Houghton
2cc93cf7b0 [Backtracing] Bail out earlier for privileged binaries on macOS.
Also remove the code that deals with file descriptors; we will now
only start the backtracer for processes that have the get-task-allow
entitlement, which means that they've been specifically signed for
debugging, and *that* means that it is no longer critical to ensure
that unexpectedly inherited fds are closed.

rdar://137551812
2024-10-22 12:21:58 +01:00
Dario Rexin
2bcece3e52 [Runtime] Use aligned offset to compute new field offset for unmanaged properties in CVW
The original fix only added the field size to the unaligned offset, which is not correct.
2024-10-17 10:31:07 -07:00
Dario Rexin
0ec1f4b6ce Merge pull request #76799 from drexin/wip-137066879
[Runtime] Properly compute offset for unmanaged properties in generic…
2024-10-17 09:42:22 -07:00
Mike Ash
4c385e4334 Merge pull request #76797 from mikeash/isequal-nil
[Runtime] Handle nil parameter to -[SwiftObject isEqual:]
2024-10-02 17:51:43 -04:00
Erik Eckstein
5502373018 SIL: rename AssociatedTypeProtocolWitness -> AssociatedConformanceWitness in SILWitnessTable
To be consistent with the naming convention in the AST
2024-10-02 07:10:30 +02:00
Michael Gottesman
cb8e8b505a Fix syntax highlighting by changing how we include COMPATIBILITY_OVERRIDE_INCLUDE_PATH.
The way that we include COMPATIBILITY_OVERRIDE_INCLUDE_PATH freaks out the
syntax highlighting of editors like emacs. It causes the whole file to be
highlighted like it is part of the include string.

To work around this, this patch creates a separate file called
CompatibilityOverrideIncludePath.h that just includes
COMPATIBILITY_OVERRIDE_INCLUDE_PATH. So its syntax highlighting is borked, but
at least in the actual files that contain real code, the syntax highlighting is
restored.
2024-10-01 16:17:16 -07:00
Dario Rexin
a5bb53aee9 [Runtime] Properly compute offset for unmanaged properties in generic CVW instantiation
rdar://137066879

An unmanaged property does not map to an operation in CVW, instead it will be copied like primitive values. When instantiating the layout string, we correctly do not emit an operation, but we compute the offset to the next field as if we did. This is causing the offset to be incorrect and subsequent operations to be executed on the wrong address, causing crashes or other misbehavior.
2024-10-01 11:25:14 -07:00
Mike Ash
c928203780 [Runtime] Handle nil parameter to -[SwiftObject isEqual:]
The parameter is nullable, and isEqual: should always return nil in that case. We need to check for nil before doing anything else.

rdar://136825667
2024-10-01 14:05:39 -04:00
Joe Groff
4b3931c8ce Merge pull request #76734 from jckarter/atomic-layout-runtime
Runtime: Set 'is not bitwise borrowable' bit for raw layout types.
2024-09-30 05:53:43 -10:00
nate-chandler
ba8f8ea282 Merge pull request #76526 from nate-chandler/general-coro/20240906/1
[CoroutineAccessors] Initial framing.
2024-09-30 07:04:04 -07:00
Joe Groff
6e565b52ba Runtime: Set 'is not bitwise borrowable' bit for raw layout types.
When initializing metadata for layout-dependent raw layout types, set the
"is not bitwise borrowable" bit.
2024-09-27 11:27:47 -07:00
Mike Ash
0d747d4d2b Merge pull request #76498 from mikeash/lazy-realization-support
[Runtime] Support lazy ObjC realization of Swift classes.
2024-09-27 00:10:17 -04:00
Nate Chandler
091368ba21 [CoroutineAccessors] Added read.
The name is a placeholder for the mutating single-yield coroutine
accessor.
2024-09-26 18:10:39 -07:00
Nate Chandler
98a2e6a7df [CoroutineAccessors] Added modify.
The name is a placeholder for the mutating single-yield coroutine
accessor.
2024-09-26 18:10:39 -07:00
Tony Allevato
9279ddfd1b Merge pull request #76519 from allevato/various-fixes
[NFC] Small cleanup in stdlib/public/runtime.
2024-09-17 15:06:14 -04:00
Tony Allevato
c68c4333b9 [NFC] Small cleanup in stdlib/public/runtime.
These changes fix minor issues that cause compilation errors with our
C++ toolchain's stricter default settings:

* `Exception.cpp`: The return type of `__cxa_begin_catch` should be
  `void *`, not `void` (see https://libcxxabi.llvm.org/spec.html).
* `Leaks.mm`: `''` is not a valid C char literal; use `'\0'` instead.
2024-09-17 10:45:28 -04:00
Mike Ash
b7d7159782 [Runtime] Support lazy ObjC realization of Swift classes.
When the ObjC runtime indicates that it supports lazy realization, avoid forcing realization of classes while setting them up. This saves time and memory for classes that never touch the parts of the ObjC runtime that trigger realization

rdar://136102084
2024-09-16 17:12:26 -04:00
Mike Ash
b35a2a11f1 Merge pull request #76309 from mikeash/mirror-thin-metatypes
[Mirror] Handle fields of thin metatypes.
2024-09-11 10:52:05 -04:00
Mike Ash
7d3451316a [Mirror] Handle fields of thin metatypes.
Fields containing metatypes with no possible subtypes are thin i.e. they have no storage. There is only one possible value they can have: the corresponding type. Mirror attempted to copy the nonexistent field value from the nonexistent storage, producing garbage. Instead, special-case thin metatypes and copy the instance type out of the metatype metadata rather than trying to copy it from the field.

rdar://108280543
2024-09-06 10:38:25 -04:00
Alejandro Alonso
f431e0064a Fix abi test for new initRaw runtime function 2024-09-04 15:13:51 -07:00
Alejandro Alonso
3d8a9d4554 Implement same type checking at runtime 2024-09-04 15:13:51 -07:00
Alejandro Alonso
f2f82a7de6 Add initRawStructMetadata2 for safety 2024-09-04 15:13:51 -07:00
Alejandro Alonso
8a9303b3cf Consistently negate the value from demangling 2024-09-04 15:13:50 -07:00
Alejandro Alonso
c1dd957c75 Use intptr_t more consistently 2024-09-04 15:13:50 -07:00
Alejandro Alonso
9903d71f91 More changes to get off of ssize_t 2024-09-04 15:13:49 -07:00
Alejandro Alonso
22349bcfb9 Use intptr_t instead of ssize_t and more test fixes 2024-09-04 15:13:49 -07:00
Alejandro Alonso
4f07c060b7 Future proof the initRawStructMetadata entrypoint 2024-09-04 15:13:46 -07:00
Alejandro Alonso
7c85261a77 Add runtime support 2024-09-04 15:13:27 -07:00
Alejandro Alonso
75c2cbf593 Implement value generics
Some requirement machine work

Rename requirement to Value

Rename more things to Value

Fix integer checking for requirement

some docs and parser changes

Minor fixes
2024-09-04 15:13:25 -07:00
Mike Ash
66303f6140 Merge pull request #75643 from mikeash/mangled-name-verification-null-check
[Runtime] Check for NULL demangling when verifying mangled name roundtrips.
2024-08-05 10:39:09 -04:00
Yuta Saito
650e90a2b0 [Runtime] Repair build of getenv mode in EnvironmentVariables.cpp
Follow-up fix to 4b3a197dc2
2024-08-03 08:36:36 +00:00
Mike Ash
1d2ea6f949 [Runtime] Check for NULL demangling when verifying mangled name roundtrips.
_swift_buildDemanglingForMetadata can fail, so check for NULL and warn about it instead of crashing.
2024-08-02 11:26:57 -04:00