Commit Graph

1960 Commits

Author SHA1 Message Date
Saleem Abdulrasool
28f2d80fd9 runtime: remove unused source (NFCI)
`StaticBinaryELF.cpp` was listed as an optional source but then unused
by any build target.  As a result, it escaped detection that the file
was no longer in use.
2019-07-06 21:13:47 -07:00
Saleem Abdulrasool
87aa923389 build: remove non-optional sources (NFC)
This just removes the files listed in the `LLVM_OPTIONAL_SOURCES` which
are in fact always built.  NFC
2019-07-06 15:49:21 -07:00
Saleem Abdulrasool
c0fb0036a3 Runtime: add a workaround for Windows ARM64
Unfortunately, `std::atomic` in msvcprt as of 14.21.27702 is broken for
double-width atomics on ARM64.  This has been reported to Microsoft and
is going to be fixed in VC++ 2019u3.  For the time being, add a partial
template specialisation for the two double-word sized types temporarily
as a workaround.  This allows the standard library build to get further.
2019-07-03 09:27:59 -07:00
Saleem Abdulrasool
88f8a3c597 Merge pull request #25846 from plotfi/master2
Appending SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS to SWIFT_COMPILE_FLAGS.
2019-07-01 16:34:40 -07:00
David Smith
a84af6f68b Revert "Revert "Revert "Use the remaining half bit in the refcount to bypass ObjC deallocation overhead"""
This reverts commit c51294671b.
2019-07-01 14:29:40 -07:00
Puyan Lotfi
6691fda8ec Appending SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS to SWIFT_COMPILE_FLAGS.
There are situations where you want to build against a libc that is out
of tree or that is not the system libc (Or for cross build scenarios).
This is a change for passing the -sdk and include paths for things like
this.
2019-07-01 09:43:47 -07:00
Joe Groff
85c44472e0 Merge pull request #25811 from jckarter/remote-mirror-opaque-types
Reflection: Look through opaque type descriptors.
2019-06-26 21:06:55 -07:00
Joe Groff
4e493b0051 Reflection: Look through opaque type descriptors.
Turn an opaque type reference in a mangled name into its underlying type, if we can.
rdar://problem/46140707
2019-06-26 17:58:52 -07:00
Jordan Rose
57a0c9f5f8 [Runtime] Fix some type mismatch errors (#25790)
Harmless in practice, but still good hygiene.
2019-06-26 15:17:50 -07:00
Mike Ash
62cb20ec69 Merge pull request #25705 from mikeash/more-dump-methods
[Runtime] Add dump() methods to TypeContextDescriptor and EnumDescriptor.
2019-06-24 11:15:02 -07:00
Mike Ash
d05a8cab34 [Runtime] Add dump() methods to TypeContextDescriptor and EnumDescriptor. 2019-06-24 11:24:53 -04:00
Brent Royal-Gordon
4149c8f97d [Runtime] Fix private generic type witness demangling failure (#25611)
This one’s screwily specific--if you have:

* a private generic type,
* with a nested generic type in it,
* and the nested type conforms to a protocol with an associated type,
* and that associated type’s witness is a generic type,
* and some of the witness type’s generic parameters are generic parameters of the nested type,

demangling would fail. The problem is that the substitution machinery in the runtime would consider there to be three, not two, generic context depths involved. Depth 1, which should correspond to the nested type, would instead have no generic parameters. The fix is to skip over depths with zero generic parameters.

Fixes <rdar://problem/47773183>.
2019-06-20 12:02:01 -07:00
Arnold Schwaighofer
fb08153de0 Fix dynamic replacement runtime when generating replacements from multiple object files
The sections with the replacements get merged and we need to consider all replacements.

SR-10947
rdar://51913012
2019-06-19 15:11:33 -07:00
David Smith
28dcc915e3 Merge pull request #25418 from Catfish-Man/no-objc-complications-4
Use the remaining half bit in the refcount to bypass ObjC deallocation overhead
2019-06-19 11:08:29 -07:00
David Smith
c51294671b Revert "Revert "Use the remaining half bit in the refcount to bypass ObjC deallocation overhead""
And add availability checking for back deployment

This reverts commit 817ea129f2.
2019-06-18 16:16:38 -07:00
Mike Ash
b70cd7031f Merge pull request #25150 from mikeash/dlopen-race
[Runtime] Fix a race with dlopen and libobjc.
2019-06-18 11:48:49 -07:00
Arnold Schwaighofer
906f0b4e9e Address review comments 2019-06-17 19:47:52 -07:00
Arnold Schwaighofer
5d329464d6 Use thread private key to avoid weak linkage
We use one bit of the third reserved swift private tls key.

Also move the functionality into a separate static archive that is
always linked dependent on deployment target.
2019-06-17 15:03:45 -07:00
Mike Ash
2ac0ab069a [Runtime] Use objc_addLoadImageFunc when available to find out about newly loaded images.
rdar://problem/49742015
2019-06-14 17:09:28 -04:00
Saleem Abdulrasool
9f070edc17 Merge pull request #25308 from Azoy/demangle-bug-thing
[Runtime] swift_demangle: Update buffer size after copying
2019-06-11 16:56:57 -07:00
Azoy
f79eb3b8d0 swift_demangle: update buffer size after copying 2019-06-07 18:06:32 -05:00
Daniel Rodríguez Troitiño
a7025522a4 [android] Basic support for backtraces.
Android doesn't support the GNU backtrace call, but unwind.h is there to
help. The code is a little bit more complicated than a simple backtrace
call, but it is just a callback and the context struct.

Sadly, it seems that -funwind-tables is needed in every piece of code
that the backtrace needs to traverse, which means that at least the
runtime and the stubs need -funwind-tables. However, the flag has been
enabled for all targets (only on Android), just in case some other code
ends up being in the stack. This might only be necessary for ARM
targets, but currently we only build ARM targets in Android. The Swift
parts of the stack seems to have unwind information and can be unwind.

Another problem at the moment is the symbols from the executable are
normally missing. To get symbol names two things need to happen: the
symbol has to be public (so it is an exported symbol, and not just a
local symbol that dladdr seems to not provide the name), and the linker
has to be invoked with -export-dynamic. Without those two pieces, the
addresses are returned (and match the binary just fine), but no names
are printed.
2019-06-05 13:12:04 -07:00
Saleem Abdulrasool
33767d6052 runtime: silence a unused definition warning (NFC)
When building without assertions, the variable will be unreferenced on
non-ObjC runtimes.  Sink the evaluation into the assertion and move the
declaration into the ObjC runtime case.
2019-06-02 11:22:35 -07:00
Erik Eckstein
7a5de47aa1 runtime: change the naming of TLS related stuff to make it more general and not specific to exclusivity checking.
Just a refactoring, NFC
2019-05-30 15:28:16 -07:00
Erik Eckstein
2ea531c3b3 IRGen/runtime: change the code generation for dynamically replaceable functions
Instead of a thunk insert the dispatch into the original function.
If the original function should be executed the prolog just jumps to the "real" code in the function. Otherwise the replacement function is called.
There is one little complication here: when the replacement function calls the original function, the original function should not dispatch to the replacement again.
To pass this information, we use a flag in thread local storage.
The setting and reading of the flag is done in two new runtime functions.

rdar://problem/51043781
2019-05-30 15:28:16 -07:00
Joe Groff
2a28948a69 Merge pull request #25030 from jckarter/SR-10600-back-deploy
Introduce a backward-deployment library for SR-10600.
2019-05-29 15:02:02 -07:00
Joe Groff
9e1907a2ed Introduce a backward-deployment library for SR-10600.
Build a static archive that can be linked into executables and take advantage of the Swift runtime's
hooking mechanism to work around the issue Doug fixed in https://github.com/apple/swift/pull/24759.
The Swift 5.0 version of swift_conformsToProtocol would return a false negative in some cases where
a subclass conforms using an inherited conformance, so work around this by successively retrying
the original implementation up the superclass chain to try to find a match.
2019-05-24 09:28:49 -07:00
Arnold Schwaighofer
0297476da5 Add missing swiftrt-coff change 2019-05-22 11:23:17 -07:00
Arnold Schwaighofer
5c3a4d329b Fix dynamic replacement of some type when used with associated types
rdar://50638228
2019-05-18 10:34:52 -07:00
Mike Ash
1a0c785384 Merge pull request #24729 from mikeash/fix-isa-mask-assert
[Runtime] Don't check objc_debug_isa_class_mask when back deploying.
2019-05-14 12:30:11 -04:00
Doug Gregor
54d3930ae8 [Runtime] Adjust to conforming type when instantiating witness table.
When we find a protocol conformance descriptor for a given type, make sure
we adjust to the conforming type of that descriptor (following the superclass
chain as needed) before instantiating the witness table.

Fixes rdar://problem/49741838.
2019-05-13 20:53:02 -07:00
Mike Ash
c42ec7ab35 [Runtime] Don't check objc_debug_isa_class_mask when back deploying.
Older OSes may not have this value or may have a different value. We only want to check going forward, because newer runtimes don't run on older OSes except in certain testing scenarios.

rdar://problem/50700856
2019-05-13 11:37:19 -04:00
Slava Pestov
97be86bbca Runtime: Don't try to register class stubs on older objc runtimes
This will allow us to emit class stubs unconditionally, rather than
checking the -enable-resilient-objc-class-stubs flag.

Part of <rdar://problem/49090631>.
2019-05-10 21:26:09 -04:00
Mike Ash
3ec3d9b6dd [Runtime] In the assert for SWIFT_ISA_MASK, tolerate it if objc_debug_isa_class_mask is not available.
rdar://problem/50674635
2019-05-10 17:27:32 -04:00
Mike Ash
14a20eea03 Merge pull request #24616 from mikeash/hardcode-swift-isamask
[Runtime] Use a #define for the value of swift_isaMask.
2019-05-10 13:31:57 -04:00
Mike Ash
b85c600395 [Runtime] Use a #define for the value of swift_isaMask.
This allows _swift_getClassOfAllocated to use a constant instead of loading from a global, and allows swift_isaMask to be computed without a static initializer. Debug builds verify that the #define matches the value from libobjc.

rdar://problem/22375602 rdar://problem/46385113
2019-05-10 09:37:51 -04:00
Mike Ash
213efbbfaa [Runtime] Avoid +class overrides when initializing an ObjC class.
swift_getInitializedObjCClass called [c class] to trigger class initialization, and returned the value. This wreaked havoc when the class in question overrides +class. Instead, ignore the return value and return c. Switch from +class to +self, which is much less likely to be overridden. Calling an overridden method could have performance downsides or even cause unwanted side effects.

rdar://problem/49853091
2019-05-08 16:17:56 -04:00
Davide Italiano
b4434fdd8d [Reflection] Fix the computation of boundaries in getFieldName(). 2019-05-06 17:27:20 -07:00
Davide Italiano
1acedc6c69 [Reflection] Check that the offset is within the section.
<rdar://problem/49043621>
2019-05-03 17:09:09 -07:00
Joe Groff
6c779bb487 Merge pull request #24445 from jckarter/opaque-type-remote
Debugger support for opaque types.
2019-05-03 08:18:59 -07:00
Saleem Abdulrasool
2e7c328077 Merge pull request #24168 from xiaobai/sink_component_arg
[CMake] Modify swift_install_in_component to support cmake install components
2019-04-30 21:06:32 -07:00
Joe Groff
9c6bc9ccd7 Runtime: Generalize TypeMetadataRecords to non-type contexts.
We could introduce non-nominal-type context descriptors, such as those for opaque declarations,
which are also interesting to be able to look up for reflection or remote purposes. This should be
a backward compatible change with old runtimes, which always ignore any context descriptor kind
they don't know about.
2019-04-29 11:30:11 -07:00
Arnold Schwaighofer
50143048ee Initialize the extraInhabitantCount field of single case enums
rdar://49786768
2019-04-25 12:33:05 -07:00
swift-ci
c34c3e373e Merge pull request #23732 from Catfish-Man/pointernt 2019-04-23 14:58:34 -07:00
David Smith
96a93261d0 Use the Swift runtime's (faster) class check in the stdlib instead of shimming object_getClass() 2019-04-23 13:05:25 -07:00
Slava Pestov
bc4d70c12a Runtime: Fix condition for class stubs support
Fixes <rdar://problem/50068190>.
2019-04-20 18:14:09 -04:00
Alex Langford
3d9a28925b [CMake] Modify swift_install_in_component to support cmake install components
CMake supports the notion of installation components. Right now we have some
custom code for supporting swift components. I think that for installation
purposes, it would be nice to use the CMake component system.

This should be a non-functional change. We should still only be generating
install rules for targets and files in components we want to install, and we
still use the install ninja target to install everything.
2019-04-19 14:06:11 -07:00
Joe Groff
7bab318238 Merge pull request #24159 from jckarter/protocol-extension-context-lookup
MetadataLookup: Use extension's generic context for non-nominal extensions.
2019-04-19 13:37:48 -07:00
Joe Groff
9a411bea6a MetadataLookup: Use extension's generic context for non-nominal extensions
In protocol extensions, and in the future parameterized extensions, have their own generic arguments
independent of an originating nominal type's formal generic parameters. Instead of crashing, handle
this gracefully. rdar://problem/50038754
2019-04-19 10:30:43 -07:00
Joe Groff
95c43f4e18 Decode opaque types in the runtime demangler. 2019-04-17 14:44:40 -07:00