diff options
author | Andy Wingo <wingo@pobox.com> | 2017-02-17 10:54:21 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2017-02-17 11:04:16 +0100 |
commit | 60035b66c795ffe82800b6400e5aba5b3d6fd5ca (patch) | |
tree | a9c209dd7e963b3438eba4462e71d6f371d53ee0 /libguile | |
parent | d0934df1f2f0e5d3fa9a1a1f15e6f2dec1d15698 (diff) |
Revert "Cheaper fluid-ref cache"
This reverts commit cd3ff33a31c51612f2247bdb15ecbe92d7da1310.
Diffstat (limited to 'libguile')
-rw-r--r-- | libguile/cache-internal.h | 6 | ||||
-rw-r--r-- | libguile/fluids.c | 30 |
2 files changed, 14 insertions, 22 deletions
diff --git a/libguile/cache-internal.h b/libguile/cache-internal.h index 88bb24af0..fc1e3c139 100644 --- a/libguile/cache-internal.h +++ b/libguile/cache-internal.h @@ -37,7 +37,6 @@ struct scm_cache_entry { scm_t_bits key; scm_t_bits value; - int needs_flush; }; #define SCM_CACHE_SIZE 8 @@ -74,7 +73,6 @@ scm_cache_evict_1 (struct scm_cache *cache, struct scm_cache_entry *evicted) sizeof (cache->entries[0]) * idx); cache->entries[0].key = 0; cache->entries[0].value = 0; - cache->entries[0].needs_flush = 0; } static inline struct scm_cache_entry* @@ -91,7 +89,7 @@ scm_cache_lookup (struct scm_cache *cache, SCM k) static inline void scm_cache_insert (struct scm_cache *cache, SCM k, SCM v, - struct scm_cache_entry *evicted, int needs_flush) + struct scm_cache_entry *evicted) { struct scm_cache_entry *entry; @@ -101,7 +99,6 @@ scm_cache_insert (struct scm_cache *cache, SCM k, SCM v, if (entry->key == SCM_UNPACK (k)) { entry->value = SCM_UNPACK (v); - entry->needs_flush = needs_flush; return; } memmove (cache->entries, @@ -109,7 +106,6 @@ scm_cache_insert (struct scm_cache *cache, SCM k, SCM v, (entry - cache->entries) * sizeof (*entry)); entry->key = SCM_UNPACK (k); entry->value = SCM_UNPACK (v); - entry->needs_flush = needs_flush; } #endif /* SCM_CACHE_INTERNAL_H */ diff --git a/libguile/fluids.c b/libguile/fluids.c index 5b42ccb6d..7daad7781 100644 --- a/libguile/fluids.c +++ b/libguile/fluids.c @@ -114,11 +114,10 @@ restore_dynamic_state (SCM saved, scm_t_dynamic_state *state) { entry->key = SCM_UNPACK (SCM_CAAR (saved)); entry->value = SCM_UNPACK (SCM_CDAR (saved)); - entry->needs_flush = 1; saved = scm_cdr (saved); } else - entry->key = entry->value = entry->needs_flush = 0; + entry->key = entry->value = 0; } state->values = saved; state->has_aliased_values = 1; @@ -134,7 +133,9 @@ save_dynamic_state (scm_t_dynamic_state *state) struct scm_cache_entry *entry = &state->cache.entries[slot]; SCM key = SCM_PACK (entry->key); SCM value = SCM_PACK (entry->value); - if (entry->key && entry->needs_flush) + if (entry->key && + !scm_is_eq (scm_weak_table_refq (state->values, key, SCM_UNDEFINED), + value)) { if (state->has_aliased_values) saved = scm_acons (key, value, saved); @@ -248,8 +249,7 @@ scm_is_fluid (SCM obj) } static void -fluid_set_x (scm_t_dynamic_state *dynamic_state, SCM fluid, SCM value, - int needs_flush) +fluid_set_x (scm_t_dynamic_state *dynamic_state, SCM fluid, SCM value) { struct scm_cache_entry *entry; struct scm_cache_entry evicted = { 0, 0 }; @@ -257,17 +257,13 @@ fluid_set_x (scm_t_dynamic_state *dynamic_state, SCM fluid, SCM value, entry = scm_cache_lookup (&dynamic_state->cache, fluid); if (scm_is_eq (SCM_PACK (entry->key), fluid)) { - if (SCM_UNPACK (value) != entry->value) - { - entry->needs_flush = 1; - entry->value = SCM_UNPACK (value); - } + entry->value = SCM_UNPACK (value); return; } - scm_cache_insert (&dynamic_state->cache, fluid, value, &evicted, 1); + scm_cache_insert (&dynamic_state->cache, fluid, value, &evicted); - if (evicted.key != 0 && evicted.needs_flush) + if (evicted.key != 0) { fluid = SCM_PACK (evicted.key); value = SCM_PACK (evicted.value); @@ -304,7 +300,7 @@ fluid_ref (scm_t_dynamic_state *dynamic_state, SCM fluid) val = SCM_I_FLUID_DEFAULT (fluid); /* Cache this lookup. */ - fluid_set_x (dynamic_state, fluid, val, 0); + fluid_set_x (dynamic_state, fluid, val); } return val; @@ -359,7 +355,7 @@ SCM_DEFINE (scm_fluid_set_x, "fluid-set!", 2, 0, 0, #define FUNC_NAME s_scm_fluid_set_x { SCM_VALIDATE_FLUID (1, fluid); - fluid_set_x (SCM_I_CURRENT_THREAD->dynamic_state, fluid, value, 1); + fluid_set_x (SCM_I_CURRENT_THREAD->dynamic_state, fluid, value); return SCM_UNSPECIFIED; } #undef FUNC_NAME @@ -373,7 +369,7 @@ SCM_DEFINE (scm_fluid_unset_x, "fluid-unset!", 1, 0, 0, suite demands it, but I would prefer not to. */ SCM_VALIDATE_FLUID (1, fluid); SCM_SET_CELL_OBJECT_1 (fluid, SCM_UNDEFINED); - fluid_set_x (SCM_I_CURRENT_THREAD->dynamic_state, fluid, SCM_UNDEFINED, 1); + fluid_set_x (SCM_I_CURRENT_THREAD->dynamic_state, fluid, SCM_UNDEFINED); return SCM_UNSPECIFIED; } #undef FUNC_NAME @@ -401,7 +397,7 @@ void scm_swap_fluid (SCM fluid, SCM value_box, scm_t_dynamic_state *dynstate) { SCM val = fluid_ref (dynstate, fluid); - fluid_set_x (dynstate, fluid, SCM_VARIABLE_REF (value_box), 1); + fluid_set_x (dynstate, fluid, SCM_VARIABLE_REF (value_box)); SCM_VARIABLE_SET (value_box, val); } @@ -478,7 +474,7 @@ swap_fluid (SCM data) scm_t_dynamic_state *dynstate = SCM_I_CURRENT_THREAD->dynamic_state; SCM f = SCM_CAR (data); SCM t = fluid_ref (dynstate, f); - fluid_set_x (dynstate, f, SCM_CDR (data), 1); + fluid_set_x (dynstate, f, SCM_CDR (data)); SCM_SETCDR (data, t); } |