mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 475876: change --with-valgrind to --enable-valgrind and add hooks to tell valgrind about the JIT's self-modifying code. r=gal (JIT parts), r=luser (build config parts).
This commit is contained in:
parent
7200f50f15
commit
25ca356b40
22
configure.in
22
configure.in
@ -6600,14 +6600,6 @@ if test "$MOZ_MEMORY"; then
|
||||
AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_ARG_WITH([valgrind],
|
||||
[ --with-valgrind Enable valgrind integration hooks],
|
||||
[enable_valgrind="yes"], [enable_valgrind="no"])
|
||||
AC_CHECK_HEADER([valgrind/valgrind.h], [], [enable_valgrind="no"])
|
||||
if test "x$enable_valgrind" = "xyes" ; then
|
||||
AC_DEFINE(MOZ_VALGRIND)
|
||||
fi
|
||||
fi
|
||||
AC_SUBST(MOZ_MEMORY)
|
||||
AC_SUBST(WIN32_CRT_SRC_DIR)
|
||||
@ -6639,6 +6631,20 @@ MOZ_ARG_WITH_STRING(wrap-malloc,
|
||||
[ --with-wrap-malloc=DIR Location of malloc wrapper library],
|
||||
WRAP_MALLOC_LIB=$withval)
|
||||
|
||||
dnl ========================================================
|
||||
dnl = Use Valgrind
|
||||
dnl ========================================================
|
||||
MOZ_ARG_ENABLE_BOOL(valgrind,
|
||||
[ --enable-valgrind Enable Valgrind integration hooks (default=no)],
|
||||
MOZ_VALGRIND=1,
|
||||
MOZ_VALGRIND= )
|
||||
if test -n "$MOZ_VALGRIND"; then
|
||||
AC_CHECK_HEADER([valgrind/valgrind.h], [],
|
||||
AC_MSG_ERROR(
|
||||
[--enable-valgrind specified but Valgrind is not installed]))
|
||||
AC_DEFINE(MOZ_VALGRIND)
|
||||
fi
|
||||
|
||||
dnl ========================================================
|
||||
dnl = Use Electric Fence
|
||||
dnl ========================================================
|
||||
|
@ -4272,14 +4272,6 @@ if test "$MOZ_MEMORY"; then
|
||||
AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_ARG_WITH([valgrind],
|
||||
[ --with-valgrind Enable valgrind integration hooks],
|
||||
[enable_valgrind="yes"], [enable_valgrind="no"])
|
||||
AC_CHECK_HEADER([valgrind/valgrind.h], [], [enable_valgrind="no"])
|
||||
if test "x$enable_valgrind" = "xyes" ; then
|
||||
AC_DEFINE(MOZ_VALGRIND)
|
||||
fi
|
||||
fi
|
||||
AC_SUBST(MOZ_MEMORY)
|
||||
AC_SUBST(WIN32_CRT_SRC_DIR)
|
||||
@ -4311,6 +4303,20 @@ MOZ_ARG_WITH_STRING(wrap-malloc,
|
||||
[ --with-wrap-malloc=DIR Location of malloc wrapper library],
|
||||
WRAP_MALLOC_LIB=$withval)
|
||||
|
||||
dnl ========================================================
|
||||
dnl = Use Valgrind
|
||||
dnl ========================================================
|
||||
MOZ_ARG_ENABLE_BOOL(valgrind,
|
||||
[ --enable-valgrind Enable Valgrind integration hooks (default=no)],
|
||||
MOZ_VALGRIND=1,
|
||||
MOZ_VALGRIND= )
|
||||
if test -n "$MOZ_VALGRIND"; then
|
||||
AC_CHECK_HEADER([valgrind/valgrind.h], [],
|
||||
AC_MSG_ERROR(
|
||||
[--enable-valgrind specified but Valgrind is not installed]))
|
||||
AC_DEFINE(MOZ_VALGRIND)
|
||||
fi
|
||||
|
||||
dnl ========================================================
|
||||
dnl = Use Electric Fence
|
||||
dnl ========================================================
|
||||
|
@ -931,6 +931,11 @@ namespace nanojit
|
||||
NanoAssert( !_branchStateMap || _branchStateMap->isEmpty());
|
||||
_branchStateMap = 0;
|
||||
|
||||
// Tell Valgrind that new code has been generated, and it must flush
|
||||
// any translations it has for the memory range generated into.
|
||||
VALGRIND_DISCARD_TRANSLATIONS(pageTop(_nIns-1), NJ_PAGE_SIZE);
|
||||
VALGRIND_DISCARD_TRANSLATIONS(pageTop(_nExitIns-1), NJ_PAGE_SIZE);
|
||||
|
||||
#ifdef AVMPLUS_ARM
|
||||
// If we've modified the code, we need to flush so we don't end up trying
|
||||
// to execute junk
|
||||
|
@ -407,6 +407,7 @@ Assembler::nPatchBranch(NIns* at, NIns* target)
|
||||
at[0] = (NIns)( COND_AL | (0x51<<20) | (PC<<16) | (PC<<12) | (4) );
|
||||
at[1] = (NIns)(target);
|
||||
}
|
||||
VALGRIND_DISCARD_TRANSLATIONS(at, 2*sizeof(NIns));
|
||||
|
||||
#if defined(UNDER_CE)
|
||||
// we changed the code, so we need to do this (sadly)
|
||||
|
@ -416,9 +416,11 @@ namespace nanojit
|
||||
if (branch[0] == JMP32) {
|
||||
was = branch + *(int32_t*)&branch[1] + 5;
|
||||
*(int32_t*)&branch[1] = offset - 5;
|
||||
VALGRIND_DISCARD_TRANSLATIONS(&branch[1], sizeof(int32_t));
|
||||
} else if (branch[0] == JCC32) {
|
||||
was = branch + *(int32_t*)&branch[2] + 6;
|
||||
*(int32_t*)&branch[2] = offset - 6;
|
||||
VALGRIND_DISCARD_TRANSLATIONS(&branch[2], sizeof(int32_t));
|
||||
} else
|
||||
NanoAssertMsg(0, "Unknown branch type in nPatchBranch");
|
||||
#else
|
||||
@ -427,6 +429,7 @@ namespace nanojit
|
||||
mem = &branch[6] + *(int32_t *)&branch[2];
|
||||
was = *(intptr_t*)mem;
|
||||
*(intptr_t *)mem = intptr_t(targ);
|
||||
VALGRIND_DISCARD_TRANSLATIONS(mem, sizeof(intptr_t));
|
||||
} else {
|
||||
NanoAssertMsg(0, "Unknown branch type in nPatchBranch");
|
||||
}
|
||||
@ -2098,6 +2101,9 @@ namespace nanojit
|
||||
Page *p = (Page*)pageTop(eip-1);
|
||||
NIns *top = (NIns*) &p->code[0];
|
||||
if (eip - n < top) {
|
||||
// We are done with the current page. Tell Valgrind that new code
|
||||
// has been generated.
|
||||
VALGRIND_DISCARD_TRANSLATIONS(pageTop(p), NJ_PAGE_SIZE);
|
||||
_nIns = pageAlloc(_inExit);
|
||||
JMP(eip);
|
||||
}
|
||||
|
@ -98,6 +98,16 @@
|
||||
#define NJ_DELETE(obj) do { delete obj; } while (0)
|
||||
#endif
|
||||
|
||||
// Embed no-op macros that let Valgrind work with the JIT.
|
||||
#ifdef MOZ_VALGRIND
|
||||
# define JS_VALGRIND
|
||||
#endif
|
||||
#ifdef JS_VALGRIND
|
||||
# include <valgrind/valgrind.h>
|
||||
#else
|
||||
# define VALGRIND_DISCARD_TRANSLATIONS(addr, szB)
|
||||
#endif
|
||||
|
||||
namespace nanojit
|
||||
{
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user