This test was accidentally passing sometimes, with the isa pointer being
set using some bit of memory in inter-object padding. This breaks
horribly with an allocator that packs objects densely.
Fix type of `__cxa_allocate_exception` with recent libsupc++.
Recent versions of GNU libsupc++ provide a definition of `__cxa_allocate_exception` that has a `noexcept` qualifier. This is sensible (if allocating an exception throws an exception, then something is badly wrong) but it not what the ABI spec says. We provide our own definition of this, which must match another if provided.
This wouldn't normally be a problem, but recent libstdc++ headers appear to leak libsupc++ headers into the namespace, so we're seeing these definitions even without explicitly including any C++ ABI-related headers.
Add a flag to indicate that instance variables have an extended type
encoding.
Remove the alignment field and replace it with 6 bits from the flags
field. We only support power of two alignments, so we may as well store
them in log form, which means we can save a field. Note that this
doesn't actually save us any space except on 32-bit platforms, because
alignment means that we end up with extra padding at the end of the
struct.
Every class is either a class or a metaclass, it doesn't make sense to
use two flags to store one bit of data.
Also remove the newabi flag from classes in the v2 ABI, where it's
redundant.
Several of the structures now end with an array of structures that may
have other fields added to them that the runtime doesn't know about yet
by a compiler. Rather than indexing into them directly, we must call an
accessor to find the correct address.
A few of the places where accesses were replaced were in functions where
it is safe because they only deal with versions of the structures that
are dynamically allocated (and will therefore have the correct size).
This was done to simplify future auditing: these fields should be
accessed directly only from the accessor functions in the header and
from the upgraders (currently in legacy.c).
Also fix a few bugs where the sizes weren't being filled in.
Methods now include a selector and extended type encoding, rather than a
method name and lgacy type encoding. Older ones are auto-upgraded.
Expose the extended type encoding via a function that JavaScriptCore
expects to exist.
This change set incorporates a number of changes that all needed to
happen together:
* The imp is now the first field of the `objc_method` structure. This
makes it possible to extend the structure without breaking anything
that relies on being able to access the IMP.
* There is no owner in the slot, so we must use other mechanisms for
determining the owner of a method (e.g. whether the same method appears
in the superclass)
* Again, because there is no owner in the slot, we can't use this as a
fast path for finding the C++ construct / destruct methods. These are
now cached in the class structure when they are found.
* The version field is gone from the slot and now we provide a global
version. This is based on the observation that method replacements
are relatively infrequent and the overhead of invalidating all method
caches is cheaper than adding extra state for every (class, method)
pair.
* A number of the runtime functions are simplified because replacing
the IMP in a `Method` now implicitly updates the dtable.
In the legact ABI, superclass pointers are initially set to strings
containing the superclass name and the runtime fixes them up. In the
new ABI, the compiler sets up the linkage directly.
In the new ABI, we use the legacy type encoding in the selector and the
extended type encoding in the types field. We want to only expose the
legacy type encoding through existing APIs.
Extended type encodings add more detailed information to object and
block types:
* Objects are encoded as @"ClassName".
* Blocks are encoded as @?<parameter type signature>
In the new ABI, we use classic type encodings for selectors and extended
type encodings everywhere else.