1090 Commits (6e52cbbbe864a6f76619ff499d48837637ce4921)
 

Author SHA1 Message Date
David Chisnall 6e52cbbbe8 Make SEH exception handling work on 32- and 64-bit Windows.
Also change the expected mangling to reflect in-progress Clang changes.
8 years ago
David Chisnall d4278a009c Fix an integer underflow bug.
We weren't correctly sign-extending the value being compared, which was
resulting in objects not being deallocated.  For some reason, this only
appeared on Windows, even though the code looked wrong on all platforms.
8 years ago
David Chisnall 3fc3e11296 Fix building the runtime test on Windows. 8 years ago
David Chisnall bab334acd4 Fix cmake configuration for Windows builds. 8 years ago
David Chisnall aa558900bd Fix an off-by-one error in the hash table.
When removing a hash entry that was in the cell assigned to its hash, we
would clear the first bit in the second maps.  If this entry was a
secondary value with the same hash, then this value became unreachable.

This very rarely showed up for two reasons.  First, most of the tables
are insert-only and so we never try to remove things from them.  Second,
it requires a particular sequence of inserts.  It occasionally caused
weak references to be susceptible to use after free.
8 years ago
David Chisnall 934cd13a7a Initial pass at Windows support.
All tests now pass with the new ABI on x86-64, with the new ABI.  Some
of the code is ugly and other platforms are probably broken.
8 years ago
Dustin L. Howett f352f62423 Add a MSVC/VS2017-compatible objc_exception_{,re}throw
This implementation of objc_exception_throw constructs a
_CxxThrowException-compatible ThrowInfo based on the runtime type of the
passed-in exception. Everything pertaining to the exception is allocated
on the stack before the call and destroyed when/if the stack frame is
aborted.

The construction of ThrowInfo, CatchableTypes, and TypeDescriptors, as
well as mangling, is compatible with Clang/LLVM's MicrosoftCXXABI
exception generator.

This ties Objective-C exceptions on Windows to the C++ exception model,
which allows us to support (unboxed) foreign exceptions and C++ catch of
Objective-C types.

objc_exception_rethrow recycles MicrosoftCXXABI's rethrow.

Contributing-author: Jordan Saunders <jmsaunde@microsoft.com>
Contributing-author: Shayne Hiet-Block <shaynehi@microsoft.com>
8 years ago
David Chisnall 38efd04e33 Fix some bugs in protocol upgrading from old ABIs.
Reported by Riccardo Mottola!
8 years ago
David Chisnall 43f557e26e Add the size field to the ivar structure.
This was the last change made to the ABI before upstreaming the clang
parts.
8 years ago
David Chisnall 22abbd2ca2 Fix a bug in hidden class deletion.
We were leaving the isa pointer pointing to the deleted class and were
then following its super_class pointer, both of which are potentially
serious.  This didn't show up on FreeBSD, because the relevant memory
was always returned to a thread-local pool and the accesses were
immediately afterwards, so it always worked.  It broke with malloc
implementations that were more aggressive about checking for
use-after-free.
8 years ago
David Chisnall 0ae4e4ceb7 Remove the need to include C++ <exception>
We were only doing it to get two definitions, which are both mandated by
the spec, so we may as well avoid all of the headaches involved.

Also remove the extern "C" from the runtime.h include while we're here,
as it is no longer needed.

Fixes #69
8 years ago
David Chisnall 4e9fd2ec8a Rename objc_slot and objc_slot_v1.
The objc_slot type was exposed via public interfaces and the renaming
broke things (including the GNUstep build).
8 years ago
David Chisnall f569aeb42b Add 1.9 release announcement to 2.x series. 8 years ago
David Chisnall f48403d51c Add commented code for iterating over constant strings. 8 years ago
David Chisnall c5cc4b9742 Update 2.0 release announcement. 8 years ago
David Chisnall 24984bffc5 Merge branch 'master' into newabi
No functionality change, some of the fixes from this branch have been
back-ported to master and this merge is just to fix up the history.
8 years ago
David Chisnall a5a0f70a03 Unregister classes when deleting them.
Coverage checking of the test suite showed that objc_disposeClassPair
wasn't tested at all, which then led to discovering that it didn't
unregister the class.
8 years ago
David Chisnall 554c6623dc Back-port constant string test from newabi branch. 8 years ago
David Chisnall f2b5988596 Add constant string test. 8 years ago
David Chisnall 0828b11125 Improve ARC test and fix bugs it uncovered.
This cleans up handling of objects that are not reference counted and
makes their interactions with ARC more consistent.  We should probably
generalise this somewhat - it currently special cases NSConstantString
and NSGlobalBlock, but it would be nice to have an API for constant
objects.
8 years ago
David Chisnall ca1d45a4e6 Fix dangling reference in weak ref code.
Another test added as a result of coverage analysis.
8 years ago
David Chisnall d89a1cafb7 Improve protocol test coverage. 8 years ago
David Chisnall 0c9ee8b920 Improve protocol tests and fix bugs.
Also add the new protocol_getProperties2 function.
8 years ago
David Chisnall 8eb06a3b15 Improve ARC test and fix bugs it uncovered.
This cleans up handling of objects that are not reference counted and
makes their interactions with ARC more consistent.  We should probably
generalise this somewhat - it currently special cases NSConstantString
and NSGlobalBlock, but it would be nice to have an API for constant
objects.
8 years ago
David Chisnall 2e32888296 Remove profiling support.
This was used with an old LLVM pass to perform speculative inlining.  It
is no longer maintained and this code hasn't been tested at all for
years or with nontrivial examples ever.
8 years ago
David Chisnall 4973b8d58a Dom't build an unused private function.
This is useful when debugging, but it's not used by default.
8 years ago
David Chisnall b37815caf7 Remove unreachable case statement. 8 years ago
David Chisnall c6aaf560c1 Fix dangling reference in weak ref code.
Another test added as a result of coverage analysis.
8 years ago
David Chisnall 29a35ab8ba Set profiling environment variable when tests are run.
This has no effect most of the time, but if the runtime is built with
llvm-cov support, then this will cause each test to emit a .profraw
file, which can be merged with:

$ llvm-profdata merge -sparse Test/*.profraw -o libobjc.profdata

This can then be used to generate coverage reports from the test suite
and find code paths that are not currently being tested.
8 years ago
David Chisnall c865b519b0 Unregister classes when deleting them.
Coverage checking of the test suite showed that objc_disposeClassPair
wasn't tested at all, which then led to discovering that it didn't
unregister the class.
8 years ago
David Chisnall c9e8743095 GC some dead code and move another legacy-compat file under the correct
option.
8 years ago
David Chisnall d4b1866170 Remove stale file. 8 years ago
David Chisnall 2934a98503 Support building without support for old ABIs. 8 years ago
David Chisnall 0f1385e1b1 Correctly upgrade categories.
This was hidden by a compiler bug where the new version was generated in
the same format as the old, so upgrading in the wrong place worked.
8 years ago
David Chisnall d11a0311e0 Add checks to prevent mixing incompatible ABI versions. 8 years ago
David Chisnall b81df02b91 Merge branch 'master' into newabi
Simplify the setSubclass dtable updating mechanism.
8 years ago
David Chisnall 8021533d4c Don't allocate objects of size 0.
There's nowhere for the class pointer, so there's nothing that you can
do with them.
8 years ago
David Chisnall 2bdf85ee50 Add missing isa pointer.
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.
8 years ago
David Chisnall a4f97f7563 Refactor locking in setSuperclass.
Now all lock ownership is tied to scopes, so will be released correctly
in all return paths.
8 years ago
David Chisnall 00d23b0013 Fix LOCK_SCOPE to allow multiple locks per scope. 8 years ago
davidchisnall fd526bc31f
Merge pull request #70 from Microsoft/css_deadlock
Let go of the runtime lock properly in class_setSuperclass
8 years ago
Dustin Howett d32bafc6e1 Let go of the runtime lock properly in class_setSuperclass 8 years ago
Jason Barmparesos 682717b08d Clang++ provides its own exception types on Linux. (#68)
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.
8 years ago
David Chisnall c50db7b1fe Remove debug log message. 8 years ago
David Chisnall 6c9edcb510 Support new NSConstantString format and update tests. 8 years ago
David Chisnall aba97e11b4 Fix ivar_ownership type name. 8 years ago
David Chisnall 67cf43c5a2 Add support for class properties in protocols. 8 years ago
David Chisnall 040114dff1 Remove some obsolete documentation. 8 years ago
David Chisnall c1391b5079 Add test for class property in category. 8 years ago
David Chisnall aba7e406ff Add test for class properties. 8 years ago