{
guint8 *reg_eip;
const void *reg_eip_aligned;
+static const void *reg_eip_aligned_last_valid=NULL; /* performance cache */
g_return_if_fail(signo==SIGSEGV);
g_return_if_fail(siginfo->si_signo==SIGSEGV);
*/
reg_eip_aligned=(const void *)(((char *)reg_eip)-(GPOINTER_TO_UINT(reg_eip)&(PAGE_SIZE-1)));
g_assert(reg_eip_aligned!=NULL);
- g_return_if_fail(!(captive_mmap_map_get(reg_eip_aligned)&PROT_EXEC));
+
+ /* We do not expect any pages can get un-PROT_EXEC-ed
+ * and therefore we never invalidate our cache 'reg_eip_aligned_last_valid'.
+ */
+ if (reg_eip_aligned_last_valid!=reg_eip_aligned) {
+ g_return_if_fail(!(captive_mmap_map_get(reg_eip_aligned)&PROT_EXEC));
+ reg_eip_aligned_last_valid=reg_eip_aligned;
+ }
/* all instruction notation comments are written in AT&T 'instr src,dest' syntax! */
if (*reg_eip==0x64) { /* prefix '%fs:' */