152 Commits (51b9a076f0c5d0d40b2e9cf7d356b58ccc92e9fe)

Author SHA1 Message Date
Hugo Melder e882423e5a
PowerPC {32, 64}-bit Block Trampolines (#272)
* Implement PowerPC block trampoline

* Adjust pagesize on ppc64

* Skip UnexpectedException test for PowerPC

* Move PAGE_SIZE to asmconstants.h

* Use PAGE_SIZE and PAGE_SHIFT macros for PowerPC

* Add ppc64el and powerpc qemu-crossbuild targets

* Add NO_SAFE_CACHING definition and guards

* Do not export objc_method_cache_version on ppc32

---------

Co-authored-by: David Chisnall <davidchisnall@users.noreply.github.com>
2 years ago
David Chisnall 377a81d237 Add support for fast-path alloc / init methods and direct methods.
The fast paths follow the pattern that we established for fast ARC:
Framework base classes can opt in by implementing a `+_TrivialAllocInit`
method.

This opt-in behaviour is inherited and is removed implicitly in any
subclass that implements alloc or init methods (alloc and init are
treated independently).

Compilers can emit calls to `objc_alloc(cls)` instead of `[cls alloc]`,
`objc_allocWithZone(cls)` instead of `[cls allocWithZone: NULL]`, and
`objc_alloc_init` instead of `[[cls alloc] init]`.

Direct methods don't require very much support in the runtime.  Apple
reuses their fast path for `-self` (which is supported only in the Apple
fork of clang, not the upstream version) for a fast init.  Given that
the first few fields of the runtime's class structure have been stable
for around 30 years, I'm happy moving the flags word (and the
initialised bit, in particular) into the public ABI.  This lets us do a
fast-path check for whether a class is initialised in class methods and
call `objc_send_initialize` if it isn't.  This function is now exposed
as part of the public ABI, it was there already and does the relevant
checks without invoking any of the message-sending machinery.

Fixes #165 #169
2 years ago
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 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 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
Frederik Seiffert 3b6b960810 Add objc_setUncaughtExceptionHandler() API 2 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 bdf03cb55d Update runtime defines to match Apple platforms 4 years ago
Frederik Seiffert 2d976b61e2 Export objc_enumerationMutation() function. 5 years ago
Frederik Seiffert d20947bab9 Export encoding functions. 5 years ago
David Chisnall f78b684db3 Fix build with -fno-common
Several of the hooks were being generated with common linkage in hooks.c
and as normal initialised symbols in sendmsg2.c.  Recent clang defaults
to -fno-common, which causes the common linkage versions to become
strong symbols and then causes a linkage failure from duplicate
definitions: one zero initialised, one initialised with a real value.

This removes copy in hooks.c, retaining only the initialised version.

Fixes #171
5 years ago
David Chisnall 8560a65f21 Add a missing `extern "C"` to slot.h.
Fixes #117
7 years ago
David Chisnall e6e86d309b
Merge pull request #116 from jordo/cpp-compile-fix
_Bool fix for cpp compilation
7 years ago
Jordan Schidlowsky 6e3c618b82 cleanup in blocks runtime for closer consistency with apple 7 years ago
Frederik Seiffert 5308d21c1e Use const pointers for associated object keys.
Matches Apple platform implementations.
7 years ago
Jordan Schidlowsky a1a3b7a4db cleanup cpp and c defines 7 years ago
Jordan Schidlowsky 72b1f9d1fa _Bool fix for cpp compilation 7 years ago
Frederik Seiffert a2463192d0 Use `id` as type for block runtime functions.
Fixes #103.
7 years ago
David Chisnall d015f0160c Rename PUBLIC to OBJC_PUBLIC to avoid some namespace pollution. 7 years ago
David Chisnall 70a12d3612 Apparently PUBLIC doesn't mean what I think it means.
It probably should be renamed OBJC_PUBLIC anyway, because it's a bit
rude to leak an identifier like that into the global namespace.
7 years ago
David Chisnall 4a8d125b3f Fix linkage type for objc_method_cache_version.
This was accidentally common linkage, so ended up with copy relocations.
7 years ago
David Chisnall da5e411d24 Add two Apple-compatible block introspection functions. 7 years ago
David Chisnall a9acb9c5b6 Add missing file. 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
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 0c9ee8b920 Improve protocol tests and fix bugs.
Also add the new protocol_getProperties2 function.
8 years ago
David Chisnall b81df02b91 Merge branch 'master' into newabi
Simplify the setSubclass dtable updating mechanism.
8 years ago
David Chisnall 040114dff1 Remove some obsolete documentation. 8 years ago
David Chisnall 4891eb9d5f Document a bit more of class structure and of type encodings. 8 years ago
David Chisnall ab84589b5d Improve protocol method metadata.
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.
8 years ago
David Chisnall 93b3f889a6 Update documentation. 8 years ago
David Chisnall a8752cd842 Clean up method / slot lookup interfaces. 8 years ago
David Chisnall a9a2ed6b10 Refactor to use `objc_method` as the slot.
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.
8 years ago
David Chisnall 3c036b3f4f Use nullptr for nil in C++11. 8 years ago
Dustin L. Howett 21ad183e3e Wrap some headers in extern C for C++ compat. 8 years ago
David Chisnall 76e7d4b07f Merge branch 'master' into newabi 8 years ago
David Chisnall 12b820cb99 Add refcount accessor function. 8 years ago
David Chisnall 458bd3c7a2 Add interfaces for better integration with Foundation. 8 years ago
David Chisnall af4e0719ff Checkpoint work on improving weak reference efficiency. 8 years ago
Zenny Chen 5f01917a49 Update blocks_runtime.h (#45)
Update blocks_runtime.h to be compatible with Apple / LLVM version.
8 years ago
David Chisnall a54272c1ab Merge origin/master into newabi (using imerge) 8 years ago
Daniel Ferreira 1593ac04af Add objc-class.h to objc headers
Some applications still include the old objc-class.h header expecting
to obtain the declarations contained in objc/message.h and
objc/runtime.h nowadays. This commit adds this header to achieve
out-of-the-box compatibility with these applications.
9 years ago
Daniel Ferreira a3e1a0d3ed Add objc-runtime.h to objc headers
Some applications still include the old objc-runtime.h header expecting
to obtain the declarations contained in objc/message.h and
objc/runtime.h nowadays. This commit adds this header to achieve
out-of-the-box compatibility with these applications.
9 years ago
David Chisnall 4a840374fe Fix typo in hooks.h. 10 years ago
David Chisnall c3c81796ca Rework slot handling so that the fields that are used for dispatch are
at the start of the structure, making it easier to change the layout in
the future.

Also clean up the growth of various fields and consolidate some of the
metadata into a pointer to the `struct objc_method`.
10 years ago
David Chisnall b952a21abe Add objc_msgSend for AArch64.
An interesting feature of the AArch64 ABI simplifies this code relative to other platforms.  AArch64 reserves an extra register (x8) for the address of struct returns, giving the
10 years ago
theraven f50bc6cf33 Added support for tracing message sends to the runtime.
Currently x86-64 only.
13 years ago
theraven 93e297fd87 Unconditionally make message.h a system header to work around an old-clang bug. 13 years ago