[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 04/09: Ensure tail caller and callee in jmpi test have c
From: |
Andy Wingo |
Subject: |
[Guile-commits] 04/09: Ensure tail caller and callee in jmpi test have compatible ABI |
Date: |
Thu, 30 Jul 2020 07:26:45 -0400 (EDT) |
wingo pushed a commit to branch master
in repository guile.
commit 6c7813a05f8772489a8543e10654d40558219baf
Author: Andy Wingo <wingo@igalia.com>
AuthorDate: Thu Jul 30 11:51:56 2020 +0200
Ensure tail caller and callee in jmpi test have compatible ABI
* tests/jmpi.c: Emit the tail callee using the JIT, to ensure that it
saves and restores registers in the same way as the caller. Fixes
#16.
---
tests/jmpi.c | 32 ++++++++++++++++++++++++++------
1 file changed, 26 insertions(+), 6 deletions(-)
diff --git a/tests/jmpi.c b/tests/jmpi.c
index 2f9213f..e73ace0 100644
--- a/tests/jmpi.c
+++ b/tests/jmpi.c
@@ -1,21 +1,41 @@
#include "test.h"
-static int tail(void) { return 42; }
+void *tail;
+
+static void *target;
static void
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
{
jit_begin(j, arena_base, arena_size);
-
- jit_jmpi(j, tail);
-
+ jit_enter_jit_abi(j, 0, 0, 0);
+ jit_movi(j, JIT_R0, 42);
+ jit_jmpi(j, target);
+ // Unreachable.
+ jit_breakpoint(j);
int (*f)(void) = jit_end(j, NULL);
-
ASSERT(f() == 42);
}
+// Make the tail-call target via a separate main_helper because probably the
new
+// arena will be allocated farther away, forcing nonlocal jumps.
+static void
+make_target(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+{
+ jit_begin(j, arena_base, arena_size);
+ size_t align = jit_enter_jit_abi(j, 0, 0, 0);
+ // Tail call target assumes tail caller called enter_jit_abi with compatible
+ // parameters.
+ target = jit_address(j);
+ jit_leave_jit_abi(j, 0, 0, align);
+ jit_retr(j, JIT_R0);
+ jit_end(j, NULL);
+
+ main_helper(0, NULL, run_test);
+}
+
int
main (int argc, char *argv[])
{
- return main_helper(argc, argv, run_test);
+ return main_helper(argc, argv, make_target);
}
- [Guile-commits] branch master updated (5e1748f -> 5342eb5), Andy Wingo, 2020/07/30
- [Guile-commits] 01/09: Add jtable instruction, Andy Wingo, 2020/07/30
- [Guile-commits] 02/09: Fix patch_veneer on aarch64, Andy Wingo, 2020/07/30
- [Guile-commits] 04/09: Ensure tail caller and callee in jmpi test have compatible ABI,
Andy Wingo <=
- [Guile-commits] 03/09: Merge branch 'fix-aarch64-veneers' into 'master', Andy Wingo, 2020/07/30
- [Guile-commits] 06/09: Add support for emitting inline data and table switches, Andy Wingo, 2020/07/30
- [Guile-commits] 07/09: Merge branch 'table-switch' into 'master', Andy Wingo, 2020/07/30
- [Guile-commits] 05/09: Merge branch 'fix-tail-call-test' into 'master', Andy Wingo, 2020/07/30
- [Guile-commits] 08/09: Merge https://gitlab.com/wingo/lightening master branch, Andy Wingo, 2020/07/30
- [Guile-commits] 09/09: Add JIT implementation for jtable, Andy Wingo, 2020/07/30