1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2025-02-03 13:12:54 +01:00

dwarf: Fix cache size calculation

The and mask trick only works for power-of-two sized things,
but must be computed using the full size.  This incorrectly
resulted in a very small cache size.

Found using bisect and 'make perf' in tests directory.

blame rev: 0b51f5892d
This commit is contained in:
Dave Watson 2017-08-14 16:28:17 -07:00
parent 152a96e291
commit 3b3a453a65

View file

@ -679,7 +679,7 @@ rs_new (struct dwarf_rs_cache *cache, struct dwarf_cursor * c)
unsigned short head;
head = cache->rr_head;
cache->rr_head = (head + 1) & (cache->log_size - 1);
cache->rr_head = (head + 1) & (DWARF_UNW_CACHE_SIZE(cache->log_size) - 1);
/* remove the old rs from the hash table (if it's there): */
if (cache->links[head].ip)
@ -885,7 +885,7 @@ find_reg_state (struct dwarf_cursor *c, dwarf_state_record_t *sr)
int ret = 0;
intrmask_t saved_mask;
if ((cache = get_rs_cache(c->as, &saved_mask)) &&
if ((cache = get_rs_cache(c->as, &saved_mask)) &&
(rs = rs_lookup(cache, c)))
{
/* update hint; no locking needed: single-word writes are atomic */
@ -951,7 +951,7 @@ dwarf_make_proc_info (struct dwarf_cursor *c)
needed for unw_resume */
dwarf_state_record_t sr;
int ret;
/* Lookup it up the slow way... */
ret = fetch_proc_info (c, c->ip, 0);
if (ret >= 0)
@ -1018,11 +1018,11 @@ dwarf_reg_states_iterate(struct dwarf_cursor *c,
case UNW_INFO_FORMAT_REMOTE_TABLE:
ret = dwarf_reg_states_table_iterate(c, cb, token);
break;
case UNW_INFO_FORMAT_DYNAMIC:
ret = dwarf_reg_states_dynamic_iterate (c, cb, token);
break;
default:
Debug (1, "Unexpected unwind-info format %d\n", c->pi.format);
ret = -UNW_EINVAL;