[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Libunwind-devel] [patch] Simplify control flow
From: |
Paul Pluzhnikov |
Subject: |
[Libunwind-devel] [patch] Simplify control flow |
Date: |
Wed, 18 Nov 2009 17:55:01 -0800 (PST) |
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
diff --git a/src/dwarf/Gparser.c b/src/dwarf/Gparser.c
index abef447..b77bde2 100644
--- a/src/dwarf/Gparser.c
+++ b/src/dwarf/Gparser.c
@@ -793,37 +793,29 @@ 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;
- }
-
- 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;
+ 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;
+ }
- c->hint = rs->hint;
- c->prev_rs = rs - cache->buckets;
+ 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;
- put_unwind_info (c, &c->pi);
- ret = apply_reg_state (c, rs);
+ c->hint = rs->hint;
+ c->prev_rs = rs - cache->buckets;
-out:
- put_rs_cache (c->as, cache, &saved_mask);
- return ret;
+ put_unwind_info (c, &c->pi);
+ }
-apply:
put_rs_cache (c->as, cache, &saved_mask);
if ((ret = apply_reg_state (c, rs)) < 0)
return ret;
- [Libunwind-devel] [patch] Simplify control flow,
Paul Pluzhnikov <=