Commit Graph

2981 Commits

Author SHA1 Message Date
swift-ci
460f279562 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-15 10:13:21 -08:00
Julian Lettner
ba3973bead [SUA] Do not access the field descriptor when absent (#63663)
Radar-Id: rdar://105461946

Co-authored-by: Julian Lettner <julian.lettner@apple.com>
2023-02-15 10:07:59 -08:00
swift-ci
1961e0762f Merge remote-tracking branch 'origin/main' into rebranch 2023-02-08 10:13:34 -08:00
Alejandro Alonso
acb7f8efda Implement generic signature checking for PartialType.create(with:) (#63496)
Check other constraints

some more fixes
2023-02-08 10:10:58 -08:00
swift-ci
9f28c7c96a Merge remote-tracking branch 'origin/main' into rebranch 2023-02-07 14:13:20 -08:00
Tim Kientzle
000664b967 Merge pull request #37912 from tbkka/tbkka/sr14635-overlyAggressiveSwiftValueBoxing-Part2
SR-14635: __SwiftValue should be transparent to casting
2023-02-07 14:12:04 -08:00
swift-ci
e213331a13 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-06 07:13:38 -08:00
Arnold Schwaighofer
9e2308295d runtime: conditionally generate relative protocol witness tables entry points 2023-02-03 08:54:58 -08:00
swift-ci
83bb6d2b8b Merge remote-tracking branch 'origin/main' into rebranch 2023-02-02 23:13:55 -08:00
Anthony Latsis
26dd150a39 Merge pull request #62670 from valeriyvan/incorrect-format 2023-02-03 10:05:52 +03:00
swift-ci
b8b40938b6 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-02 17:14:31 -08:00
Julian Lettner
5ad0331e55 Adopt malloc_type for allocating Swift objects from runtime (#63226)
Adopt malloc_type for allocating Swift objects from runtime

Radar-Id: rdar://98998492
2023-02-02 17:08:41 -08:00
swift-ci
148d3ac8bf Merge remote-tracking branch 'origin/main' into rebranch 2023-02-02 12:54:50 -08:00
Tim Kientzle
3a849abe08 Flip the bincompat switches on the tightened casting semantics
so the new behavior is always enabled by default on all OSes.

(This may change depending on whether anyone is actually depending
on this behavior.)
2023-02-02 08:45:50 -08:00
Tim Kientzle
00f49a98d0 Provide a Bincompat override for the newly tightened casting semantics 2023-02-02 08:45:50 -08:00
Tim Kientzle
1846545da1 Use SwiftValue unpacking API correctly 2023-02-02 08:45:50 -08:00
Tim Kientzle
6127cc286c Fix calling convention for unboxFromSwiftValueWithType 2023-02-02 08:45:50 -08:00
Tim Kientzle
b91f29dfcb SR-14635: __SwiftValue should be transparent to casting
This PR changes the casting machinery to avoid casting `__SwiftValue` boxes
directly.  This forces the caster to instead unwrap `__SwiftValue` boxes and
retry with the inner content.  This results in boxed values being cast like the
inner content.

This fixes the behavior in situations like the following:
```
   let t = ...
   let s = t as Any as! AnyObject
   // `s` is now a `__SwiftValue` box
   // Next line should be true iff t conforms to NSCopying
   // Prior to this change, it always succeeds
   s is NSCopying
```

After this change, the above cast succeeds only if `t` actually
conforms to `NSCopying`.

This is a follow-on to PR#37683.
Related to: SR-14635
2023-02-02 08:45:50 -08:00
Arnold Schwaighofer
0f9bfac94b Remove undefined behavior in RelativeWitnessTable::getDescription() 2023-02-02 07:02:21 -08:00
Alastair Houghton
125e54f38c [Runtime] Adjust argument types to match the LLVM15 ABI.
It appears that LLVM 15 changed the ABI for _Float16 on x86-64 such that
values are now passed in `xmm0` instead of using integer registers.

Also enable this code for Linux.

rdar://104134160
2023-02-02 12:21:52 +00:00
Alastair Houghton
df1891eb98 [Runtime] Add __extendhfxf2 support to the Swift runtime.
It turns out that we can just use the Float16 to Float32 conversion and
let the compiler turn that into a long double for us, which means we
can take advantage of the F16C CPU instructions if they're present as well.

rdar://104134160
2023-02-02 12:21:52 +00:00
Valeriy Van
3e85cc4862 [runtime] Fix incorrect format specifier 2023-02-02 14:04:25 +02:00
swift-ci
18d60f721a Merge remote-tracking branch 'origin/main' into rebranch 2023-02-01 19:34:06 -08:00
Arnold Schwaighofer
d5965d0ef6 Fix AnyHashableSupport.cpp for SWIFT_STDLIB_USE_RELATIVE_PROTOCOL_WITNESS_TABLES 2023-02-01 07:10:53 -08:00
swift-ci
82c0288da8 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-01 06:13:47 -08:00
Arnold Schwaighofer
770648f161 Initial runtime changes to support relative protocol witness tables 2023-01-31 10:59:37 -08:00
swift-ci
55108f9a60 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-13 06:46:31 -08:00
Mike Ash
df48847c4a Merge pull request #62997 from mikeash/null-symbolic-reference-fatal-error
[Runtime] Fatal error when resolving a symbolic reference to NULL.
2023-01-13 09:14:14 -05:00
swift-ci
361b0cf08a Merge remote-tracking branch 'origin/main' into rebranch 2023-01-12 12:36:00 -08:00
Alastair Houghton
6ca5716ef4 Merge pull request #62879 from al45tair/eng/PR-103950409
[Runtime] Make the swift_getTypeByMangled... functions emit error messages.
2023-01-12 20:32:41 +00:00
Mike Ash
7b33d2c0af [Runtime] Fatal error when resolving a symbolic reference to NULL.
We crash in ResolveAsSymbolicReference::operator() when a symbolic reference targets a missing symbol. We usually have very little information about what was missing when this happens. Instead of crashing, explicitly check for NULL and fatal error in that case, including information about the location of the symbolic reference that it came from.
2023-01-12 11:46:57 -05:00
swift-ci
cb3a8e8553 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-12 04:40:13 -08:00
Jonathan Grynspan
b2bbf00bd7 Remove unused infrastructure added for runtime attributes (#62971) 2023-01-12 04:16:45 -08:00
Erik Eckstein
0e78660bdd linux: link the stdlib against the clang rt libs
This fixes missing floating point conversion symbols.
It also makes the workarounds in Float16Support.cpp obsolete.

rdar://102641225
2023-01-11 13:51:02 +01:00
Alejandro Alonso
382510fa50 Rename Reflection library to RemoteInspection (#62846) 2023-01-06 13:21:32 -05:00
Alastair Houghton
f0200bc0d8 Conditionalise the warnings on an environment variable.
We'll only generate warnings if SWIFT_DEBUG_FAILED_TYPE_LOOKUP is
enabled.

rdar://103950409
2023-01-06 14:42:27 +00:00
Alastair Houghton
d9db40d356 Make the swift_getTypeByMangled... functions emit error messages.
When type lookups fail, these functions should at least generate a warning.

rdar://103950409
2023-01-06 13:04:38 +00:00
Alastair Houghton
e73de539b8 Move _swift_win32_withDbgHelpLibrary into the new header.
It makes sense to move this function into the new Win32 header.

rdar://103397975
2022-12-21 11:44:37 +00:00
Alastair Houghton
fb1211e3fa Rename the functions as they're exported as C APIs.
`SWIFT_RUNTIME_STDLIB_INTERNAL` does `extern "C"`, so we can't put these
in a namespace and have to use a C-style prefix instead.

Also slightly rearrange the code in `CommandLine.cpp`.

rdar://103397975
2022-12-21 11:44:37 +00:00
Alastair Houghton
ca771c4d1d Change to returning nullptr rather than triggering a fatal error.
Instead of triggering a fatal error on failure, return `nullptr` and
let the caller decide what to do about it.  The CommandLine code should
trigger a fatal error, of course.

rdar://103397975
2022-12-21 11:44:37 +00:00
Alastair Houghton
a31b1c54fa Centralise code to map between UTF-8 and UTF-16 on Windows.
In various places we need to call the Windows API, and because Swift uses UTF-8
for its string representation, we can’t call the ANSI API functions (because the
code page used for the ANSI functions varies depending on the system locale
setting). Instead, we need to use the wide character APIs.

This means that we need to convert UTF-8 to wide character and vice-versa in
various places in the runtime.

rdar://103397975
2022-12-21 11:44:35 +00:00
Jonathan Grynspan
8af9b14428 Only touch the MetadataSections::swift5_runtime_attributes field in newer structures 2022-12-20 09:45:01 -08:00
Jonathan Grynspan
11033c6aa4 Fill out dynamic loading of the runtime attributes section 2022-12-20 09:45:01 -08:00
Pavel Yaskevich
a5af302173 [stdlib] RuntimeMetadata: Register newly added "runtime attributes" section 2022-12-20 09:45:01 -08:00
Arnold Schwaighofer
1e82ef8df7 Fix dynamic replacement of weakly linked symbols
If the replaced symbol goes away in the original library, the
replacement key in the replacement descriptor will be null. Handle this
by ignoring the replacement entry rather than crashing.

rdar://103307821
2022-12-15 13:19:34 -08:00
Jonathan Grynspan
70d4b4678e Add swift:: in a couple of places that don't have using namespace swift (affects sourcekit-lsp) (#62583) 2022-12-14 16:34:44 -05:00
Jonathan Grynspan
c889270a38 Remove lookupSymbol() and have all callers use SymbolInfo::lookup() instead (#62552) 2022-12-14 08:33:32 -05:00
Jonathan Grynspan
26fc627ad0 Fix a use-after-free bug on Win32 when calling lookupSymbol() (#62484) 2022-12-13 09:04:34 -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
Jonathan Grynspan
e057172b6f Make _swift_willThrow atomic (#62349)
* Make _swift_willThrow atomic
2022-12-03 10:41:56 -05:00