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.
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
This will allow us to emit class stubs unconditionally, rather than
checking the -enable-resilient-objc-class-stubs flag.
Part of <rdar://problem/49090631>.
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
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
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.
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.
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
The sections to which the start/stop symbols are being applied do not
guarantee pointer alignment. In particular, the field metadata is
aligned to a 4-byte boundary, which is less then the pointer alignment
of `uintptr_t`. This results in extra padding in the data which is
going to cause the iteration to run off the end. A similar byte
alignment is forced for the markers in the ELF case as well. This fixes
one of the reflection tests on Windows where we were attempting to
decode the padding as an entry.
This adds a new tail-allocated field to class context descriptors storing
a pointer to an Objective-C class stub.
When the stub is present, we use the new _objc_realizeClassFromSwift()
entry point to realize the class instead of calling objc_readClassPair().
This should attach categories to the realized class, if they were emitted
to reference the stub.
This caused an issue where the runtime was unable to find subclasses of
resilient subclasses of NSObject until they were first registered by their
sugared name with NSClassFromString or were instantiated directly.
rdar://48892003
Extract common code from the old and new remangler into a common base class.
This lets the old remangler benefit from the changes I did recently in the new remangler.
This is needed for Windows which does not support cross-module data
references without indirection. By lazy initializing the data, we can
indirect through the IAT for the data pointer and fill in the parent
pointer.
Recent Swift uses 2 as the is-Swift bit when running on newer versions, and 1 on older versions. Since it's difficult or impossible to know what we'll be running on at build time, make the selection at runtime.
Instead of capturing SubstGenericParametersFromMetadata and SubstGenericParametersFromWrittenArgs by value, capture by reference.
This avoids those instances to be copied and thus avoids a lot of mallocs.
SR-10028
rdar://problem/48575729
This dramatically reduces the number of needed malloc calls.
Unfortunately I had to add the implementation of SmallVectorBase::grow_pod to the runtime, as we don't link LLVM. This is a bad hack, but better than re-inventing a new SmallVector implementation.
SR-10028
rdar://problem/48575729
We would not previously symbolicate the stack trace and as a result
would not display the stack trace. Add symbolication support to the
runtime to actually make use of the captured stack trace. This allows
us to get a stack trace when the standard library or swift code reports
a fatal error.
The assertions here are based around the idea that `std::atomic` is
trivially constructible which is not a guarantee that the standard fully
provides. The default initialization of the `std::atomic` type may
leave it in an undetermined state. These were caught using the Visual
C++ preview runtime.
Ideally, the object constructor would use a placement new operator.
However, prior to C++17, the C++ standard mandated that there be a
NULL pointer check in the placement new operator. This is something
which is no longer the case with C++17. Switch to the placement new
operator for C++17 and newer and enable that codepath for Windows as
well (which seemingly elides the null-pointer check with clang-cl).