190 Commits (8e18060c1d78486178aa5e6f9009344a461c8d9d)

Author SHA1 Message Date
Hugo Melder ab23f14fd7
Initial Windows on ARM (AArch64) Support (#249)
* Conditionally include ntdll.dll

* Use text relocation instead of GOT

* Use FlushInstructionCache instead of clear_cache for arm64

* Load address in two stages (adrp, add)

* objc_msgSend.aarch64.S add comments

* Add seh directives

* Move .seh_proc into slow sloop section

* Comment out cfi directives

* Substitute raw .seh directives with macros

* Add documentation of SEH annotations

* Detect CPU Architecture with preprocessor

* Cleanup CMakeLists.txt

Co-authored-by: David Chisnall <davidchisnall@users.noreply.github.com>

* Remove line in objc_msgSend.aarch64.S

Co-authored-by: David Chisnall <davidchisnall@users.noreply.github.com>

* Change Test CMakeList to use ARCHITECTURE var

* Use existing clear cache macro

* Change _WIN64 to _WIN32 and reorder labels

* Remove macro and replace _WIN64 with _WIN32

* Remove argument from non-win32 macro

---------

Co-authored-by: David Chisnall <davidchisnall@users.noreply.github.com>
2 years ago
hmelder d0d28b8f9d Add include in UnexpectedException test 2 years ago
Frederik Seiffert 226455bd10 Tests: disable failing UnexpectedException test on ARM architectures 2 years ago
Frederik Seiffert 3b6b960810 Add objc_setUncaughtExceptionHandler() API 2 years ago
Frederik Seiffert 0aea4b2e93 Support _objc_unexpected_exception on Win32 2 years ago
Frederik Seiffert ca46e42516 Add test for unexpected exception hook 2 years ago
David Chisnall 71e38a048f Attempt to add QEMU to CI. 3 years ago
David Chisnall 7c23a07bb4 Various CMake cleanups and modernisations.
This adds a dependency on a version of CMake with support for Objective-C,
removing a number of hacks to make CMake work and introduces a few
modernisations:

 - Options use CMake's `option` mechanism.
 - A lot of things now use generator expressions, which should improve the
   things like the multi-config Ninja generator.
 - We no longer depend on hacks to build in CI.

At the same time, a few other things are simplified:

 - There is no longer support for building without C++ support and we depend on
   a C++ standard library, not just a runtime. This makes it possible to use
   more C++ features inside the runtime.
 - We no longer support clang-cl on Windows and instead require clang.exe.
 - Support for the Boehm GC has been removed.
3 years ago
David Chisnall 7ccc1db5a8 Modernise CI
CI was failing because a number of our host platforms were no longer
supported.  This commit:

 - Moves to the latest FreeBSD 12, 13, and 14 branch releases.
 - Moves to modern Ubuntu.
 - Replaces Windows 2016 with 2022
 - Moves from Azure Pipelines to GitHub for the non-FreeBSD tests.
 - Fixes some tests that are not reliable in some contexts.
3 years ago
Stefan Gränitz 8c600f5b56
Enable test ObjCXXEHInterop_arc on Windows for Clang 16+ (#233)
This test used to fail on Windows, because Clang's codegen and transformation haven't been in-line with the requirements of the WinEH backend in LLVM. The following changes implement the missing pieces and let the test to pass in both debug and release mode:

https://reviews.llvm.org/D128190 [WinEH] Apply funclet operand bundles to nounwind intrinsics that lower to function calls in the course of IR transforms
https://reviews.llvm.org/D134441 [ObjC][ARC] Fix target register for call expanded from CALL_RVMARKER on Windows
https://reviews.llvm.org/D137939 [CGObjC] Open cleanup scope before SaveAndRestore CurrentFuncletPad and push CatchRetScope early
https://reviews.llvm.org/D137944 [ObjC][ARC] Teach the OptimizeSequences step of ObjCARCOpts about WinEH funclet tokens
3 years ago
Frederik Seiffert a357cb999c
tests: Test that we can throw and catch the same exception multiple times sequentially. (#188)
This originally came up as an issue with libc++abi support (#152), but is not specific to that ABI.

* Use the C++ runtime to check for uncaught C++ exceptions.

As discussed in #152, use the function defined in the Itanium C++ ABI to
check whether the thrown exception is the current caught C++ exception
and needs rethrowing via `__cxa_rethrow()`.

Co-authored-by: Niels Grewe <grewe@ocean-insights.com>
Co-authored-by: David Chisnall <gnustep@theravensnest.org>
4 years ago
Graham--M 14619f2905
Fix autorelease pool emptying when new references are added (#218)
* Add test for emptying autorelease pool

* Fix arc autorelease pool emptying when adding further references
When releasing a reference in the arc autorelease pool, it is
possible and anticipated that new references may added to the pool.
This fix addresses an edge case where releasing a reference in the
same pool page as the stop position can add more references which
cause the insertion of a new page and emptyPool() returns early
after emptying the new page.
4 years ago
Frederik Seiffert b32ee7787d
Fix weak ref handling during dealloc (#215)
Add test for setting weak ref during dealloc

Fixes #214
4 years ago
Graham--M 921e3c3386 Strong retain calls should always return the instance pointer.
This fixes a regression in 73132a6 (#200) where nil was returned
from a retain call after the object begins deallocating. Normal
retains of a deallocating object are still expected to return an
instance pointer inside its dealloc method and code compiled with ARC
will generate calls to objc_storeStrong() when a block captures the
self pointer inside the dealloc method.
5 years ago
Graham--M 73132a6c98
Avoid dangling weak references to deallocating objects. (#200)
The previous checks for a deallocating object with negative reference count did not work because:
    1. the sign bit has to be recreated as was happening in objc_delete_weak_refs()
    2. there was no distinction between a saturated count and a negative reference count

refcount_max now indicates when the refcount has saturated and should no longer be mutated.
An underflow to -1 still maps to refcount_mask, allowing us to detect when an object is supposed to be deallocated.
Neither objc_release_fast_no_destroy_np() nor objc_retain_fast_np() mutate the refcount when it is one of those values, so the comment in objc_delete_weak_refs() was adjusted.
5 years ago
David Chisnall be6483de6d Improve constant string support in tests.
This makes no difference to existing tests, but is needed for the ones
in #138
6 years ago
David Chisnall 65d6b279a0 Rework C++ exception interop again.
We now, the first time we encounter a foreign exception, throw a C++
exception through a frame that has a custom personality function and
probe the layout of the __cxa_exception structure.
We then use the offsets learned from this along with the public ABI
functions for allocating the structure.

At the same time, add a test that we are correctly setting the count of
uncaught exceptions.

Fixes #146
6 years ago
David Chisnall 5a35fff19d Add test for checking whether a class supports fast ARC. 6 years ago
David Chisnall 78ff24516c Fix invoking missing superclass methods.
The lookup functions for the superclass paths were silently ignoring
missing methods, rather than calling the forwarding hook.

Fixes #153
6 years ago
David Chisnall 249acabbf4 Disable a test on Windows.
This is failing (and needs fixing) but it's unhelpful for CI to report
failures on Windows for PRs.
6 years ago
Niels Grewe 59815ebc10 fix test for class properties 6 years ago
David Chisnall 7c79dfc4c5 Add missing files. 6 years ago
David Chisnall aa775cf835 Fix ObjC++ interop bug.
The reworked wrapping of C++ exceptions meant that we were missing a
dereference of the result of __cxa_begin_catch.

Add a test that triggers this issue.  It would have occurred in the
non-ARC version if we actually did anything with the exception, but
compiling it in ARC mode makes the compiler insert retain / autorelease
around the exception object to ensure that it remains live.
6 years ago
Rupert Daniel 108d4e19c0 Updated BlockImpTest asserts. Fixes #126
assert now directly compares block self with expected class, avoiding
objc_msgSend.
6 years ago
Rupert Daniel 710b2368cc Fixed crash when using self in imp_implementationWithBlock on armv7a 6 years ago
David Chisnall 2fb1194cec Add test case for weak ref issue.
This test now fails deterministically, which should make fixing it
easier.
6 years ago
Frederik Seiffert 5308d21c1e Use const pointers for associated object keys.
Matches Apple platform implementations.
7 years ago
David Chisnall 375018a933 Fix upgrading legacy properties with qualifiers.
This fixes PropertyIntrospectionTest2_arc with the 1.x ABI and enables
the test that was disabled in this mode.
7 years ago
Frederik Seiffert 5aa82d059a Disabled atomic property tests on legacy ABI versions. 7 years ago
Frederik Seiffert fb32780698 Extended property introspection test with atomic-type property. 7 years ago
Frederik Seiffert 5917514ac1 Added test for atomic ivars. 7 years ago
David Chisnall 1ab65ca818 Replace incorrect magic number with sensible number. 7 years ago
David Chisnall 945bbd760d Mark some tests as big.
Setting these tests to use 3 processors is weird, but it means that in
CI (where we do 4 tests in parallel), we won't ever run more than one of
these at a time (though we can run any other one test at the same time
as these).  This should fix the intermittent failure.
7 years ago
David Chisnall c4cb965033 Add more assertions to ManyManySelectors test.
This is intermittently failing in CI.  It looks as if the CI machine is
running out of memory in a way that we are not gracefully handling.
7 years ago
David Chisnall 369c84db35 Fix compiler warnings. 7 years ago
David Chisnall 959a0f1998 Make alignTest pass on ARM.
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.
7 years ago
David Chisnall afee197c67 Rework some of the ivar offset calculations.
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.
7 years ago
David Chisnall eab35fce37 Work around clang 8 bug in test. 7 years ago
Dustin Howett f392ff1870 Fix dtable rebase and add a test for a missing case
The dtable rebasing rework in b81df02b broke the inheritance of
superclass methods from a superclass that had already been initialized.
7 years ago
David Chisnall e811e6ce32 Fix build failure in test. 7 years ago
David Chisnall 0da21d5064 Add some more Windows build tweaks.
This enables building on Windows with Ninja.
7 years ago
David Chisnall d0c3fe5323 Remove a broken assertion.
This was checking that a variable that was never assigned to was a
non-zero value.
7 years ago
David Chisnall 262cea96f5 Fix test for clang 8.
Clang 8 now rejects the thing that this is testing (which is good,
because it's a terrible idea).
7 years ago
David Chisnall b9b6198520 Improve the forward-declared protocol test. 8 years ago
David Chisnall 6ab3df0892 Improve the forward declare protocols test.
Make it not fail to build with older compilers and make it test the
thing that should be true with the new ABI.
8 years ago
David Chisnall 00c631c58e Fix a bug in a test. 8 years ago
David Chisnall 65d5adc9f7 Add some extra test cases to the exception test.
We were testing this in the ObjC++ interop test, but it makes sense to
run the test even when not building ObjC++.
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