This test assumed that a vector of 4 ints needed 16-byte alignment, but
this is target specific. Now check that the runtime provides at least
as strong alignment as the compiler expects.
This has been tested with a few hacks on FreeBSD, where everything
except for throwing exceptions in +initialize appears to work (most
likely an unrelated issue, though it's possible that there are problems
with the unwind tables in objc_msgSend.)
Fixes#92
This was actually a memory leak in the hidden class implementation, but
it was mostly visible in the @synchronized implementation. Every hidden
class registered a custom .cxx_destruct method, to handle cleanup of all
of the hidden class structures. Unfortunately, this destructor failed
to delete the reflection metadata structures associated with the class,
specifically the objc_method_list containing the objc_method pointing to
the destructor itself.
Fixes#98
We use the existence of the `Protocol` class in a set of loaded objects
to determine whether we are mixing ABIs in a safe way (i.e. only mixing
a new ABI runtime with old ABI everything else). Unfortunately, in
static linking, the Protocol class was not being linked because it is
never directly referenced, which made this check fail.
Fixes#85
We now correctly handle ivars that overlap with the end of what the
compiler thinks is the start of the superclass and bitfields at the
start of a class.
Clang rounds up the size of a class to the size of a word. If the first
instance variable in a subclass has a field that has smaller alignment
requirements than a word, it is generated with a negative offset,
indicating that it belongs in the space allocated for the parent.
This did not work at all with the code we have for recomputing instance
variable layouts, which uses only the size and the alignment.
Fixes#96
For compatibility with a Facebook internal project, clang now mangles
Objective-C types and C structures in the same way. This is a terrible
idea, but it apparently doesn't break anything.
This was triggered when upgrading ivars from the pre-2.0 ABI that used
long double - their alignment could not be calculated correctly and we
hit an assertion.
Fixes: #82
__builtin_clz takes an unsigned int, it isn't overloaded for different
types. This meant that we were computing log2 by counting the
leading bits in a 32-bit value and using that result as if it were the
number of bits in a 64-bit value. This meant that our alignment values
were 2^32 times as big as they should be. This mostly didn't matter,
because we then truncated the result to 32 bits and the wrapping gave
the correct answer.
Unfortunately, this was undefined behaviour and, at sufficiently high
optimisation levels, this resulted in the value being optimised away,
leading to odd results.