1340 Commits (3c42c64c14d912d5af31146d6dba435515b1defe)
 

Author SHA1 Message Date
Hugo Melder 3c42c64c14
Skip tests using objc_msgSend if not available (#263)
* Add __GNUSTEP_MSGSEND__ definition

* Mark test as skipped if return code is 77

* Skip tests using objc_msgSend if not available

* ManyManySelectors: Skip objc_msgSend if not available

* Skip UnexpectedException test on ARM and AArch64

* Add UnexpectedException.m to list of unit tests

* Call manyArgs with objc_msgSend directly
2 years ago
Hugo Melder 5cf2b7350e
AArch64 objc_msgSend: Fix argument corruption due to invalid stack pointer offset (#266)
* Fix argument corruption due to invalid sp offset

* Bump runtime version
2 years ago
Hugo Melder adedd68048
Initial RISC-V 64-bit Support (#261)
* RISC-V objc_msgSend implementation

* Use objc_msgSend.riscv64.S if requirements are met

* RISC-V 64-bit block trampoline

* Fix formatting

* Add riscv64 crossbuild in CI

* Exclude llvm 13 and 14 for riscv64 in CI

* Add RISC-V and Windows on ARM to ANNOUNCE

* Add comment to why we exclude architectures in qemu-crossbuild

* Remove duplicated entry in ANNOUNCE
2 years ago
Frederik Carlier 0771ddf3e5 Don't -fobjc-runtime=gnustep-2.0 as a global flag
The legacy tests will override this flag.
2 years ago
Frederik Carlier a61309b0d3 Support compiling on mingw (no exception handling) 2 years ago
Frederik Carlier 4d9d930940 Mark legacy API with OBJC_PUBLIC
Fixes compilation errors on MINGW when using the legacy API (-fobjc-runtime=gnustep-1.7 or -fobjc-runtime=gcc)
2 years ago
David Chisnall 83d2983e16
Update FreeBSD CI to supported versions. (#258) 2 years ago
Frederik Carlier d34e066483 Tests: Append CMAKE_BINARY_DIR to PATH on Windows
Avoids copying objc.dll to the tests directory.
2 years ago
Frederik Carlier 32c09c0029
Prefer system-provided robin-map (#248)
* Prefer system-provided robin-map

* Use find_package

* Use submodule

* PR feedback

* Include FetchContent
2 years ago
David Chisnall 8e18060c1d Update release notes. 2 years ago
Marco Rebhan 79a44f6e9a Remove GC leftovers from pkg-config file 2 years ago
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 5462768a17 CI: add LLVM 15, remove LLVM 12 on Ubuntu 22.04 2 years ago
Frederik Seiffert 55b3fba9c9 CI: schedule automatic and allow manual runs 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 b3f7b1bac3 Remove Boehm GC support code.
This removes all support for GC mode.

This was deprecated by Apple in OS X 10.8 (2012) and never supported in
iOS.  Very little code ever tried to use it with this runtime.

It's gone from the build system already.
3 years ago
David Chisnall e23882fb23 Rewrite the selector table in C++.
This replaces a few home-grown datastructures with third-party ones that
get a lot more testing:

 - The home-grown hopscotch hash table is moved to using robin map.  The
   original was designed to be lock free, but we've been using it behind
   a lock for ages.
 - The selector list is now a std::vector.
 - The types list now use std::forward_list.

This also removes a couple of code paths that haven't been used since we
started using the new ABI data structures internally and upgrading at
load time.

The new code tries to differentiate in the static type system between
registered and unregistered selectors.  The check for whether a selector
is registered is fragile and depends on no selector being mapped or
allocated in memory below the total number of selectors.  This check can
now disappear on most code paths.

On a single test machine (not guaranteed to be representative) the test
suite now completes around 20% faster.
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 1991b12355 Fix the `instance_size` field for upgraded classes.
The instance size was being reported incorrectly which meant that
associated objects looked for a reference list slightly after the end of
the object.

Fixes #228
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
Earl Robsham cd50e72f81
Fix lock-ordering during init (#237)
Reorders how locking is handled in `objc_send_initialize()` to prevent a deadlock.
Previously, contention on the low level spinlocks could cause a very intermittent deadlock:
  - Thread A : `objc_send_initialize()` holds the runtime lock, then tries to acquire the object lock on the metaclass, which needs to initialize the mutex for the new metaclass inside `referenceListForObject()`, so it tries to lock the `lock_for_pointer()` / `lock_spinlock()`
  - Thread B : `referenceListForObject()` holds a spinlock for an unrelated object while running `initHiddenClassForObject()` -> `allocateHiddenClass()`, which tries to acquire the runtime lock
If the metaclass object pointer in Thread A hashes to the same spinlock as the object in thread B, the runtime lock ends up deadlocked forever.
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 35ac9bc072 Don't pass ANDROID_ARM_NEON testing C++ runtime
Fixes building for Android arm64-v8a with NDK r25, which no longer supports this flag. Since we were passing this unconditionally we were previously inadvertently disabling NEON support if the flag wasn't set.
3 years ago
David Chisnall 5a4d0959b3 Update objc/runtime.h
Co-authored-by: Frederik Seiffert <frederik@algoriddim.com>
3 years ago
David Chisnall a094ad0a45 Add returns-retained annotation to class_createInstance. 3 years ago
Frederik Seiffert 7dee32ad1e CI: upgrade to Windows 2022 VM 4 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
Frederik Seiffert bdf03cb55d Update runtime defines to match Apple platforms 4 years ago
Alex Myczko 646c142f3c
fix typo (#208) 5 years ago
David Chisnall 396c9b553a
Delete some dead code containing bugs. (#205)
Fixes #203
5 years ago
mischievous 1094eb7a1c
Updated the class_copyMethodList (#206)
Updated the class_copyMethodList to clear the stack garbage for outCount if preset before checking the class is null
5 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 38f44a8752 Remove unused declares 5 years ago
Bernard Cafarelli 2deec335f6 Add pthreads to link libraries, not link flags
This fixes linking errors with --as-needed like:
ld: libobjc.so.4.6: undefined reference to `pthread_mutexattr_destroy'

Fixes #180
5 years ago
Frederik Seiffert 2d976b61e2 Export objc_enumerationMutation() function. 5 years ago
Frederik Seiffert 06da6a91c3 Suppress EH debug logs in release builds. 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
Graham Lee c399119694 Remove redundant declaration of __cxa_allocate_exception
Fixes #193
5 years ago
David Chisnall 93fbf4d4bc Increase testing matrix.
Add 32-bit x86-Linux builds.
Add building with the nightly LLVM releases.  There are some regressions
since LLVM 8 that would have been caught by this that we can hopefully
fix in time for the LLVM 12 release.
5 years ago
Frederik Seiffert a08828291c Add missing extern "C" in unwind-arm.h. 5 years ago
David Chisnall 15ae929a2c Add libc++abi note to ANNOUNCE. 5 years ago
David Chisnall b685cc94eb Reset ANNOUNCE after 2.1 release. 5 years ago
Niels Grewe 014f386f58 Add support for libc++abi.
Extends C++ interop with autodetected support for libc++abi in addition to the existing support for libcxxrt and libsubc++.

Fixes #142.
5 years ago