mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-04 14:20:26 +02:00
Implement jit_flush
* 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.
This commit is contained in:
parent
95f4ee4737
commit
7b449aa063
12 changed files with 136 additions and 28 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2014-11-08 Paulo Andrade <pcpa@gnu.org>
|
||||
|
||||
* 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.
|
||||
|
||||
2014-11-08 Paulo Andrade <pcpa@gnu.org>
|
||||
|
||||
* check/ctramp.c: New file. It just repeats the test
|
||||
|
|
|
@ -589,6 +589,9 @@ _jit_regarg_p(jit_state_t*, jit_node_t*, jit_int32_t);
|
|||
extern jit_pointer_t
|
||||
_emit_code(jit_state_t*);
|
||||
|
||||
extern void
|
||||
jit_flush(void *fptr, void *tptr);
|
||||
|
||||
#define emit_ldxi(r0, r1, i0) _emit_ldxi(_jit, r0, r1, i0)
|
||||
extern void
|
||||
_emit_ldxi(jit_state_t*, jit_int32_t, jit_int32_t, jit_word_t);
|
||||
|
|
|
@ -1170,8 +1170,7 @@ _emit_code(jit_state_t *_jit)
|
|||
patch_at(word, value);
|
||||
}
|
||||
|
||||
word = sysconf(_SC_PAGE_SIZE);
|
||||
__clear_cache(_jit->code.ptr, (void *)((_jit->pc.w + word) & -word));
|
||||
jit_flush(_jit->code.ptr, _jit->pc.uc);
|
||||
|
||||
return (_jit->code.ptr);
|
||||
}
|
||||
|
@ -1181,6 +1180,19 @@ _emit_code(jit_state_t *_jit)
|
|||
# include "jit_aarch64-fpu.c"
|
||||
#undef CODE
|
||||
|
||||
void
|
||||
jit_flush(void *fptr, void *tptr)
|
||||
{
|
||||
#if defined(__GNUC__)
|
||||
jit_word_t f, t, s;
|
||||
|
||||
s = sysconf(_SC_PAGE_SIZE);
|
||||
f = (jit_word_t)fptr & -s;
|
||||
t = (((jit_word_t)tptr) + s - 1) & -s;
|
||||
__clear_cache((void *)f, (void *)t);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
_emit_ldxi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
|
||||
{
|
||||
|
|
|
@ -1213,6 +1213,8 @@ _emit_code(jit_state_t *_jit)
|
|||
patch_at(_jitc->patches.ptr[offset].inst, word);
|
||||
}
|
||||
|
||||
jit_flush(_jit->code.ptr, _jit->pc.uc);
|
||||
|
||||
return (_jit->code.ptr);
|
||||
}
|
||||
|
||||
|
@ -1221,6 +1223,11 @@ _emit_code(jit_state_t *_jit)
|
|||
# include "jit_alpha-fpu.c"
|
||||
#undef CODE
|
||||
|
||||
void
|
||||
jit_flush(void *fptr, void *tptr)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
_emit_ldxi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
|
||||
{
|
||||
|
|
|
@ -1589,10 +1589,7 @@ _emit_code(jit_state_t *_jit)
|
|||
patch_at(_jitc->patches.ptr[offset].kind & ~arm_patch_node, word, value);
|
||||
}
|
||||
|
||||
#if defined(__GNUC__)
|
||||
word = sysconf(_SC_PAGE_SIZE);
|
||||
__clear_cache(_jit->code.ptr, (void *)((_jit->pc.w + word) & -word));
|
||||
#endif
|
||||
jit_flush(_jit->code.ptr, _jit->pc.uc);
|
||||
|
||||
return (_jit->code.ptr);
|
||||
}
|
||||
|
@ -1603,6 +1600,19 @@ _emit_code(jit_state_t *_jit)
|
|||
# include "jit_arm-vfp.c"
|
||||
#undef CODE
|
||||
|
||||
void
|
||||
jit_flush(void *fptr, void *tptr)
|
||||
{
|
||||
#if defined(__GNUC__)
|
||||
jit_word_t f, t, s;
|
||||
|
||||
s = sysconf(_SC_PAGE_SIZE);
|
||||
f = (jit_word_t)fptr & -s;
|
||||
t = (((jit_word_t)tptr) + s - 1) & -s;
|
||||
__clear_cache((void *)f, (void *)t);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
_emit_ldxi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
|
||||
{
|
||||
|
|
|
@ -1162,6 +1162,23 @@ _emit_code(jit_state_t *_jit)
|
|||
patch_at(_jitc->patches.ptr[offset].inst, word);
|
||||
}
|
||||
|
||||
jit_flush(_jit->code.ptr, _jit->pc.uc);
|
||||
|
||||
return (_jit->code.ptr);
|
||||
}
|
||||
|
||||
#define CODE 1
|
||||
# include "jit_hppa-cpu.c"
|
||||
# include "jit_hppa-fpu.c"
|
||||
#undef CODE
|
||||
|
||||
void
|
||||
jit_flush(void *fptr, void *tptr)
|
||||
{
|
||||
jit_word_t f, t, s;
|
||||
s = sysconf(_SC_PAGE_SIZE);
|
||||
f = (jit_word_t)fptr & -s;
|
||||
t = (((jit_word_t)tptr) + s - 1) & -s;
|
||||
#if defined(__hppa)
|
||||
/* --- parisc2.0.pdf ---
|
||||
Programming Note
|
||||
|
@ -1203,9 +1220,7 @@ at most two cachelines.
|
|||
* on this software.
|
||||
*/
|
||||
{
|
||||
jit_word_t f = (jit_word_t)_jit->code.ptr;
|
||||
jit_word_t n = f + 32;
|
||||
jit_word_t t = f + _jit->code.length;
|
||||
register int u, v;
|
||||
for (; f <= t; n = f + 32, f += 64) {
|
||||
asm volatile ("fdc 0(0,%0)"
|
||||
|
@ -1234,18 +1249,10 @@ at most two cachelines.
|
|||
}
|
||||
#else
|
||||
/* This is supposed to work but appears to fail on multiprocessor systems */
|
||||
word = sysconf(_SC_PAGE_SIZE);
|
||||
__clear_cache(_jit->code.ptr, (void *)((_jit->pc.w + word) & -word));
|
||||
__clear_cache((void *)f, (void *)t);
|
||||
#endif
|
||||
|
||||
return (_jit->code.ptr);
|
||||
}
|
||||
|
||||
#define CODE 1
|
||||
# include "jit_hppa-cpu.c"
|
||||
# include "jit_hppa-fpu.c"
|
||||
#undef CODE
|
||||
|
||||
void
|
||||
_emit_ldxi(jit_state_t *_jit, jit_gpr_t r0, jit_gpr_t r1, jit_word_t i0)
|
||||
{
|
||||
|
|
|
@ -1385,10 +1385,7 @@ _emit_code(jit_state_t *_jit)
|
|||
patch_at(node->code, _jitc->patches.ptr[offset].inst, word);
|
||||
}
|
||||
|
||||
#if defined(__GNUC__)
|
||||
word = sysconf(_SC_PAGE_SIZE);
|
||||
__clear_cache(_jit->code.ptr, (void *)((_jit->pc.w + word) & -word));
|
||||
#endif
|
||||
jit_flush(_jit->code.ptr, _jit->pc.uc);
|
||||
|
||||
return (_jit->code.ptr);
|
||||
}
|
||||
|
@ -1398,6 +1395,19 @@ _emit_code(jit_state_t *_jit)
|
|||
# include "jit_ia64-fpu.c"
|
||||
#undef CODE
|
||||
|
||||
void
|
||||
jit_flush(void *fptr, void *tptr)
|
||||
{
|
||||
#if defined(__GNUC__)
|
||||
jit_word_t f, t, s;
|
||||
|
||||
s = sysconf(_SC_PAGE_SIZE);
|
||||
f = (jit_word_t)fptr & -s;
|
||||
t = (((jit_word_t)tptr) + s - 1) & -s;
|
||||
__clear_cache((void *)f, (void *)t);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Use r2 that is reserved to not require a jit_get_reg call, also note
|
||||
* that addil needs a register that first in 2 bits, so, if using a
|
||||
* register other than r2 must be less than r8 (or check for a smaller
|
||||
|
|
|
@ -1488,9 +1488,7 @@ _emit_code(jit_state_t *_jit)
|
|||
patch_at(_jitc->patches.ptr[offset].inst, word);
|
||||
}
|
||||
|
||||
#if defined(__linux__)
|
||||
_flush_cache((char *)_jit->code.ptr, _jit->pc.uc - _jit->code.ptr, ICACHE);
|
||||
#endif
|
||||
jit_flush(_jit->code.ptr, _jit->pc.uc);
|
||||
|
||||
return (_jit->code.ptr);
|
||||
}
|
||||
|
@ -1500,6 +1498,19 @@ _emit_code(jit_state_t *_jit)
|
|||
# include "jit_mips-fpu.c"
|
||||
#undef CODE
|
||||
|
||||
void
|
||||
jit_flush(void *fptr, void *tptr)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
jit_word_t f, t, s;
|
||||
|
||||
s = sysconf(_SC_PAGE_SIZE);
|
||||
f = (jit_word_t)fptr & -s;
|
||||
t = (((jit_word_t)tptr) + s - 1) & -s;
|
||||
_flush_cache((void *)f, t - f, ICACHE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
_emit_ldxi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
|
||||
{
|
||||
|
|
|
@ -1372,8 +1372,7 @@ _emit_code(jit_state_t *_jit)
|
|||
patch_at(_jitc->patches.ptr[offset].inst, word);
|
||||
}
|
||||
|
||||
word = sysconf(_SC_PAGE_SIZE);
|
||||
__clear_cache(_jit->code.ptr, (void *)((_jit->pc.w + word) & -word));
|
||||
jit_flush(_jit->code.ptr, _jit->pc.uc);
|
||||
|
||||
return (_jit->code.ptr);
|
||||
}
|
||||
|
@ -1383,6 +1382,19 @@ _emit_code(jit_state_t *_jit)
|
|||
# include "jit_ppc-fpu.c"
|
||||
#undef CODE
|
||||
|
||||
void
|
||||
jit_flush(void *fptr, void *tptr)
|
||||
{
|
||||
#if defined(__GNUC__)
|
||||
jit_word_t f, t, s;
|
||||
|
||||
s = sysconf(_SC_PAGE_SIZE);
|
||||
f = (jit_word_t)fptr & -s;
|
||||
t = (((jit_word_t)tptr) + s - 1) & -s;
|
||||
__clear_cache((void *)f, (void *)t);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
_emit_ldxi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
|
||||
{
|
||||
|
|
|
@ -1154,8 +1154,7 @@ _emit_code(jit_state_t *_jit)
|
|||
patch_at(_jitc->patches.ptr[offset].inst, word);
|
||||
}
|
||||
|
||||
word = sysconf(_SC_PAGE_SIZE);
|
||||
__clear_cache(_jit->code.ptr, (void *)((_jit->pc.w + word) & -word));
|
||||
jit_flush(_jit->code.ptr, _jit->pc.uc);
|
||||
|
||||
return (_jit->code.ptr);
|
||||
}
|
||||
|
@ -1165,6 +1164,19 @@ _emit_code(jit_state_t *_jit)
|
|||
# include "jit_s390x-fpu.c"
|
||||
#undef CODE
|
||||
|
||||
void
|
||||
jit_flush(void *fptr, void *tptr)
|
||||
{
|
||||
#if defined(__GNUC__)
|
||||
jit_word_t f, t, s;
|
||||
|
||||
s = sysconf(_SC_PAGE_SIZE);
|
||||
f = (jit_word_t)fptr & -s;
|
||||
t = (((jit_word_t)tptr) + s - 1) & -s;
|
||||
__clear_cache((void *)f, (void *)t);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
_emit_ldxi(jit_state_t *_jit, jit_gpr_t r0, jit_gpr_t r1, jit_word_t i0)
|
||||
{
|
||||
|
|
|
@ -1156,6 +1156,8 @@ _emit_code(jit_state_t *_jit)
|
|||
patch_at(_jitc->patches.ptr[offset].inst, word);
|
||||
}
|
||||
|
||||
jit_flush(_jit->code.ptr, _jit->pc.uc);
|
||||
|
||||
return (_jit->code.ptr);
|
||||
}
|
||||
|
||||
|
@ -1164,6 +1166,11 @@ _emit_code(jit_state_t *_jit)
|
|||
# include "jit_sparc-fpu.c"
|
||||
#undef CODE
|
||||
|
||||
void
|
||||
jit_flush(void *fptr, void *tptr)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
_emit_ldxi(jit_state_t *_jit, jit_gpr_t r0, jit_gpr_t r1, jit_word_t i0)
|
||||
{
|
||||
|
|
|
@ -1794,6 +1794,8 @@ _emit_code(jit_state_t *_jit)
|
|||
patch_at(node, _jitc->patches.ptr[offset].inst, word);
|
||||
}
|
||||
|
||||
jit_flush(_jit->code.ptr, _jit->pc.uc);
|
||||
|
||||
return (_jit->code.ptr);
|
||||
}
|
||||
|
||||
|
@ -1803,6 +1805,11 @@ _emit_code(jit_state_t *_jit)
|
|||
# include "jit_x86-x87.c"
|
||||
#undef CODE
|
||||
|
||||
void
|
||||
jit_flush(void *fptr, void *tptr)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
_emit_ldxi(jit_state_t *_jit, jit_gpr_t r0, jit_gpr_t r1, jit_word_t i0)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue