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>
|
2014-11-08 Paulo Andrade <pcpa@gnu.org>
|
||||||
|
|
||||||
* check/ctramp.c: New file. It just repeats the test
|
* 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
|
extern jit_pointer_t
|
||||||
_emit_code(jit_state_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)
|
#define emit_ldxi(r0, r1, i0) _emit_ldxi(_jit, r0, r1, i0)
|
||||||
extern void
|
extern void
|
||||||
_emit_ldxi(jit_state_t*, jit_int32_t, jit_int32_t, jit_word_t);
|
_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);
|
patch_at(word, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
word = sysconf(_SC_PAGE_SIZE);
|
jit_flush(_jit->code.ptr, _jit->pc.uc);
|
||||||
__clear_cache(_jit->code.ptr, (void *)((_jit->pc.w + word) & -word));
|
|
||||||
|
|
||||||
return (_jit->code.ptr);
|
return (_jit->code.ptr);
|
||||||
}
|
}
|
||||||
|
@ -1181,6 +1180,19 @@ _emit_code(jit_state_t *_jit)
|
||||||
# include "jit_aarch64-fpu.c"
|
# include "jit_aarch64-fpu.c"
|
||||||
#undef CODE
|
#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
|
void
|
||||||
_emit_ldxi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
|
_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);
|
patch_at(_jitc->patches.ptr[offset].inst, word);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jit_flush(_jit->code.ptr, _jit->pc.uc);
|
||||||
|
|
||||||
return (_jit->code.ptr);
|
return (_jit->code.ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1221,6 +1223,11 @@ _emit_code(jit_state_t *_jit)
|
||||||
# include "jit_alpha-fpu.c"
|
# include "jit_alpha-fpu.c"
|
||||||
#undef CODE
|
#undef CODE
|
||||||
|
|
||||||
|
void
|
||||||
|
jit_flush(void *fptr, void *tptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_emit_ldxi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
|
_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);
|
patch_at(_jitc->patches.ptr[offset].kind & ~arm_patch_node, word, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
jit_flush(_jit->code.ptr, _jit->pc.uc);
|
||||||
word = sysconf(_SC_PAGE_SIZE);
|
|
||||||
__clear_cache(_jit->code.ptr, (void *)((_jit->pc.w + word) & -word));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return (_jit->code.ptr);
|
return (_jit->code.ptr);
|
||||||
}
|
}
|
||||||
|
@ -1603,6 +1600,19 @@ _emit_code(jit_state_t *_jit)
|
||||||
# include "jit_arm-vfp.c"
|
# include "jit_arm-vfp.c"
|
||||||
#undef CODE
|
#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
|
void
|
||||||
_emit_ldxi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
|
_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);
|
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)
|
#if defined(__hppa)
|
||||||
/* --- parisc2.0.pdf ---
|
/* --- parisc2.0.pdf ---
|
||||||
Programming Note
|
Programming Note
|
||||||
|
@ -1203,9 +1220,7 @@ at most two cachelines.
|
||||||
* on this software.
|
* on this software.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
jit_word_t f = (jit_word_t)_jit->code.ptr;
|
|
||||||
jit_word_t n = f + 32;
|
jit_word_t n = f + 32;
|
||||||
jit_word_t t = f + _jit->code.length;
|
|
||||||
register int u, v;
|
register int u, v;
|
||||||
for (; f <= t; n = f + 32, f += 64) {
|
for (; f <= t; n = f + 32, f += 64) {
|
||||||
asm volatile ("fdc 0(0,%0)"
|
asm volatile ("fdc 0(0,%0)"
|
||||||
|
@ -1234,18 +1249,10 @@ at most two cachelines.
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* This is supposed to work but appears to fail on multiprocessor systems */
|
/* This is supposed to work but appears to fail on multiprocessor systems */
|
||||||
word = sysconf(_SC_PAGE_SIZE);
|
__clear_cache((void *)f, (void *)t);
|
||||||
__clear_cache(_jit->code.ptr, (void *)((_jit->pc.w + word) & -word));
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return (_jit->code.ptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CODE 1
|
|
||||||
# include "jit_hppa-cpu.c"
|
|
||||||
# include "jit_hppa-fpu.c"
|
|
||||||
#undef CODE
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_emit_ldxi(jit_state_t *_jit, jit_gpr_t r0, jit_gpr_t r1, jit_word_t i0)
|
_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);
|
patch_at(node->code, _jitc->patches.ptr[offset].inst, word);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
jit_flush(_jit->code.ptr, _jit->pc.uc);
|
||||||
word = sysconf(_SC_PAGE_SIZE);
|
|
||||||
__clear_cache(_jit->code.ptr, (void *)((_jit->pc.w + word) & -word));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return (_jit->code.ptr);
|
return (_jit->code.ptr);
|
||||||
}
|
}
|
||||||
|
@ -1398,6 +1395,19 @@ _emit_code(jit_state_t *_jit)
|
||||||
# include "jit_ia64-fpu.c"
|
# include "jit_ia64-fpu.c"
|
||||||
#undef CODE
|
#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
|
/* 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
|
* 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
|
* 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);
|
patch_at(_jitc->patches.ptr[offset].inst, word);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__linux__)
|
jit_flush(_jit->code.ptr, _jit->pc.uc);
|
||||||
_flush_cache((char *)_jit->code.ptr, _jit->pc.uc - _jit->code.ptr, ICACHE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return (_jit->code.ptr);
|
return (_jit->code.ptr);
|
||||||
}
|
}
|
||||||
|
@ -1500,6 +1498,19 @@ _emit_code(jit_state_t *_jit)
|
||||||
# include "jit_mips-fpu.c"
|
# include "jit_mips-fpu.c"
|
||||||
#undef CODE
|
#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
|
void
|
||||||
_emit_ldxi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
|
_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);
|
patch_at(_jitc->patches.ptr[offset].inst, word);
|
||||||
}
|
}
|
||||||
|
|
||||||
word = sysconf(_SC_PAGE_SIZE);
|
jit_flush(_jit->code.ptr, _jit->pc.uc);
|
||||||
__clear_cache(_jit->code.ptr, (void *)((_jit->pc.w + word) & -word));
|
|
||||||
|
|
||||||
return (_jit->code.ptr);
|
return (_jit->code.ptr);
|
||||||
}
|
}
|
||||||
|
@ -1383,6 +1382,19 @@ _emit_code(jit_state_t *_jit)
|
||||||
# include "jit_ppc-fpu.c"
|
# include "jit_ppc-fpu.c"
|
||||||
#undef CODE
|
#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
|
void
|
||||||
_emit_ldxi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_word_t i0)
|
_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);
|
patch_at(_jitc->patches.ptr[offset].inst, word);
|
||||||
}
|
}
|
||||||
|
|
||||||
word = sysconf(_SC_PAGE_SIZE);
|
jit_flush(_jit->code.ptr, _jit->pc.uc);
|
||||||
__clear_cache(_jit->code.ptr, (void *)((_jit->pc.w + word) & -word));
|
|
||||||
|
|
||||||
return (_jit->code.ptr);
|
return (_jit->code.ptr);
|
||||||
}
|
}
|
||||||
|
@ -1165,6 +1164,19 @@ _emit_code(jit_state_t *_jit)
|
||||||
# include "jit_s390x-fpu.c"
|
# include "jit_s390x-fpu.c"
|
||||||
#undef CODE
|
#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
|
void
|
||||||
_emit_ldxi(jit_state_t *_jit, jit_gpr_t r0, jit_gpr_t r1, jit_word_t i0)
|
_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);
|
patch_at(_jitc->patches.ptr[offset].inst, word);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jit_flush(_jit->code.ptr, _jit->pc.uc);
|
||||||
|
|
||||||
return (_jit->code.ptr);
|
return (_jit->code.ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1164,6 +1166,11 @@ _emit_code(jit_state_t *_jit)
|
||||||
# include "jit_sparc-fpu.c"
|
# include "jit_sparc-fpu.c"
|
||||||
#undef CODE
|
#undef CODE
|
||||||
|
|
||||||
|
void
|
||||||
|
jit_flush(void *fptr, void *tptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_emit_ldxi(jit_state_t *_jit, jit_gpr_t r0, jit_gpr_t r1, jit_word_t i0)
|
_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);
|
patch_at(node, _jitc->patches.ptr[offset].inst, word);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jit_flush(_jit->code.ptr, _jit->pc.uc);
|
||||||
|
|
||||||
return (_jit->code.ptr);
|
return (_jit->code.ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1803,6 +1805,11 @@ _emit_code(jit_state_t *_jit)
|
||||||
# include "jit_x86-x87.c"
|
# include "jit_x86-x87.c"
|
||||||
#undef CODE
|
#undef CODE
|
||||||
|
|
||||||
|
void
|
||||||
|
jit_flush(void *fptr, void *tptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_emit_ldxi(jit_state_t *_jit, jit_gpr_t r0, jit_gpr_t r1, jit_word_t i0)
|
_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