Re: new module 'jit/cache'

2023-12-20 Thread Marc Nieper-Wißkirchen
Do you have detailed test results/logs?

Thanks,

Marc

Am Di., 19. Dez. 2023 um 23:13 Uhr schrieb Bruno Haible :

> My (preliminary) test results:
>
> The test passes on x86_64, m68k, alpha, s390, s390x, riscv64, loongarch64.
>
> It fails on some platforms with i386, mips, sparc, arm, arm64
>
> It fails on all platforms with powerpc*, ia64.
>
> Bruno
>
>
>
>


Re: new module 'jit/cache'

2023-12-19 Thread Bruno Haible
My (preliminary) test results:

The test passes on x86_64, m68k, alpha, s390, s390x, riscv64, loongarch64.

It fails on some platforms with i386, mips, sparc, arm, arm64

It fails on all platforms with powerpc*, ia64.

Bruno






Re: new module 'jit/cache'

2023-12-19 Thread Bruno Haible
Hi Marc,

> I forgot to actually make use of the patched part in the test case; here is
> the full patch.  Please excuse the mess.

Looks good to me. As I want to start testing it, I committed the patch for you.

Bruno






Re: new module 'jit/cache'

2023-11-28 Thread Marc Nieper-Wißkirchen
I forgot to actually make use of the patched part in the test case; here is
the full patch.  Please excuse the mess.



Am Mo., 27. Nov. 2023 um 18:36 Uhr schrieb Marc Nieper-Wißkirchen <
marc.nieper+...@gmail.com>:

> Am Mo., 27. Nov. 2023 um 17:27 Uhr schrieb Marc Nieper-Wißkirchen <
> marc.nieper+...@gmail.com>:
>
> [...]
>
>
>
>> For the moment, I expect
>>>   - a SIGSEGV on powerpc*-aix, powerpc64-linux, ia64, hppa, and hppa64
>>> due to the structure of function pointers, see
>>>
>>> https://git.savannah.gnu.org/gitweb/?p=libffcall.git;a=blob;f=porting-tools/abis/function-pointer.txt
>>
>>
>> Thank you; I will try to incorporate this info into my test.
>>
>
> I have attached a patch file to review my ideas.  The code hasn't been
> checked on the platforms actually touched by the patch.  It has not been
> committed yet (and lacks a ChangeLog entry).
>
> Marc
>
>


jit-cache.patch
Description: Binary data


Re: new module 'jit/cache'

2023-11-27 Thread Marc Nieper-Wißkirchen
Am Mo., 27. Nov. 2023 um 17:27 Uhr schrieb Marc Nieper-Wißkirchen <
marc.nieper+...@gmail.com>:

[...]



> For the moment, I expect
>>   - a SIGSEGV on powerpc*-aix, powerpc64-linux, ia64, hppa, and hppa64
>> due to the structure of function pointers, see
>>
>> https://git.savannah.gnu.org/gitweb/?p=libffcall.git;a=blob;f=porting-tools/abis/function-pointer.txt
>
>
> Thank you; I will try to incorporate this info into my test.
>

I have attached a patch file to review my ideas.  The code hasn't been
checked on the platforms actually touched by the patch.  It has not been
committed yet (and lacks a ChangeLog entry).

Marc


jit-cache.patch
Description: Binary data


Re: new module 'jit/cache'

2023-11-27 Thread Marc Nieper-Wißkirchen
Am Sa., 25. Nov. 2023 um 21:19 Uhr schrieb Bruno Haible :

> Hello Marc,
>
> > Here is my attempt at a simple unit test for your new cache module.
> >
> > I have tested it on an x86 box (where the instruction cache is always in
> > sync) and on an Armv8 Raspberry, both running GNU/Linux.  Commenting out
> > the call to `clear_cache' shows that `clear_cache' is not a NOP on Arm
> and
> > that the test is actually doing a non-trivial test.
>
> Very nice! It is simpler than what I had expected (no per-CPU #ifdefs so
> far).
>

I am sure they will come as soon as it is tested on more platforms than
just GNU/Linux with x86_64 and aarch64.

The alternative would be to pull in the whole GNU lightning...

I've committed your patch (as two separate patches).
>
> I will test it on various platforms.
>
> For the moment, I expect
>   - a SIGSEGV on powerpc*-aix, powerpc64-linux, ia64, hppa, and hppa64
> due to the structure of function pointers, see
>
> https://git.savannah.gnu.org/gitweb/?p=libffcall.git;a=blob;f=porting-tools/abis/function-pointer.txt


Thank you; I will try to incorporate this info into my test.

  - a link error on native Windows, due to the use of mprotect() outside
> #ifdefs.
>

Of course! I am going to fix this.


Re: new module 'jit/cache'

2023-11-25 Thread Bruno Haible
Hello Marc,

> Here is my attempt at a simple unit test for your new cache module.
> 
> I have tested it on an x86 box (where the instruction cache is always in
> sync) and on an Armv8 Raspberry, both running GNU/Linux.  Commenting out
> the call to `clear_cache' shows that `clear_cache' is not a NOP on Arm and
> that the test is actually doing a non-trivial test.

Very nice! It is simpler than what I had expected (no per-CPU #ifdefs so far).

I've committed your patch (as two separate patches).

I will test it on various platforms.

For the moment, I expect
  - a SIGSEGV on powerpc*-aix, powerpc64-linux, ia64, hppa, and hppa64
due to the structure of function pointers, see

https://git.savannah.gnu.org/gitweb/?p=libffcall.git;a=blob;f=porting-tools/abis/function-pointer.txt
  - a link error on native Windows, due to the use of mprotect() outside
#ifdefs.

But we'll see...

Bruno






Re: new module 'jit/cache'

2023-11-25 Thread Marc Nieper-Wißkirchen
Hello Bruno,

Here is my attempt at a simple unit test for your new cache module.

I have tested it on an x86 box (where the instruction cache is always in
sync) and on an Armv8 Raspberry, both running GNU/Linux.  Commenting out
the call to `clear_cache' shows that `clear_cache' is not a NOP on Arm and
that the test is actually doing a non-trivial test.

Best,

Marc

Am Mo., 13. Nov. 2023 um 14:33 Uhr schrieb Bruno Haible :

> >   * m4/valgrind-helper.m4: New file.
>
> Oops, that file was incomplete. Fixed like this:
>
>
> 2023-11-13  Bruno Haible  
>
> jit/cache: Fix configure test.
> * m4/valgrind-helper.m4 (gl_VALGRIND_HELPER): Check already at
> configure
> time whether  exists. Fix AC_DEFINE_UNQUOTED
> invocation.
>
> diff --git a/m4/valgrind-helper.m4 b/m4/valgrind-helper.m4
> index b3d70a7ad9..99c31030b9 100644
> --- a/m4/valgrind-helper.m4
> +++ b/m4/valgrind-helper.m4
> @@ -1,4 +1,4 @@
> -# valgrind-helper.m4 serial 1
> +# valgrind-helper.m4 serial 2
>  dnl Copyright (C) 2023 Free Software Foundation, Inc.
>  dnl This file is free software; the Free Software Foundation
>  dnl gives unlimited permission to copy and/or distribute it,
> @@ -18,5 +18,13 @@ AC_DEFUN_ONCE([gl_VALGRIND_HELPER]
> support_valgrind=0
>   fi
>  ])
> -  AC_DEFINE_UNQUOTED([ENABLE_VALGRIND_SUPPORT], [$support_valgrind])
> +  if test $support_valgrind = 1; then
> +AC_CHECK_HEADERS([valgrind/valgrind.h])
> +if test $ac_cv_header_valgrind_valgrind_h != yes; then
> +  AC_MSG_ERROR([cannot enable valgrind support: 
> not found])
> +fi
> +  fi
> +  AC_DEFINE_UNQUOTED([ENABLE_VALGRIND_SUPPORT], [$support_valgrind],
> +[Define to 1 to include support for running the binaries under
> valgrind,
> + or to 0 otherwise.])
>  ])
>
>
>
>
From 335cc8f54e4510d4a9025a401cc67a7d32ce1f56 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marc=20Nieper-Wi=C3=9Fkirchen?= 
Date: Sat, 25 Nov 2023 18:14:55 +0100
Subject: [PATCH] jit/cache-tests: New module.

* m4/valgrind-helper.m4: Unconditionally set support_valgrind to
fix configure error.
* modules/jit/cache-tests: New file.  Mark the test as unportable
for now.
* tests/jit/test-cache.c: New file.
---
 ChangeLog   |  9 +
 m4/valgrind-helper.m4   |  3 +-
 modules/jit/cache-tests | 20 +++
 tests/jit/test-cache.c  | 77 +
 4 files changed, 108 insertions(+), 1 deletion(-)
 create mode 100644 modules/jit/cache-tests
 create mode 100644 tests/jit/test-cache.c

diff --git a/ChangeLog b/ChangeLog
index 1834acd9da..89419032b3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2023-11-25  Marc Nieper-Wißkirchen  
+
+	jit/cache-tests: New module.
+	* m4/valgrind-helper.m4: Unconditionally set support_valgrind to
+	fix configure error.
+	* modules/jit/cache-tests: New file.  Mark the test as unportable
+	for now.
+	* tests/jit/test-cache.c: New file.
+
 2023-11-24  Bruno Haible  
 
 	floorf, ceilf tests: Strengthen against compiler optimizations.
diff --git a/m4/valgrind-helper.m4 b/m4/valgrind-helper.m4
index 99c31030b9..90637e6745 100644
--- a/m4/valgrind-helper.m4
+++ b/m4/valgrind-helper.m4
@@ -17,7 +17,8 @@ AC_DEFUN_ONCE([gl_VALGRIND_HELPER],
  else
support_valgrind=0
  fi
-])
+],
+[support_valgrind=0])
   if test $support_valgrind = 1; then
 AC_CHECK_HEADERS([valgrind/valgrind.h])
 if test $ac_cv_header_valgrind_valgrind_h != yes; then
diff --git a/modules/jit/cache-tests b/modules/jit/cache-tests
new file mode 100644
index 00..eff828890d
--- /dev/null
+++ b/modules/jit/cache-tests
@@ -0,0 +1,20 @@
+Files:
+tests/jit/test-cache.c
+tests/macros.h
+
+Status:
+unportable-test
+
+Depends-on:
+getpagesize
+pagealign_alloc
+stdint
+
+configure.ac:
+AC_CHECK_HEADERS_ONCE([sys/mman.h])
+AC_CHECK_FUNCS_ONCE([mprotect])
+
+Makefile.am:
+TESTS += test-cache
+check_PROGRAMS += test-cache
+test_cache_SOURCES = jit/test-cache.c
diff --git a/tests/jit/test-cache.c b/tests/jit/test-cache.c
new file mode 100644
index 00..47c81a8b1e
--- /dev/null
+++ b/tests/jit/test-cache.c
@@ -0,0 +1,77 @@
+/* Test clear_cache.
+
+   Copyright 2023 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see .  */
+
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+
+#if HAVE_SYS_MMAN_H && HAVE_MPROTECT
+# include 
+#endif
+
+#i

Re: new module 'jit/cache'

2023-11-13 Thread Bruno Haible
>   * m4/valgrind-helper.m4: New file.

Oops, that file was incomplete. Fixed like this:


2023-11-13  Bruno Haible  

jit/cache: Fix configure test.
* m4/valgrind-helper.m4 (gl_VALGRIND_HELPER): Check already at configure
time whether  exists. Fix AC_DEFINE_UNQUOTED
invocation.

diff --git a/m4/valgrind-helper.m4 b/m4/valgrind-helper.m4
index b3d70a7ad9..99c31030b9 100644
--- a/m4/valgrind-helper.m4
+++ b/m4/valgrind-helper.m4
@@ -1,4 +1,4 @@
-# valgrind-helper.m4 serial 1
+# valgrind-helper.m4 serial 2
 dnl Copyright (C) 2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -18,5 +18,13 @@ AC_DEFUN_ONCE([gl_VALGRIND_HELPER]
support_valgrind=0
  fi
 ])
-  AC_DEFINE_UNQUOTED([ENABLE_VALGRIND_SUPPORT], [$support_valgrind])
+  if test $support_valgrind = 1; then
+AC_CHECK_HEADERS([valgrind/valgrind.h])
+if test $ac_cv_header_valgrind_valgrind_h != yes; then
+  AC_MSG_ERROR([cannot enable valgrind support:  not 
found])
+fi
+  fi
+  AC_DEFINE_UNQUOTED([ENABLE_VALGRIND_SUPPORT], [$support_valgrind],
+[Define to 1 to include support for running the binaries under valgrind,
+ or to 0 otherwise.])
 ])