Commit Graph

3162 Commits

Author SHA1 Message Date
Slava Pestov
1834469d72 Merge pull request #64063 from slavapestov/more-variadic-generic-types-runtime-work
More variadic generic types runtime work
2023-03-03 08:44:34 -05:00
Alastair Houghton
b05f609e4c [Runtime] Remove spurious include of <filesystem>.
This was added when Saleem suggested using <filesystem> to avoid having
to do lots of string manipulation, but it turns out we can't use it on
macOS because of minimum deployment versions, and we also can't use it
on Ubuntu 18.04 because it doesn't exist there.

The code related to it was backed out already, but I missed the include.

rdar://106183273
2023-03-03 07:32:51 +00:00
Slava Pestov
66ed09e72b Runtime: Variadic generic type fixes 2023-03-03 02:24:01 -05:00
Slava Pestov
32caa17b11 Runtime: Finish removing the 'extra argument' notion 2023-03-03 02:21:08 -05:00
Mishal Shah
e256b56545 Merge branch 'main' into rebranch 2023-03-02 18:25:09 -08:00
Alastair Houghton
95b8a4877b Merge pull request #63964 from al45tair/backtracing/path-lookup
[Backtracing] Add support for looking up paths for auxiliary executables
2023-03-03 00:09:14 +00:00
Slava Pestov
68378b8feb Merge pull request #64031 from slavapestov/remove-obsolete-concurrent-map
Remove obsolete ConcurrentMap and friends
2023-03-02 15:07:16 -05:00
Mike Ash
360c6d1570 Merge pull request #64003 from mikeash/getsectiondata-spi
[Runtime] Use dyld SPI for getting macho sections when available.
2023-03-02 10:50:59 -05:00
Slava Pestov
01acda7730 Runtime: Remove linear order on metadata cache keys 2023-03-02 10:22:11 -05:00
Alastair Houghton
14a0ec38a2 [Backtracing] A couple more const fixes.
rdar://103071801
2023-03-02 09:42:00 +00:00
Alastair Houghton
81a8a7e9e2 [Backtracing] Fix some const problems as a result of the previous change.
rdar://103071801
2023-03-02 08:48:36 +00:00
Mike Ash
19d86e8d3e [Runtime] Use dyld SPI for getting macho sections when available.
When available, use objc_addLoadImageFunc2 and _dyld_register_func_for_add_image to look up mach-o sections instead of using getsectiondata. When not available, we fall back to objc_addLoadImageFunc or _dyld_register_func_for_add_image and getsectiondata as before.

rdar://51760462
2023-03-01 16:06:15 -05:00
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