Commit Graph

2981 Commits

Author SHA1 Message Date
Dario Rexin
c1b07f0f99 Merge pull request #68283 from drexin/wip-narf
[Runtime] Use handleRefCountsAssignWithCopy in swift_generic_assignWi…
2023-09-09 23:09:31 -07:00
Alejandro Alonso
1375ce6247 Merge pull request #68359 from Azoy/packs-pack-packs
[Runtime] Add a function to check type creation
2023-09-07 07:24:55 -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
Evan Wilde
176bf3417e Merge pull request #65076 from etcwilde/ewilde/metadata-cleanup
Replace mismatched `delete` with `swift_cxx_deleteObject`
2023-09-01 20:31:29 -07:00
Dario Rexin
ee28da2bf2 [Runtime] Use handleRefCountsAssignWithCopy in swift_generic_assignWithCopy
rdar://114840977

This was accidentally committed after debugging an issue
2023-09-01 14:53:52 -07:00
Dario Rexin
6e3d1ae726 [Runtime] Check if objc pointers are tagged before masking
In layout string value witnesses runtime functions, if an objc pointer is tagged, there is no ref counting necessary.
2023-08-30 18:50:38 -07:00
Dario Rexin
8fe4c77b3e [Runtime] Properly mask pointers before ref counting and other fixes
The fixes are all around enum support. Some tag comparisons and pointer masking were incorrect and led to crashes.

rdar://114575149
2023-08-30 17:54:47 -07:00
Saleem Abdulrasool
898f9efe3e Merge pull request #68099 from hjyamauchi/abort
Fix a fatal error not-terminating issue in Windows
2023-08-27 12:08:32 -07:00
Hiroshi Yamauchi
5fc3ad3a81 Fix a fatal error not-terminating issue in Windows.
Fix the issue that fatal errors in certain cases don't terminate the
process and the process keeps running in Windows by disabling the
exception swallowing that supressed the illegal instruction exceptions
coming from llvm.trap.
2023-08-25 13:04:36 -07:00
Dario Rexin
030daee5ad Merge pull request #68042 from drexin/wip-layout-strings-work
Improve layout strings runtime code and fix several issues
2023-08-24 16:03:34 -07:00
Kshitij Jain
d5a3e2e630 [AutoDiff] Fixes memory leaks in autodiff linear map context allocation builtins (#67944)
When the differentiating a function containing loops, we allocate a linear map context object on the heap. This context object may store non-trivial objects, such as closures, that need to be released explicitly. Fix the autodiff linear map context allocation builtins to correctly release such objects and not just free the memory they occupy.
2023-08-24 13:57:10 -07:00
Dario Rexin
e3a1bac859 [Runtime] Use copy of addrOffset in single payload assign with copy 2023-08-24 11:01:14 -07:00
Dario Rexin
21f4064380 [Runtime] Fix singlePayloadEnumSimpleAssignWithCopy 2023-08-21 10:59:15 -07:00
Dario Rexin
fd967fd9e3 [Runtime] Properly handle boxed references in layout string instantiation 2023-08-21 10:58:25 -07:00
Dario Rexin
7e3f56de24 [Runtime] Fix generic existentials in layout strings 2023-08-21 10:57:33 -07:00
Dario Rexin
56048ac19f [Runtime+IRGen] Fix existential offset for multiple protocol witnesses 2023-08-21 10:57:06 -07:00
Dario Rexin
8b3aaf5423 [Runtime] Compute end before looping over single payload ref count 2023-08-21 10:56:42 -07:00
Dario Rexin
7c0203dd55 [Runtime] Combine copy and destroy in assignWithCopy 2023-08-21 10:56:19 -07:00
Dario Rexin
8ab845fdca [Runtime+IRGen] Fix offsets of existentials in layout strings 2023-08-21 10:55:51 -07:00
Dario Rexin
4f6e69b35f [Runtime] Reduce instruction count in simple layout string operations 2023-08-21 10:55:25 -07:00
Dario Rexin
30d628270b [IRGen+Runtime] Make more fine grained copies in layout string runtime functions 2023-08-21 10:55:02 -07:00
Dario Rexin
27b1764d13 [Runtime+IRGen] Fix layout string flag in type layout and add array functions 2023-08-21 10:54:35 -07:00
Dario Rexin
31de67c713 [IRGen+Runtime] Further fixes for layout strings 2023-08-21 10:54:14 -07:00
Dario Rexin
4a395cb8d3 [Runtime+IRGen] Some fixes and optimizations for layout strings 2023-08-21 10:53:44 -07:00
Dario Rexin
2f61e2a9c9 [Runtime] Further abstract shared functionality in BytecodeLayouts 2023-08-21 10:53:14 -07:00
Dario Rexin
ec3a2dc370 [Runtime] Templatize shared functionality in BytecodeLayouts 2023-08-21 10:52:39 -07:00
Dario Rexin
c25b3b43a2 [Runtime] Restructure BytecodeLayouts 2023-08-21 10:52:24 -07:00
Alejandro Alonso
44198d16a4 Merge pull request #67611 from Azoy/raw-types-are-cool!
[WIP] Implement dependent layouts for raw types
2023-08-16 06:55:42 -07:00
Alejandro Alonso
c20ab10cef Use an i32 argument instead of size
more int32

zzz
2023-08-15 19:49:44 -07:00
Mike Ash
dbd2f82739 [Runtime] Fix up the heap destroyer in objc_setClassCopyFixupHandler.
We fix up the VWT pointer, but not the heap destroyer. This doesn't matter for classes which use ObjC refcounting, which is the common case for dynamic subclasses, because that doesn't use the heap destroyer pointer. But it does matter for classes that use native Swift refcounting, such as classes that don't inherit from NSObject, or actors.

rdar://113657917
2023-08-10 15:19:18 -04:00
Saleem Abdulrasool
da314bc7d7 runtime: silence some -Wformat warnings (NFC)
Use `z` rather than `l` for the modifier as the values are `size_t`
rather than `long`.  This fixes a bit of warning spew on Windows.
2023-08-04 08:47:23 -07:00
Alejandro Alonso
df17f7be90 Implement dependent layouts for raw types
Update raw_layout.swift

Allow for concrete specializations of raw layout

Make test platform agnostic
2023-08-01 14:09:23 -07:00
Dario Rexin
b82ac6bcdf Merge pull request #67599 from drexin/wip-112474091
[Runtime] Fix _swift_refCountBytesForMetatype for reference types
2023-07-28 14:53:56 -07:00
Dario Rexin
f257b3bbab [Runtime] Fix _swift_refCountBytesForMetatype for reference types
_swift_addRefCountStringForMetatype and _swift_refCountBytesForMetatype diverged in the code that determines whether a type is a reference, causing the size number of ref count bytes to differ from the actually used bytes. This can cause early termination of the runtime interpreter functions, which in turn causes unbalanced reference counts.

rdar://112474091
2023-07-28 11:55:53 -07:00
Slava Pestov
3a24b5361d TypeDecoder: Push one-element tuple unwrapping down into createTupleType() implementations
The old behavior was only correct when building substituted types,
ie, if createTupleType() was never called with a pack expansion type.

This was the case in the runtime's MetadataLookup which applies
substitutions to an interface type to ultimately construct metadata
for a fully-concrete type, but not in the ASTDemangler, where we
actually build interface types.

Since TypeDecoder doesn't have any way to query the kind of type
it just built, let's just instead make this decision inside the
implementation of the type builder concept.

Fixes https://github.com/apple/swift/issues/67322.
2023-07-27 12:14:54 -04:00
Mike Ash
b7f73cd52b [Runtime] Gracefully handle null genericArgs in SubstGenericParametersFromMetadata.
If a caller passes NULL generic parameters when looking up a generic type, we'll error and return NULL instead of crashing.

rdar://112153818
2023-07-26 16:49:52 -04:00
Slava Pestov
82c172c8e3 Merge pull request #67527 from slavapestov/rdar112866068
Runtime: Lift prohibition on packs in swift_getTypeByMangledName() overload used by mirrors
2023-07-26 06:49:00 -04:00
Slava Pestov
e454458e2a Runtime: Lift prohibition on packs in swift_getTypeByMangledName() overload used by mirrors
Fixes rdar://problem/112866068.
2023-07-25 23:15:01 -04:00
Dario Rexin
620d516fe7 [Runtime] Fix MultiPayloadEnumFN case in swift_resolve_resilientAccessors
rdar://112825968

Offsets were wrong, causing invalid memory accesses
2023-07-25 13:50:17 -07:00
Dario Rexin
f96b099ce9 Merge pull request #67485 from drexin/wip-fix-offset-writing-resolve
[Runtime] Fix issues with dynamic layout string instantiation
2023-07-24 13:09:52 -07:00
Ben Barham
b962cab6e1 Merge pull request #67478 from finagolfin/droid-ci
[Backtracing][Linux] Disable invoking process_vm_readv() for older Android APIs
2023-07-24 10:14:19 -07:00
Dario Rexin
6fb232510b [Runtime] Fix SinglePayloadEnumSimple read offset in swift_resolve_resilientAccessors
The offset was off by 1, causing subsequent tags to not be resolved properly.
2023-07-24 09:47:42 -07:00
Evan Wilde
669285fd17 Merge pull request #65534 from stephank/fix/cmake-3.25
build: fix accidental cmake expansions
2023-07-24 09:44:14 -07:00
Dario Rexin
10685367ce [Runtime] Use the properly resolved tag when adding offset after resolving relative pointers in layout strings
The tag was overwritten after resolve when a prior field caused a non-zero offset. This then caused the runtime to treat is a relative instead of an absolute pointer, causing invalid pointers to be dereferenced.
2023-07-24 09:36:26 -07:00
Finagolfin
4cbbb33dbf [Backtracing][Linux] Disable invoking process_vm_readv() for older Android APIs 2023-07-23 20:11:26 +05:30
Dario Rexin
937d1727a3 [IRGen] Fix enum metadata instantiation for resilient payload
The metadata can't be constant when we generate a layout string at runtime.
2023-07-17 16:00:41 -07:00
Stéphan Kochen
7b460ce495 build: fix accidental cmake expansions
As of CMake 3.25, there are now global variables `LINUX=1`, `ANDROID=1`,
etc. These conflict with expressions that used these names as unquoted
strings in positions where CMake accepts 'variable|string', for example:

- `if(sdk STREQUAL LINUX)` would fail, because `LINUX` is now defined and
  expands to 1, where it would previously coerce to a string.

- `if(${sdk} STREQUAL "LINUX")` would fail if `sdk=LINUX`, because the
  left-hand side expands twice.

In this patch, I looked for a number of patterns to fix up, sometimes a
little defensively:

- Quoted right-hand side of `STREQUAL` where I was confident it was
  intended to be a string literal.

- Removed manual variable expansion on left-hand side of `STREQUAL`,
  `MATCHES` and `IN_LIST` where I was confident it was unintended.

Fixes #65028.
2023-07-17 21:50:50 +02:00
Kuba Mracek
aab7eab240 Be consistent about guarding SWIFT_HAS_OPAQUE_ISAS with SWIFT_OBJC_INTEROP 2023-07-13 09:03:19 -07:00
Mike Ash
2d238bcea5 Merge pull request #67168 from mikeash/ptrauth-struct-context-descriptors
[Runtime][IRGen] Sign type context descriptor pointers.
2023-07-11 17:03:53 -04:00