mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2024-11-26 17:17:39 +01:00
Simplify control flow
Greetings, Attached patch gets rid of additional unnecessary branch (rs_get_cache can not return NULL unless caching_policy is UNW_CACHE_NONE), gets rid of goto's, and makes apply_reg_state (major CPU consumer) execute with cache lock not held (before the patch, apply_reg_state was called with lock held for newly-inserted entries, but not for found-in-cache entries). Tested on Linux/x86_64 with no regressions. Thanks, -- Paul Pluzhnikov
This commit is contained in:
parent
f958b9dc4f
commit
2648a77f04
1 changed files with 17 additions and 25 deletions
|
@ -793,22 +793,19 @@ dwarf_find_save_locs (struct dwarf_cursor *c)
|
|||
return uncached_dwarf_find_save_locs (c);
|
||||
|
||||
cache = get_rs_cache(c->as, &saved_mask);
|
||||
if (!cache)
|
||||
return -UNW_ENOINFO; /* cache is busy */
|
||||
rs = rs_lookup(cache, c);
|
||||
|
||||
if (rs)
|
||||
{
|
||||
c->ret_addr_column = rs->ret_addr_column;
|
||||
goto apply;
|
||||
else
|
||||
{
|
||||
if ((ret = fetch_proc_info (c, c->ip, 1)) < 0 ||
|
||||
(ret = create_state_record_for (c, &sr, c->ip)) < 0)
|
||||
{
|
||||
put_rs_cache (c->as, cache, &saved_mask);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = fetch_proc_info (c, c->ip, 1)) < 0)
|
||||
goto out;
|
||||
|
||||
if ((ret = create_state_record_for (c, &sr, c->ip)) < 0)
|
||||
goto out;
|
||||
|
||||
rs = rs_new (cache, c);
|
||||
memcpy(rs, &sr.rs_current, offsetof(struct dwarf_reg_state, ip));
|
||||
cache->buckets[c->prev_rs].hint = rs - cache->buckets;
|
||||
|
@ -817,13 +814,8 @@ dwarf_find_save_locs (struct dwarf_cursor *c)
|
|||
c->prev_rs = rs - cache->buckets;
|
||||
|
||||
put_unwind_info (c, &c->pi);
|
||||
ret = apply_reg_state (c, rs);
|
||||
}
|
||||
|
||||
out:
|
||||
put_rs_cache (c->as, cache, &saved_mask);
|
||||
return ret;
|
||||
|
||||
apply:
|
||||
put_rs_cache (c->as, cache, &saved_mask);
|
||||
if ((ret = apply_reg_state (c, rs)) < 0)
|
||||
return ret;
|
||||
|
|
Loading…
Reference in a new issue