1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-30 17:00:23 +02:00
Commit graph

27 commits

Author SHA1 Message Date
Helmut Eller
f31fb0044d Fix some problems with callr and calli.
The problem with callr is that the register that contains the
function to be called, can be overwritten by the logic that moves
the values into argument registers.  To fix this, I added a
get_callr_temp function that should return a platform specific
register that is not used to pass arguments.  For Aarch64/Arm the
link registers seems to work; for Amd64/i686 the RAX register.
The function/tmp pair becomes an additional argument to the
parallel assigment; this way the original function register is not
accidentally overwritten.

The problem with calli is that it may not have enough temp
registers to move arguments.  The windmill paper says that at most
one temporary register is needed for the parallel assignment.
However, we also need a temp register for mem-to-mem moves.  So it
seems that we need a second temporary.  For Amd64/i686 we have
only one temporary GPR and one temporary FPR.  To fix this, I
modified the algorithm from the paper a bit: we perform the
mem-to-mem moves before the other moves.  Later when we need the
temp to break cycles, there shouldn't be any mem-to-mem moves
left.  So we should never need two temps at the same time.

* lightening/lightening.c: (get_callr_temp): New function; need
for each platform.
(prepare_call_args): Include the function/callr_temp pair in the
arguments for the parallel assignment.

* lightening/x86.c, lightening/arm.c, lightening/aarch64.c
(get_callr_temp): Implementation for each platform.

* lightening/arm.c (next_abi_arg): Fix the stack size for doubles.

* tests/call_10_2.c, tests/callr_10.c: New tests.
* tests/regarrays.inc: New file. Common code between the above two
tests that would be tedious to duplicate.
2022-06-08 16:20:42 +02:00
Andy Wingo
35cd7fac8b Fix jmp-shortening on x64 when target within instruction.
* lightening/x86.c (jit_try_shorten): If the address is within the
  last instruction, don't shorten.  If the intstruction is a jump, we
  could elide it entirely in some cases, but we don't know if the user
  captured the PC before calling jit_patch_here.  Better to leave this
  to the user.

Thanks to Helmut Eller for the bug report and test case in
https://gitlab.com/wingo/lightening/-/issues/17.
2021-01-07 11:04:17 +01:00
Andy Wingo
91c1591e41 Add support for emitting inline data and table switches
* lightening.h:
* lightening/lightening.c (jit_begin_data, jit_end_data)
  (jit_emit_u8, jit_emit_u16, jit_emit_u32, jit_emit_u64): Add new raw
  data-emitting primitives, bracketed by begin/end so that we can flush
  constant pools first, if needed.
* lightening/lightening.c (struct jit_state): Add new emitting_data
  flag.
  (jit_begin, jit_reset, jit_end): Handle the new flag.
  (emit_abs_reloc): Move here, from x86.c.
* lightening/x86.c (emit_abs_reloc): Remove.
  (jit_try_shorten): Don't shorten if loc == start; could be raw data.
* tests/jmp_table.c: New test.
2020-07-30 13:02:46 +02:00
Andy Wingo
a96c0188f1 Ensure 32 bytes of stack are reserved on 64-bit Windows targets
* lightening/x86.c (reset_abi_arg_iterator): Reserve 32 stack bytes on
  64-bit Windows systems, in accordance with ABI.  Thanks a million to
  Charles Stanhope for the patch and to Mike Gran for testing!
2020-02-17 22:01:14 +01:00
Andy Wingo
0b723c0401 ARMv7 backend passing all tests! 2019-05-20 15:20:33 +02:00
Andy Wingo
a643f99d68 Fix compilation on aarch64 2019-05-16 10:19:02 +02:00
Andy Wingo
0bfdcc7016 Refactor to add support for constant tables, shifted relocs 2019-05-14 15:53:25 +02:00
Andy Wingo
fc9b474da6 Refactor some bits from x86 to lightening 2019-05-10 14:14:32 +02:00
Andy Wingo
57b31f1111 Stack alignment is 16 even on x86-32 2019-04-29 16:12:38 +02:00
Andy Wingo
04cd8874de Stack alignment takes saved return address into account 2019-04-28 12:37:19 +02:00
Andy Wingo
d617315fdb Fix jit_leave_jit_abi to pop correct registers
Also relax stack alignment on 32-bit x86
2019-04-27 22:27:39 +02:00
Andy Wingo
fe34e3cdf1 Make jit_cpu private 2019-04-26 16:09:06 +02:00
Andy Wingo
bab1f40b5e Fix lightening to compile on 32-bit x86 2019-04-26 14:44:09 +02:00
Andy Wingo
89fd69fc00 Account for saved return address when locating args
Also, fix alignment to be in bytes rather than bits.  Oops!
2019-04-26 14:38:29 +02:00
Andy Wingo
04d89a7ce2 Implement reloc shortening, and remove unused functionality 2019-04-26 12:40:44 +02:00
Andy Wingo
796f263ed8 Remove unused jit_epilog definition 2019-04-26 11:40:06 +02:00
Andy Wingo
a3e044c808 Move jit_move_operands etc to common lightening.c file 2019-04-26 09:09:50 +02:00
Andy Wingo
2602f17fb4 Simplify register representation again
There's only one flag, "callee-save".  Also the regno range is limited
to 0-63 inclusive, to allow for cheap register sets as uint64_t values.
2019-04-25 19:12:55 +02:00
Andy Wingo
af4e0422ae Align stack on 64-bit targets for calls 2019-04-25 18:12:23 +02:00
Andy Wingo
ddd66a2f34 Simplify register representation
Instead of JIT_R0 being a wrapped index into a table which then gives
the regno and class, just have JIT_R0 be the wrapped regno and class.
2019-04-25 17:03:46 +02:00
Andy Wingo
b34e230413 Fix apply_addend bug
* lightening/x86.c (jit_move_operands): Fix bug when calling
  apply_addend.
2019-04-24 22:56:48 +02:00
Andy Wingo
4db777e12e Add support for operand addends
This can allow for better register allocation around calls for field
locations.
2019-04-24 15:52:07 +02:00
Andy Wingo
d07dac40ad Add proper parallel-moves solver
Add parallel assignment serializer from Guile, originating in the Caml
paper by Rideau et al.
2019-04-24 15:08:35 +02:00
Andy Wingo
0be4f7a2a1 Simplify API for loading call arguments 2019-04-22 09:15:03 +02:00
Andy Wingo
4e1876f294 Support spilling args to stack 2019-04-04 17:06:57 +02:00
Andy Wingo
ede10b101b Support immediate arguments 2019-04-04 12:09:41 +02:00
Andy Wingo
f348b8ed6d Change headers and files to be named "lightening" instead of "jit"
This improves integration with other projects.  Like for example Guile
already has files named jit.c and jit.h; it's easier to manage if
lightening uses its own file names.
2019-04-03 13:57:48 +02:00
Renamed from jit/x86.c (Browse further)