Commit Graph

3150 Commits

Author SHA1 Message Date
Slava Pestov
ac199ac7c6 Runtime: Metadata cache key support for packs 2023-03-01 15:48:01 -05:00
Slava Pestov
e5eafbc446 Runtime: Factor out GenericSignatureLayout::compare() 2023-03-01 15:11:02 -05:00
Alastair Houghton
f6bfa7ef35 [Backtracing] Change the return type of one of the paths functions.
Since it's copying, it may as well return `char *` instead of
`const char *`.

rdar://103071801
2023-03-01 19:08:08 +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
Slava Pestov
d5b75fe7d2 Runtime: Add GenericRequirementKind::SameShape and stub out cases 2023-02-28 17:33:06 -05:00
Slava Pestov
d764167783 Runtime: Fix Windows build 2023-02-28 02:12:32 -05:00
Slava Pestov
560aad797e Runtime: Wrap pack pointers in a fancy TargetPackPointer template instead of twiddling the LSB by hand
This is more type safe in theory, but in practice it's just catnip for C++ fans.
2023-02-28 02:12:32 -05:00
Slava Pestov
5663910827 Runtime: Add swift_allocateMetadataPack() and swift_allocateWitnessTablePack()
Both return the pack immediately if its already heap allocated, by
checking the least significant bit of the pack pointer.

Then,

- swift_allocateMetadataPack() uniques the metadata pack by the
  pointer equality of elements.

- swift_allocateWitnessTablePack() does not unique the pack.

Both return a pack pointer with the least significant bit set,
indicating heap allocation.
2023-02-28 02:12:32 -05:00
Arnold Schwaighofer
1dfc30eb1f Merge remote-tracking branch 'origin/main' into rebranch 2023-02-27 09:18:56 -08:00
Dario Rexin
96d988a431 [Runtime] Move bytecode layout handling into runtime (#63901)
rdar://105904548
2023-02-25 10:18:45 -08:00
Dario Rexin
a8d4d57f11 [IRGen] Generate compressed representation of value witnesses (#63813)
rdar://105837040

* WIP: Store layout string in type metadata

* WIP: More cases working

* WIP: Layout strings almost working

* Add layout string pointer to struct metadata

* Fetch bytecode layout strings from metadata in runtime

* More efficient bytecode layout

* Add support for interpreted generics in layout strings

* Layout string instantiation, take and more

* Remove duplicate information from layout strings

* Include size of previous object in next objects offset to reduce number of increments at runtime

* Add support for existentials

* Build type layout strings with StructBuilder to support target sizes and metadata pointers

* Add support for resilient types

* Properly cache layout strings in compiler

* Generic resilient types working

* Non-generic resilient types working

* Instantiate resilient type in layout when possible

* Fix a few issues around alignment and signing

* Disable generics, fix static alignment

* Fix MultiPayloadEnum size when no extra tag is necessary

* Fixes after rebase

* Cleanup

* Fix most tests

* Fix objcImplementattion and non-Darwin builds

* Fix BytecodeLayouts on non-Darwin

* Fix Linux build

* Fix sizes in linux tests

* Sign layout string pointers

* Use nullptr instead of debug value
2023-02-24 15:40:28 -08:00
swift-ci
f3d628ad9e Merge remote-tracking branch 'origin/main' into rebranch 2023-02-21 16:53:20 -08:00
Slava Pestov
d8f7959adf ASTDemangler: Support PackType, SILPackType, and PackExpansionType
Also stub out the corresponding entry points in the runtime's
MetadataBuilder and the Remote Mirrors TypeRefBuilder.
2023-02-21 15:33:19 -05:00
swift-ci
e2b5e98b83 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-20 19:13:32 -08:00
Arnold Schwaighofer
881958109c Merge pull request #63788 from aschwaighofer/sign_relative_pwt
Sign relative protocol witness tables
2023-02-20 19:13:03 -08:00
swift-ci
781b317e3c Merge remote-tracking branch 'origin/main' into rebranch 2023-02-20 14:33:20 -08:00
Julian Lettner
a60d354ef5 [SUA] Add test for allocation of classes without metadata (#63759)
Add test for allocating classes with pruned metadata and refactor
`computeMallocTypeSummary()` to make it easier to understand:

* Use early returns for error (metadata absent) conditions
* Remove reliance on implicit dependency---having a type descriptor
  currently implies that there is also class metadata---in case this
  ever changes

Co-authored-by: Julian Lettner <julian.lettner@apple.com>
2023-02-20 14:18:31 -08:00
Arnold Schwaighofer
1fa68ff82b Sign relative protocol witness tables
rdar://98583748
2023-02-20 12:29:13 -08:00
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