Commit Graph

1782 Commits

Author SHA1 Message Date
Mike Ash
b964cde3dc [Runtime] In various enumTagSinglePayload functions, don't read getExtraInhabitantIndex or storeExtraInhabitant unless it actually has extra inhabitants.
This code would previously read off the end of the allocated metadata to fetch these values. This was usually harmless, as the value was never used in that case. However, on rare occasions the metadata would be right before unmapped memory, and this read would crash trying to access that unmapped memory.

rdar://problem/39866044
2018-07-11 11:17:23 -04:00
swift-ci
b22fb292d2 Merge remote-tracking branch 'origin/master' into master-next 2018-07-10 13:29:21 -07:00
Mike Ash
8a2705548d Merge pull request #17709 from mikeash/fix-const-cast-warning
[Runtime] Fix a warning about casting away constness in _swift_getClassOfAllocated.
2018-07-10 16:26:18 -04:00
swift-ci
468e401436 Merge remote-tracking branch 'origin/master' into master-next 2018-07-09 12:29:36 -07:00
Michael Gottesman
5648ef219d [+0-all-args] Clean up remains of +1 convention from the runtime. 2018-07-06 23:10:12 -07:00
swift-ci
68f92a5cc0 Merge remote-tracking branch 'origin/master' into master-next 2018-07-05 16:20:09 -07:00
Jordan Rose
2345a54ed2 Make sure artificial subclasses work with '===' and casting (#17765)
Dynamic subclasses aren't /really/ valid Swift type metadata, but
they can still be used as values of type AnyClass. Make sure we
don't assert when that happens.

No intended functionality change.
2018-07-05 15:54:45 -07:00
swift-ci
decf2b1130 Merge remote-tracking branch 'origin/master' into master-next 2018-07-05 11:49:26 -07:00
John McCall
34b0cbc11d Merge pull request #16237 from davezarzycki/metaprogram_ref_storage_types
[AST] NFC: Enable reference storage type meta-programming
2018-07-05 14:45:38 -04:00
Bob Wilson
e468fae196 Merge remote-tracking branch 'origin/master' into master-next 2018-07-04 11:13:51 -07:00
Ben Cohen
2b04e9f105 Suppress a number of warnings in no-assert builds (#17721)
* Supress a number of warnings about things used only in asserts

* Re-use a couple of variables instead of supressing the warning
2018-07-04 07:15:14 -07:00
swift-ci
3406cebee3 Merge remote-tracking branch 'origin/master' into master-next 2018-07-03 16:09:00 -07:00
Joe Groff
06ac23842f IRGen: Correctly set and honor the "is reflectable" bit on structs and classes.
If we only emit an opaque reflection record for a struct or class, then we can't reflect its fields. We failed both to clear the "is reflectable" bit in the context descriptor for non-reflectable structs, and to check for the bit before trying to present a struct's fields as children in the runtime. rdar://problem/41274260
2018-07-03 13:52:46 -07:00
Mike Ash
87dd0b53cf [Runtime] Fix a warning about casting away constness in _swift_getClassOfAllocated.
rdar://problem/40625756
2018-07-03 14:32:13 -04:00
David Zarzycki
efce6fca1e [Runtime] NFC: Adopt reference storage type meta-programming macros 2018-06-30 06:44:34 -04:00
swift-ci
54572b7e1f Merge remote-tracking branch 'origin/master' into master-next 2018-06-29 06:49:25 -07:00
Mike Ash
e32b77a6a7 Merge pull request #17515 from mikeash/nested-nserror-to-error-bridging
[Runtime] Extend ObjC bridging casts to convert NSError to Error when nested in a container type.
2018-06-29 06:47:23 -07:00
Bob Wilson
b254041121 Merge remote-tracking branch 'origin/master' into master-next 2018-06-28 23:23:29 -07:00
Joe Groff
e2dd2ff11f Runtime: Handle synthesized decl "related entity" tags.
Clang-importer-synthesized declarations get an extra tag character included in their mangling, which was not being preserved in type context descriptors. This caused runtime lookup for these synthesized types to fail. Fix this by adding the tag information to type context descriptors and teaching the runtime to match it up when fetching metadata by mangled name. Fixes rdar://problem/40878715.
2018-06-28 12:11:12 -07:00
Mike Ash
e992f46764 [Runtime] Extend ObjC bridging casts to convert NSError to Error when nested in a container type.
rdar://problem/39349762
2018-06-28 13:35:25 -04:00
Joe Groff
9ef3377d28 Runtime: Fallback when _swift_getFieldAt fails to find field metadata.
Better to log the failure than fall off the edge of this function, which is expected to always invoke its callback once.
2018-06-27 14:04:14 -07:00
swift-ci
d3e605a74a Merge remote-tracking branch 'origin/master' into master-next 2018-06-25 16:50:12 -07:00
Joe Groff
663904766e Revert "Runtime: Only demangle symbolic references in constant memory."
This reverts commit 99842f9919.
2018-06-25 15:47:14 -07:00
swift-ci
b70a1cd998 Merge remote-tracking branch 'origin/master' into master-next 2018-06-25 12:49:31 -07:00
Joe Groff
99842f9919 Runtime: Only demangle symbolic references in constant memory.
This provides a slight amount of defense against attackers constructing mangled names with offsets crafted to JOP the runtime into attacker-controlled code. (Someone could still find some random code or constant data artifact in a binary that *looks* like a mangled string with symbolic references and theoretically attack that way, but they at least wouldn't be able to construct their own string entirely.)
2018-06-25 10:22:20 -07:00
swift-ci
f7e70911de Merge remote-tracking branch 'origin/master' into master-next 2018-06-20 06:30:02 -07:00
Doug Gregor
f232af5535 [Mangling] Allow standard substitutions in protocol mangling.
Protocol name mangling didn’t always go through a path that allowed the use
of standard substitutions. Enable standard substitutions for protocol name
manglings where they make sense.

Removes ~277k from the standard library binary size.
2018-06-19 23:24:38 -07:00
Doug Gregor
7952a19f31 [Mangling] Introduce known manglings for many more standard library types.
Since the mangling scheme and set of standard library types is effectively
fixed now, introduce known mangling substitutions for a number of new
standard library types, filling out the S[A-Za-z] space.

Reduces standard library binary size by ~195k.
2018-06-19 23:24:38 -07:00
Bob Wilson
740c4d0782 [master-next] Avoid use of StringRef::split and rsplit
LLVM r334283 changed StringRef::split(char) to be implemented using
StringRef::split(StringRef), which is not defined inline. Because Swift
uses StringRef without linking LLVM's libSupport.a, we can only use
functions that are defined inline in the headers. Swift currently only
builds LLVM for the host, so we cannot link libSupport.a without building
it for every target, which would be a big change. Instead, this changes
a few places in Swift to avoid using those split and rsplit functions.

rdar://problem/41029268
2018-06-18 12:57:59 -07:00
Bob Wilson
225bc732b4 Merge remote-tracking branch 'origin/master' into master-next 2018-06-15 17:26:12 -07:00
Lily Vulcano
ce6316ed51 Expose swift_getTypeContextDescriptor() on Darwin. 2018-06-15 13:36:26 -07:00
swift-ci
be34234b1d Merge remote-tracking branch 'origin/master' into master-next 2018-06-13 09:49:27 -07:00
Joe Groff
5887165582 Merge pull request #15565 from tanner0101/get-field-c-callable
[runtime] make `swift_getFieldAt` callable from C / Swift
2018-06-13 09:39:32 -07:00
Bob Wilson
796122fa45 Merge remote-tracking branch 'origin/master' into master-next 2018-06-12 15:06:47 -07:00
Saleem Abdulrasool
b33a1e1766 runtime: workaround GCC 4.8 libstdc++ C++11 conformance
libstdc++ included with GCC 4.8 does not define `std::max_align_t` as
required by the C++11 specification.  As a workaround, explicitly create
the definition locally.  This was fixed in GCC 4.9 and later.
2018-06-12 12:03:31 -07:00
swift-ci
737078d205 Merge remote-tracking branch 'origin/master' into master-next 2018-06-11 17:09:35 -07:00
swift-ci
f65000ae57 Merge pull request #16964 from millenomi/bundle-for-class 2018-06-11 17:00:21 -07:00
swift-ci
797dc74b30 Merge remote-tracking branch 'origin/master' into master-next 2018-06-11 11:29:34 -07:00
Pavel Yaskevich
92c4189e2d [Runtime] NFC: remove C style "stddef.h" header from casting 2018-06-10 20:36:27 -07:00
swift-ci
890603e42f Merge remote-tracking branch 'origin/master' into master-next 2018-06-08 17:09:46 -07:00
Saleem Abdulrasool
638b89d12d runtime: use std::max_align_t over max_align_t (NFC)
MSVC does not provide a full C99 environment.  Use the C++ equivalent
spelling for the value.  This allows the build to succeed on Windows.
2018-06-08 14:36:19 -07:00
swift-ci
b6511cf791 Merge remote-tracking branch 'origin/master' into master-next 2018-06-08 10:09:36 -07:00
Joe Groff
c85a881993 Merge pull request #16906 from linux-on-ibm-z/s390x-relocation-fix
Mark swift sections as 1 byte aligned
2018-06-08 09:59:16 -07:00
Lily Vulcano
4c857c5f49 Mark as API; use expanded-from-template return type. 2018-06-08 09:45:49 -07:00
Lily Vulcano
02bf6fd217 Expose SPI to get type descriptor for Bundle(for:) 2018-06-08 09:42:53 -07:00
swift-ci
568855a33c Merge remote-tracking branch 'origin/master' into master-next 2018-05-31 09:29:52 -07:00
Lily Vulcano
1377ab7d7e Turn on ‘as’ bridging on Darwin. 2018-05-30 15:07:22 -07:00
swift-ci
ff0c455b1c Merge remote-tracking branch 'origin/master' into master-next 2018-05-29 11:49:49 -07:00
Mike Ash
9638cb8f6e [Runtime] Fix format string warnings in Errors.cpp and Exclusivity.cpp when built for 32-bit.
rdar://problem/40345076
2018-05-25 16:16:02 -04:00
Michael Munday
94ffb3404b Mark swift sections as 1 byte aligned
The C compiler on some platforms (such as s390x) assumes that the
data pointed to by symbols meets certain alignment requirements.
The swift sections do not necessarily meet these alignment
requirements so this change adds alignment attributes to them to
force the compiler to emit the instruction sequences and relocations
required to address unaligned data.

This fixes a 'R_390_PC32DBL target misaligned' warning issued by
gold on s390x.
2018-05-25 11:03:44 -04:00