1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-14 15:40:19 +02:00

Simplify dynstack API to only wind one fluid at a time

* libguile/dynstack.h (SCM_DYNSTACK_TYPE_WITH_FLUID): Rename from
  with-fluids.
* libguile/dynstack.c (scm_dynstack_push_fluid):
  (scm_dynstack_unwind_fluid): Change API to only wind/unwind one
  fluid binding.
  (WITH_FLUID_WORDS): New define, always 2 words (fluid and value box).
  (WITH_FLUID_FLUID, WITH_FLUID_VALUE_BOX): New macros to get offsets of
  fluid and value box.
  (scm_dynstack_push_rewinder, scm_dynstack_push_unwinder): Use
  WINDER_WORDS.
  (scm_dynstack_push_dynwind): Use DYNWIND_WORDS.
  (scm_dynstack_wind_1): Update for scm_swap_fluid API change.

* libguile/fluids.h:
* libguile/fluids.c (scm_prepare_fluids): Remove; no longer needed.
  (scm_swap_fluid): Update to just swap one fluid binding.
  (scm_c_with_fluids, scm_c_with_fluid): Update to use
  scm_dynstack_push_fluid.

* libguile/memoize.c (do_push_fluid, do_pop_fluid): Adapt to API
  change.
* libguile/vm-engine.c (rtl_vm_engine): Change wind-fluids / unwind-fluids
  to push-fluid / pop-fluid, and actually enable.  Woo!

* libguile/vm-i-system.c (push-fluid, pop-fluid): Update to new API.
This commit is contained in:
Andy Wingo 2013-06-28 20:01:35 +02:00
parent c32b7c4cef
commit 98eaef1b50
7 changed files with 85 additions and 150 deletions

View file

@ -2519,39 +2519,34 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t nargs_)
NEXT (1);
}
/* wind-fluids fluid-base:24 _:8 n:24 value0:24 0:8 ...
/* push-fluid fluid:12 value:12
*
* Dynamically bind N fluids to values. The fluids are expected to be
* allocated in a continguous range on the stack, starting from
* FLUID-BASE. The values do not have this restriction.
*/
VM_DEFINE_OP (69, wind_fluids, "wind-fluids", OP2 (U8_U24, X8_R24))
#if 0
VM_DEFINE_OP (69, push_fluid, "push-fluid", OP1 (U8_U12_U12))
{
scm_t_uint32 fluid_base, n;
scm_t_uint32 fluid, value;
SCM_UNPACK_RTL_24 (op, fluid_base);
SCM_UNPACK_RTL_24 (ip[1], n);
SCM_UNPACK_RTL_12_12 (op, fluid, value);
scm_dynstack_push_fluids_shuffled (&current_thread->dynstack, n,
&fp[fluid_base], fp, &ip[2],
current_thread->dynamic_state);
NEXT (n + 2);
scm_dynstack_push_fluid (&current_thread->dynstack,
fp[fluid], fp[value],
current_thread->dynamic_state);
NEXT (1);
}
#else
abort();
#endif
/* unwind-fluids _:24
/* pop-fluid _:24
*
* Leave the dynamic extent of a with-fluids expression, restoring the
* fluids to their previous values.
*/
VM_DEFINE_OP (70, unwind_fluids, "unwind-fluids", OP1 (U8_X24))
VM_DEFINE_OP (70, pop_fluid, "pop-fluid", OP1 (U8_X24))
{
/* This function must not allocate. */
scm_dynstack_unwind_fluids (&current_thread->dynstack,
current_thread->dynamic_state);
scm_dynstack_unwind_fluid (&current_thread->dynstack,
current_thread->dynamic_state);
NEXT (1);
}