* include/lightning.h, include/lightning/jit_private.h,
lib/jit_aarch64-cpu.c, lib/jit_aarch64.c,
lib/jit_alpha-cpu.c, lib/jit_alpha.c,
lib/jit_arm-cpu.c, lib/jit_arm.c,
lib/jit_hppa-cpu.c, lib/jit_hppa.c,
lib/jit_ia64-cpu.c, lib/jit_ia64.c,
lib/jit_mips-cpu.c, lib/jit_mips.c,
lib/jit_ppc-cpu.c, lib/jit_ppc.c,
lib/jit_s390-cpu.c, lib/jit_s390.c,
lib/jit_sparc-cpu.c, lib/jit_sparc.c,
lib/jit_x86-cpu.c, lib/jit_x86.c: Implement the new
jit_allocar(offs, size) interface, that receives
two integer registers arguments, allocates space
dynamically in the stack, returns the offset in
the first argument, and uses the second argument
for the size in bytes of the memory to be allocated.
* check/allocar.ok, check/allocar.tst: New files
implementing test cases for the new jit_allocar
interface.
* check/Makefile.am, check/lightning.c: Update for
the new test case and interface.
* doc/body.texi: Add documentation of the new
interface.
* include/lightning/jit_x86.h, lib/jit_x86-cpu.c,
lib/jit_x86-x87.c: No longer make st(7) available.
Need to keep one x87 slots empty to avoid exceptions.
This has the side effect of no longer needing the
hackish emms instruction before a function call.
* lib/lightning.c: Remove the jit_regno_patch bitfield
register fields before actual emit, as it is only really
used before emit, otherwise, on special conditions it
may consider live registers as dead during code emit.
* lib/jit_x86-cpu.c, lib/jit_x86-sse.c, lib/jit_x86-x87.c:
Correct encoding of ldxr* stxr* in the x32 abi. If the
displacement register is negative, it would generate
a 64 bit instruction with a 32 bit unsigned displacement.
* check/ranger.tst, check/ranger.ok: New files, implementing
a test case for negative loads and stores. This is range.tst
converted to use registers instead of immediate offsets.
check/Makefile.am: Update for the new test case.
* lib/jit_size.c: Preventively use at least 144 bytes
if JIT_INSTR_MAX is less than it. The logic is not
guaranteed to be 100% precise, it is mostly heuristics
to allocate a buffer with as close as possible size,
but a wrong value may cause code generation to write
past the end of the buffer.
* lib/lightning.c: Correct the reason the bug in
simplify_stxi was not triggered before, it was due to
incorrectly resetting the value->code field, what was
causing it to never properly optimize:
stxi Im0 Rb0 Rt0
ldxi Rt1 Rb1 Im1
when Rb0 == Rb1, Rt0 == Rt1 and Im0 == Im1
There was another possible issue, that has been also
addressed in this commit, that would be the case of
Rbn == Rtn, where no redundancy removal is possible.
* lib/lightning.c: Correct wrong check in simplify_stxi.
The test was incorrectly comparing the target register
and the displacement offset. This was a time bomb bug,
that would trigger in code like:
stxi Im0 Rb0 Rt0
stxi Im1 Rb1 Rt1
if Rb0 == Rb1 && Rt0 == Rt1 && Im0 == Rt1, that is,
the wrong check was Im0 == Rt1, instead of the supposed
Im0 == Imm1 (that was what the code mean't to do). It
was removing the second stxi assuming it was redundantly
generated; as that is not uncommon pattern on
translators generating jit.
* configure.ac, include/lightning/jit_private.h,
lib/jit_aarch64.c, lib/jit_alpha.c, lib/jit_arm.c,
lib/jit_disasm.c, lib/jit_hppa.c, lib/jit_ia64.c,
lib/jit_mips.c, lib/jit_ppc.c, lib/jit_print.c,
lib/jit_s390.c, lib/jit_sparc.c, lib/jit_x86.c: Add a new
--enable-devel-disassembler option, that should be used
during development, or lightning debug. This option
intermixes previous jit_print and jit_disassemble
output, making it easier to visualize what lightning
call was used, and what code was generated.
* doc/body.texi: Reorder documentation, making jit_frame
and jit_tramp the lightning response to the need of
trampolines, continuations and tail call optimizations.
A pseudo code example of a factorial function was added.
Also added a section for description of the available
predicates.
* doc/fact.c: New file, implementing a simple example of
a translation of a trivial, recursive, tail call optimization
into lightning calls. This is the conversion to functional C
code of the example in doc/body.texi.
* doc/Makefile.am: Update for the next test case.
* include/lightning.h, lib/jit_aarch64.c,
lib/jit_alpha.c, lib/jit_arm-vfp.c, lib/jit_arm.c,
lib/jit_hppa.c, lib/jit_ia64.c, lib/jit_mips.c,
lib/jit_ppc.c, lib/jit_s390.c, lib/jit_sparc.c,
lib/jit_x86.c: Add the new jit_arg_register_p predicate.
The predicate is expected to be used to know if an
argument is in a register, what would need special
handling if code that can overwrite non callee save
registers is executed.
* check/carg.c: New test case to check consistency and
expected usage of jit_arg_register_p.
* check/Makefile.am: Update for new test case.
* include/lightning/jit_aarch64.h,
include/lightning/jit_alpha.h,
include/lightning/jit_arm.h,
include/lightning/jit_hppa.h,
include/lightning/jit_mips.h,
include/lightning/jit_ppc.h,
include/lightning/jit_s390.h,
include/lightning/jit_sparc.h,
include/lightning/jit_x86.h,
lib/jit_aarch64.c, lib/jit_alpha.c,
lib/jit_arm.c, lib/jit_hppa.c,
lib/jit_ia64.c, lib/jit_mips.c,
lib/jit_ppc.c, lib/jit_s390.c,
lib/jit_sparc.c, lib/jit_x86.c: Remove jit_arg_reg_p and
jit_arg_f_reg_p from a public header, and define it only
on port specific files where an integer offset is used
to qualify an argument identifier. Exported code expects
an opaque pointer (but of jit_node_t* type) to "qualify"
an argument identifier.
This patch, and the code review/simplification done during
it also corrected some bugs:
o Inconsistent jit_arg_d value of double argument after 3
integer arguments in arm for jit_functions; tested, C
functions were being properly called.
o Inconsistent use of getarg_{f,d} and putarg*_{f,d} on
s390 (32-bit) that happened to not have a proper test
case, as it would only happen for jit functions, and
tested, called C functions had proper arguments.
o Corrected a "last minute" correction that did not go
to the committed version, and would not compile on hppa,
due to bad _jit_putargi_d prototype definition.
* include/lightning.h, lib/jit_aarch64.c,
lib/jit_alpha.c, lib/jit_arm.c, lib/jit_hppa.c,
lib/jit_ia64.c, lib/jit_mips.c, lib/jit_ppc.c,
lib/jit_s390.c, lib/jit_sparc.c, lib/jit_x86.c:
Implement jit_putarg*. It works as a mix of jit_getarg*
and jit_pusharg*, in the way that the first argument is
a register or immediate, and the second is a pointer
returned by jit_arg*. The use of the interface is to change
values of arguments to the current jit function.
* check/put.ok, check/put.tst: New test cases exercising
the new jit_putarg* interface.
* check/Makefile.am, check/lightning.c: Update for the
new test case and interface.
* include/lightning.h, include/lightning/jit_private.h,
include/lightning/jit_s390x.h, lib/jit_disasm.c,
lib/jit_s390x-cpu.c, lib/jit_s390x-fpu.c, lib/jit_s390x-sz.c,
lib/jit_s390x.c, lib/jit_size.c, lib/lightning.c:
Add support for generating jit for s390 32 bit. This change
also removed %f15 from the list of temporaries fpr registers;
it was not being used, but if were, it would corrupt the
stack frame because the spill address would overwrite grp
offsets.
* include/lightning.h: Split jit_htonr in the new 3 interfaces
jit_htonr_us, jit_htonr_ui and jit_htonr_ul, the later only
available on 64 bit. The plain/untyped jit_htonr macro call
maps to the wordsize one.
* lib/jit_aarch64-cpu.c, lib/jit_aarch64-sz.c, lib/jit_aarch64.c,
lib/jit_alpha-cpu.c, lib/jit_alpha-sz.c, lib/jit_alpha.c,
lib/jit_arm-cpu.c, lib/jit_arm-sz.c, lib/jit_arm.c,
lib/jit_hppa-cpu.c, lib/jit_hppa-sz.c, lib/jit_hppa.c,
lib/jit_ia64-cpu.c, lib/jit_ia64-sz.c, lib/jit_ia64.c,
lib/jit_mips-cpu.c, lib/jit_mips-sz.c, lib/jit_mips.c,
lib/jit_ppc-cpu.c, lib/jit_ppc-sz.c, lib/jit_ppc.c,
lib/jit_s390x-cpu.c, lib/jit_s390x-sz.c, lib/jit_s390x.c,
lib/jit_sparc-cpu.c, lib/jit_sparc-sz.c, lib/jit_sparc.c,
lib/jit_x86-cpu.c, lib/jit_x86-sz.c, lib/jit_x86.c:
Update backends for the new jit_htonr*.
* check/lightning.c, lib/jit_names.c, lib/lightning.c:
Update for the new jit_htonr* interfaces.
* check/Makefile.am: Update for new test cases.
* check/hton.ok, check/hton.tst: New test cases.
* include/lightning/jit_private.h, include/lightning/jit_x86.h,
lib/jit_disasm.c, lib/jit_x86-cpu.c, lib/jit_x86-sse.c,
lib/jit_x86-sz.c, lib/jit_x86-x87.c, lib/jit_x86.c,
size.c: Implement support for the x32 abi. Built and
tested on Gentoo default/linux/amd64/13.0/x32 profile.
* lib/jit_arm.c: Call __clear_cache for every page.
This should only be required for older boards or
toolchain setup, but has been reported to be required
for lightning at some point.
* lib/jit_disasm.c: Change thumb or arm disassemble based on
jit code before disassembly.
* lib/jit_arm-cpu.c: Correct reversed arguments to LDRD and
STRD instructions, and correct checking for support of those.
* lib/jit_arm-swf.c: Correct wrong use of LDRD and STRD and
only use those if the register is even.
* check/check.arm.swf.sh, check/check.arm4.swf.sh: New files
to test LDRD and STRD, as well as the alternate code path
when those are not available, in the .arm4. test case.
* check/Makefile.am: Update for the new test cases.
* include/lightning/jit_private.h, lib/jit_aarch64.c,
lib/jit_alpha.c, lib/jit_arm.c, lib/jit_hppa.c,
lib/jit_ia64.c, lib/jit_mips.c, lib/jit_ppc.c,
lib/jit_s390x.c, lib/jit_sparc.c, lib/jit_x86.c:
Implement a private jit_flush call, that flushes
the cache, if applicable, aligning down to the
previous and up to the next page boundary.
* check/ctramp.c: New file. It just repeats the test
of tramp.tst, but using two jit_state_t, what should
test possible issues with two contexts, and also validate
jit_tramp works on backends with function descriptions.
* check/Makefile.am: Update for new test case.
* include/lightning/jit_mips.h: Do not make the t9 register
JIT_R11 (or JIT_R7 for n32 or n64 abi) available. Previously
it cause problems if one expects it to not be changed in a
function call. For example, calling a jit function, where it
really does not need to be changed.
Make jit_memcpy, jit_memmove, jit_data take const pointers to
allow jit_note to be used with a const string (e.g. a string
literal, __FILE__ or __func__). This is needed for GNU Smalltalk
to silence compiler warnings.
Sadly "const jit_pointer_t" is not the same as "typedef const void *"
so I introduced a new typedef for a const jit pointer. The other
option would be to replace jit_pointer_t with void*.
* lib/jit_aarch64.c, lib/jit_alpha.c, lib/jit_arm.c,
lib/jit_hppa.c, lib/jit_ia64.c, lib/jit_mips.c, lib/jit_ppc.c,
lib/jit_s390x.c, lib/jit_sparc.c, lib/jit_x86.c: Add an
assertion to all code generation "drivers" to ensure
_jitc->regarg is empty or in an expected state, after
translation of a lightning instruction to native code.
This change was a brute force test to find out other cases
of a temporary not being release (like was happening with
_bmsi and _bmci on x86), but no other case was found,
after running make check, with assertions enabled, on all
backends.