summaryrefslogtreecommitdiff
path: root/libguile/deprecated.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2016-11-27 21:33:30 +0100
committerAndy Wingo <wingo@pobox.com>2016-12-05 21:46:37 +0100
commitaa84489d18320df086e08554554d6f3b92c45893 (patch)
tree94fb265632d6dbd35f31b8dd7f34d2f0a418e6b7 /libguile/deprecated.c
parenta9dc553893dcd26f047afecc8dc84d30c9bdcde6 (diff)
downloadguile-aa84489d18320df086e08554554d6f3b92c45893.tar.gz
Reimplement dynamic states
There are two goals: one, to use less memory per dynamic state in order to allow millions of dynamic states to be allocated in light-weight threading scenarios. The second goal is to prevent dynamic states from being actively mutated in two threads at once. This second goal does mean that dynamic states object that escape into scheme are now copies that won't receive further updates; an incompatible change, but one which we hope doesn't affect anyone. * libguile/cache-internal.h: New file. * libguile/fluids.c (is_dynamic_state, get_dynamic_state) (save_dynamic_state, restore_dynamic_state, add_entry) (copy_value_table): New functions. (scm_i_fluid_print, scm_i_dynamic_state_print): Move up. (new_fluid): No need for a number. (scm_fluid_p: scm_is_fluid): Inline IS_FLUID uses. (fluid_set_x, fluid_ref): Adapt to dynamic state changes. (scm_fluid_set_x, scm_fluid_unset_x): Call fluid_set_x. (scm_swap_fluid): Rewrite in terms of fluid_ref and fluid_set. (swap_fluid): Use internal fluid_set_x. (scm_i_make_initial_dynamic_state): Adapt to dynamic state representation change. (scm_dynamic_state_p, scm_is_dynamic_state): Use new accessors. (scm_current_dynamic_state): Use make_dynamic_state. (scm_dynwind_current_dynamic_state): Use new accessor. * libguile/fluids.h: Remove internal definitions. Add new struct definition. * libguile/threads.h (scm_i_thread): Use scm_t_dynamic_state for dynamic state. * libguile/threads.c (guilify_self_1, guilify_self_2): (scm_i_init_thread_for_guile, scm_init_guile): (scm_call_with_new_thread): (scm_init_threads, scm_init_threads_default_dynamic_state): Adapt to scm_i_thread change. (scm_i_with_guile, with_guile): Remove "and parent" suffix. (scm_i_reset_fluid): Remove unneeded function. * doc/ref/api-scheduling.texi (Fluids and Dynamic States): Remove scm_make_dynamic_state docs. Update current-dynamic-state docs. * libguile/vm-engine.c (vm_engine): Update fluid-ref and fluid-set! inlined fast paths for dynamic state changes. * libguile/vm.c (vm_error_unbound_fluid): Remove now-unused function. * NEWS: Update. * module/ice-9/deprecated.scm (make-dynamic-state): New definition. * libguile/deprecated.h: * libguile/deprecated.c (scm_make_dynamic_state): Move here. * libguile/__scm.h (scm_t_dynamic_state): New typedef. * libguile/dynstack.h: * libguile/dynstack.c (scm_dynstack_push_fluid): (scm_dynstack_unwind_fluid): Take raw dynstate in these internal functions. * libguile/throw.c (catch): Adapt to dynstack changes.
Diffstat (limited to 'libguile/deprecated.c')
-rw-r--r--libguile/deprecated.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/libguile/deprecated.c b/libguile/deprecated.c
index 0ea4b5e20..c3d4935d0 100644
--- a/libguile/deprecated.c
+++ b/libguile/deprecated.c
@@ -853,7 +853,7 @@ scm_internal_cwdr (scm_t_catch_body body, void *body_data,
scm_dynstack_unwind (dynstack, SCM_DYNSTACK_FIRST (dynstack));
scm_dynwind_begin (SCM_F_DYNWIND_REWINDABLE);
- scm_dynwind_current_dynamic_state (scm_make_dynamic_state (SCM_UNDEFINED));
+ scm_dynwind_current_dynamic_state (scm_current_dynamic_state ());
my_handler_data.run_handler = 0;
answer = scm_i_with_continuation_barrier (body, body_data,
@@ -928,6 +928,18 @@ scm_apply_with_dynamic_root (SCM proc, SCM a1, SCM args, SCM handler)
+SCM
+scm_make_dynamic_state (SCM parent)
+{
+ scm_c_issue_deprecation_warning
+ ("scm_make_dynamic_state is deprecated. Dynamic states are "
+ "now immutable; just use the parent directly.");
+ return SCM_UNBNDP (parent) ? scm_current_dynamic_state () : parent;
+}
+
+
+
+
void
scm_i_init_deprecated ()
{