Commit Graph
365 Commits
Author SHA1 Message Date
Richard Henderson 0172bc029c x86: Disable .org for Darwin 2015-01-05 10:01:37 -08:00
Richard Henderson 9f112619c1 x86: Best guess at update for Darwin 2015-01-05 10:01:37 -08:00
Nobuyoshi Nakada 7282d3289c x86: MSVC does not support Complex type 2014-12-22 17:14:40 +09:00
Nobuyoshi Nakada 5f8881a591 x86: Fix void pointer arithmetic 2014-12-22 17:08:08 +09:00
Richard Henderson 7ba30b1906 s390: Inline and tidy ffi_prep_args
As per discussion with Ulrich Weigand, document the restrictions
on the code within ffi_call_int as we simultaneously prepare
stack frames for ffi_call_SYSV and the target function.
2014-12-19 11:38:17 -05:00
Richard Henderson f69ec6f35d s390: Use pc-relative insns in 31-bit mode
It's silly to stick to esa/390 features when the compiler won't.
Detect when brasl and larl are used by the compiler and then use
them in the assembly.
2014-12-18 16:21:07 -05:00
Richard Henderson 2f530de168 s390: Reorganize assembly
Avoid using ffi_prep_args as a callback; do all the work setting
up the frame within ffi_call_int directly.  Save fewer registers
in ffi_closure_SYSV.
2014-12-18 16:01:59 -05:00
Richard Henderson 97512ded05 s390: Avoid aliasing warnings 2014-12-18 16:01:15 -05:00
Richard Henderson c860ca9ac0 s390: Kill trailing whitespace 2014-12-17 13:24:03 -05:00
Dominik Vogt 02b7c89967 s390: Go closure support 2014-12-17 13:20:51 -05:00
Anthony Green 75b2199f26 Merge pull request #157 from rth7680/x86
Two fixes for x86
2014-12-12 10:13:56 -05:00
Anthony Green 8a3a2723aa Merge pull request #156 from rth7680/sparc
sparc: Define FFI_TARGET_SPECIFIC_VARIADIC for v9
2014-12-12 10:13:27 -05:00
Richard Henderson 2f65246968 x86: Handle void arguments as if an empty structure
Since libffi currently doesn't allow empty structures, libgo
currently maps them to ffi_type_void.  Given that we'll abort
on this case, handle it gracefully.
2014-12-11 14:16:00 -08:00
Richard Henderson 097ccfd6a6 x86: Fix some unwind errors 2014-12-11 14:11:44 -08:00
James Greenhalgh 9ae3bc870e Fix for https://github.com/atgreen/libffi/issues/141 2014-12-06 23:58:41 -05:00
Richard Henderson 590663b30b powerpc: Fix ffi_go_closure_linux64
Unlike ffi_closure_LINUX64, this entry point is called normally,
so we already have the TOC in R2 and the closure in R11.

	* powerpc/linux64_closure.S (ffi_closure_LINUX64): Remove a
	register dependency chain.
	(ffi_go_closure_linux64): Don't load r11 or r2.
2014-11-20 11:35:12 +10:30
Alan Modra fa1040c111 GO closures for powerpc linux
Plus .cfi async unwind info, rearrangement of ffi_call_linux64 and
ffi_call_SYSV function params to avoid register copies, tweaks to
trampolines.

	* src/powerpc/ffitarget.h (FFI_GO_CLOSURES): Define.
	* src/powerpc/ffi.c (ffi_call_int): New function with extra
	closure param, and args rearranged on ffi_call_linux64 and
	ffi_call_SYSV calls, extracted from ..
	(ffi_call): ..here.
	(ffi_call_go, ffi_prep_go_closure): New functions.
	* src/powerpc/ffi_linux64.c (ffi_prep_closure_loc_linux64): Make
	hidden.  Only flush insn part of ELFv2 trampoline.  Don't shuffle
	ELFv1 trampoline.
	(ffi_closure_helper_LINUX64): Replace closure param with cif, fun,
	user_data params.
	* src/powerpc/ffi_powerpc.h (ffi_go_closure_sysv): Declare.
	(ffi_go_closure_linux64): Declare.
	(ffi_call_SYSV, fi_call_LINUX64): Update.
	(ffi_prep_closure_loc_sysv, ffi_prep_closure_loc_linux64): Declare.
	(ffi_closure_helper_SYSV, ffi_closure_helper_LINUX64): Update.
	* src/powerpc/ffi_sysv.c (ASM_NEEDS_REGISTERS): Increase to 6.
	(ffi_prep_closure_loc_sysv): Use bcl in trampoline, put data words
	last, flush just the insn part.
	(ffi_closure_helper_SYSV): Replace closure param with cif, fun and
	user_data params.
	* src/powerpc/linux64.S (ffi_call_LINUX64): Replace hand-written
	.eh_frame with .cfi directives.  Adjust for changed param order.
	Pass extra "closure" param to user function in static chain.  Add
	.cfi directives to describe epilogue.  Don't provide traceback
	table for ELFv2 or _CALL_LINUX.
	* src/powerpc/linux64_closure.S (ffi_closure_LINUX64): Replace
	hand-written .eh_frame with .cfi directives.  Adjust for changed
	ffi_closure_helper_LINUX64 params.  Add .cfi directives to
	describe epilogue.  Don't provide traceback table for ELFv2 or
	_CALL_LINUX.
	(ffi_go_closure_linux64): New function.
	* src/powerpc/sysv.S: Remove redundant .globl ffi_prep_args_SYSV.
	(ffi_call_SYSV): Make hidden.  Replace hand-written .eh_frame with
	.cfi directives.  Adjust for changed params.  Pass extra "closure"
	param to user function in static chain.  Add .cfi directives to
	describe epilogue.
	* src/powerpc/ppc_closure.S (ffi_closure_SYSV): Make hidden.
	Replace hand-written .eh_frame with .cfi directives.  Adjust for
	changed ffi_closure_helper_SYSV params.  Add .cfi directives to
	describe epilogue.  Don't just use nops in the dead __NO_FPRS__
	epilogues.
	(ffi_go_closure_sysv): New function.
2014-11-20 11:35:12 +10:30
Alan Modra d3d06f4c94 Fix powerpc breakage from 6e8a4460
* src/powerpc/ffitarget.h: #error on unexpected FFI_TYPE_LAST.
	(FFI_PPC_TYPE_LAST): Define.
	(FFI_TYPE_UINT128): Define in terms of FFI_PPC_TYPE_LAST.
	(FFI_SYSV_TYPE_SMALL_STRUCT, FFI_V2_TYPE_FLOAT_HOMOG): Likewise.
	(FFI_V2_TYPE_DOUBLE_HOMOG, FFI_V2_TYPE_SMALL_STRUCT): Likewise.
2014-11-20 11:35:12 +10:30
Richard Henderson 542e004710 sparc: Define FFI_TARGET_SPECIFIC_VARIADIC for v9
This is a port of

  http://gcc.gnu.org/viewcvs?rev=207763&root=gcc&view=rev

aka GCC PR libffi/60073, to the rewritten Sparc codebase.
Supposedly, we should have seen failures with the existing
libffi.call/cls_double_va.c testcase, but I hadn't.
Perhaps a gcc newer than 4.6.3 is required to see that...
2014-11-18 05:07:00 -08:00
Gregory Pakosz a9ed0c3a04 dlmalloc: change defined(i386) to defined(__i386__)
When compiling with --std==c99, GCC and clang don't define i386 but __i386__
2014-11-18 09:37:10 +01:00
Richard Henderson dea49e2020 x86: Fix typo in ffi_prep_go_closure
Used the wrong register for THISCALL and FASTCALL.
2014-11-14 13:07:47 +01:00
Richard Henderson f8632815a6 powerpc: Delete patch output
Clearly added by mistake.
2014-11-13 12:32:35 +01:00
Richard Henderson 0e303c0657 x86: Work around clang bugs
http://llvm.org/bugs/show_bug.cgi?21500
http://llvm.org/bugs/show_bug.cgi?21501
http://llvm.org/bugs/show_bug.cgi?21515
2014-11-12 03:58:58 -08:00
Richard Henderson 6eec410f15 sparc: Re-add abi compliant structure support
The original code, removed in the "rewrite" patch, was incorrect for
large structures, and required dynamic allocation of a trampoline on
every ffi_call.

Instead, allocate a 4k entry table of all possible structure returns.
The table is 80k, but is read-only and dynamically paged, which ought
to be better than allocating the trampoline.

This is difficult to test with gcc.  One can only use -O0 at present.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63668.
2014-11-12 09:36:11 +01:00
Richard Henderson 92022496ef sparc: Add support for Go closures 2014-11-12 09:36:11 +01:00
Richard Henderson ad89c2d9e9 sparc: Add support for complex types 2014-11-12 09:36:09 +01:00
Richard Henderson 20da5b4132 sparc: Handle more cases of structure return directly 2014-11-12 09:35:24 +01:00
Richard Henderson 0686c2e71c sparc: Preprocess float point struct return
We can eliminate recursion and speed structure return
by flattening a nested structure tree into a bitmask.
2014-11-12 09:35:24 +01:00
Richard Henderson 2b27890ba7 sparc: Rewrite everything
It's impossible to call between v8 and v9 ABIs, because of the stack bias
in the v9 ABI.  So let's not pretend it's just not implemented yet.  Split
the v9 code out to a separate file.

The register windows prevent ffi_call from setting up the entire stack
frame the assembly, but we needn't make an indirect call back to prep_args.
2014-11-12 09:35:21 +01:00
Richard Henderson 5d7b544505 sparc: Tidy up symbols
Assembly to use local labels, .type annotation, hidden annotation.
I do retain the _prefix for the symbols, but given that it wasn't
done consistently across all symbols, I doubt it's actually needed.
2014-11-12 09:34:24 +01:00
Richard Henderson fd4f7cc0ca sparc: Eliminate long double ifdefs 2014-11-12 09:34:24 +01:00
Richard Henderson ab83cbb90b arm: Add support for Go closures 2014-11-12 09:32:39 +01:00
Richard Henderson 6fa617dabc arm: Add argument space for the hidden struct return pointer
This should have been failing all along, but it's only
exposed by the complex_int test case.
2014-11-12 09:32:39 +01:00
Richard Henderson a529bec27b arm: Add support for complex types 2014-11-12 09:32:36 +01:00
Richard Henderson 5e88ebe627 arm: Remove internal FFI_TYPE constants
These have been replaced by the contents of internal.h.
2014-11-12 09:32:13 +01:00
Richard Henderson a4b785ea69 arm: Rewrite ffi_closure
Move the push of the argument registers into ffi_closure_SYSV,
reducing the size of the trampoline.
2014-11-12 09:32:13 +01:00
Richard Henderson e7f15f60e8 arm: Rewrite ffi_call
Use the trick to allocate the stack frame for ffi_call_SYSV
within ffi_call itself.
2014-11-12 09:32:13 +01:00
Richard Henderson a74a3aaddb arm: Rewrite vfp_type_p
Do not modify the ffi_type.  Rearrange the tests so that we
quickly eliminate structures that cannot match.  Return an
encoded value of element count and base type.
2014-11-12 09:32:13 +01:00
Richard Henderson 0d39b4bb69 arm: Deref ffi_put_arg arguments 2014-11-12 09:32:13 +01:00
Richard Henderson 57b24fb3f5 arm: Deref ffi_align argument 2014-11-12 09:32:13 +01:00
Richard Henderson c129bea82a arm: Reindent arm/ffi.c 2014-11-12 09:32:13 +01:00
Richard Henderson 9761b7bb70 alpha: Add support for Go closures 2014-11-12 09:31:21 +01:00
Richard Henderson f41bec3b57 alpha: Add support for complex types 2014-11-12 09:31:19 +01:00
Richard Henderson 5f917371af alpha: Clean up conversion of float values
Don't use "real" conversion to double, lest we raise
exceptions when passing signalling nans.
2014-11-12 09:30:59 +01:00
Richard Henderson 32a26b75ba alpha: Reorganize cif flags
Unties the backend from changes to FFI_TYPE_* constants, and allows
compilation to succeed after the addition of FFI_TYPE_COMPLEX.

Delete the hand-written unwind info.
2014-11-12 09:30:59 +01:00
Richard Henderson c6352b664c aarch64: Add support for Go closures 2014-11-12 09:29:32 +01:00
Richard Henderson 0e41c73b09 aarch64: Move x8 out of call_context
Reduces stack size.  It was only used by the closure, and there
are available argument registers.
2014-11-12 09:29:32 +01:00
Richard Henderson a992f8789b aarch64: Add support for complex types 2014-11-12 09:29:31 +01:00
Richard Henderson 658b2b5600 aarch64: Remove aarch64_flags
This field was useless from the start, since the normal flags
field is available for backend use.
2014-11-12 09:28:44 +01:00
Richard Henderson 4a3cbcaa4f aarch64: Unify scalar fp and hfa handling
Since an HFA of a single element is exactly the same as scalar,
this tidies things up a bit.
2014-11-12 09:28:44 +01:00