This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: [Patch] 3/3 FFI: Use __builtin_flush_icache() to flush MIPS i-cache.
- From: David Daney <ddaney at avtrex dot com>
- To: gcc-patches at gcc dot gnu dot org, java-patches at gcc dot gnu dot org
- Date: Thu, 05 Jul 2007 00:42:34 -0700
- Subject: Re: [Patch] 3/3 FFI: Use __builtin_flush_icache() to flush MIPS i-cache.
- References: <468734D3.3020908@avtrex.com> <4687370E.7090801@avtrex.com>
David Daney wrote:
This is the third and final part of the __builtin_flush_icache patch.
It replaces the hard coded library call to cacheflush() in the MIPS
ffi_prep_closure_loc with a call to __builtin_flush_icache();
For targets that support user-space i-cache flushing (mips32r2), this
will eliminate a system call from the ffi closure preparation path.
On all other targets the generated code is the same as before.
Bootstrapped and tested on x86_64-unknown-linux-gnu all default
languages with no regressions.
Also tested on:
x86_64 cross to mipsel-linux --with-arch=mips32
i686 cross to mipsel-linux --with-arch=mips32r2
with no regressions.
A new version of the patch. All that changed is the name of the
builtin. It is now __builtin___clear_cache().
Tested as before.
OK to commit:
2007-07-04 David Daney <ddaney@avtrex.com>
* src/mips/ffi.c: Don't include sys/cachectl.h.
(ffi_prep_closure_loc): Use __builtin___clear_cache() instead of
cacheflush().
Index: src/mips/ffi.c
===================================================================
--- src/mips/ffi.c (revision 125997)
+++ src/mips/ffi.c (working copy)
@@ -27,7 +27,6 @@
#include <ffi_common.h>
#include <stdlib.h>
-#include <sys/cachectl.h>
#if _MIPS_SIM == _ABIN32
#define FIX_ARGP \
@@ -506,6 +505,7 @@ ffi_prep_closure_loc (ffi_closure *closu
unsigned int *tramp = (unsigned int *) &closure->tramp[0];
unsigned int fn;
unsigned int ctx = (unsigned int) codeloc;
+ char *clear_location = (char *) codeloc;
#if defined(FFI_MIPS_O32)
FFI_ASSERT(cif->abi == FFI_O32 || cif->abi == FFI_O32_SOFT_FLOAT);
@@ -525,8 +525,7 @@ ffi_prep_closure_loc (ffi_closure *closu
closure->fun = fun;
closure->user_data = user_data;
- /* XXX this is available on Linux, but anything else? */
- cacheflush (codeloc, FFI_TRAMPOLINE_SIZE, ICACHE);
+ __builtin___clear_cache(clear_location, clear_location + FFI_TRAMPOLINE_SIZE);
return FFI_OK;
}