| Commit message (Expand) | Author | Age | Files | Lines |
* | Add thread local fluids...* libguile/fluids.h (struct scm_dynamic_state): Add thread_local_values
table. Thread locals are flushed to a separate thread-local table.
The references are strong references since the table never escapes the
thread.
(scm_make_thread_local_fluid, scm_fluid_thread_local_p): New
functions.
* libguile/fluids.c (FLUID_F_THREAD_LOCAL):
(SCM_I_FLUID_THREAD_LOCAL_P): New macros.
(restore_dynamic_state): Add comment about precondition.
(save_dynamic_state): Flush thread locals.
(scm_i_fluid_print): Print thread locals nicely.
(new_fluid): Add flags arg.
(scm_make_fluid, scm_make_fluid_with_default, scm_make_unbound_fluid):
Adapt.
(scm_make_thread_local_fluid, scm_fluid_thread_local_p): New
functions.
(fluid_set_x): Special flushing logic for thread-locals.
(fluid_ref): Special cache miss logic for thread locals.
* libguile/stacks.c (scm_init_stacks):
* libguile/throw.c (scm_init_throw): %stacks and %exception-handler are
thread-locals.
* libguile/threads.c (guilify_self_2): Init thread locals table.
* test-suite/tests/fluids.test ("dynamic states"): Add test.
* doc/ref/api-control.texi (Fluids and Dynamic States): Add link to
Thread-Local Variables.
* doc/ref/api-scheduling.texi (Thread Local Variables): Update with real
thread-locals.
* NEWS: Update.
| Andy Wingo | 2017-03-07 | 1 | -1/+1 |
* | Avoid stacks in dynamically-bound values...* libguile/dynstack.h:
* libguile/dynstack.c (scm_dynstack_find_old_fluid_value): New
function.
* libguile/fluids.c (saved_dynamic_state_ref): New helper.
(scm_fluid_ref): Fix docstring.
(scm_fluid_ref_star): New function allowing access to previous values
for a fluid.
(scm_dynamic_state_ref): New internal function.
* libguile/fluids.h: Add scm_fluid_ref_star and scm_dynamic_state_ref.
* libguile/stacks.c (scm_stack_id): Adapt to %stacks not being a chain.
* libguile/throw.c (catch, throw_without_pre_unwind): Adapt to
%exception-handlers not being a chain.
* module/ice-9/boot-9.scm (catch, dispatch-exception): Instead of having
%exception-handlers be a chain, use fluid-ref* to access the chain
that is in place at the time the exception is thrown. Prevents
unintended undelimited capture of the current exception handler stack
by a delimited "catch".
(%start-stack): Similarly, don't be a chain.
* module/system/repl/debug.scm (frame->stack-vector):
* module/system/repl/error-handling.scm (call-with-error-handling):
* module/ice-9/save-stack.scm (save-stack): Adapt to %stacks not being a
chain.
* test-suite/tests/exceptions.test ("delimited exception handlers"): Add
tests.
* doc/ref/api-control.texi (Fluids and Dynamic States): Add docs.
| Andy Wingo | 2017-02-07 | 1 | -13/+15 |
* | Add suspendable-continuation?...* doc/ref/api-control.texi (Prompt Primitives): Document
suspendable-continuation?.
* libguile/control.c (scm_suspendable_continuation_p): New procedure.
(scm_init_ice_9_control): New extension procedure, defines
suspendable-continuation?.
(scm_init_control): Register scm_init_ice_9_control.
* libguile/eval.c (eval):
* libguile/throw.c (catch):
* libguile/continuations.c (scm_i_make_continuation): Restore resumable
prompt cookie after continuation invocation.
* libguile/vm.c (scm_call_n): Arrange to set resumable_prompt_cookie
during invocation of VM.
* libguile/vm.h (struct scm_vm): Add resumable_prompt_cookie member.
* module/ice-9/control.scm: Export suspendable-continuation?.
* test-suite/tests/control.test ("suspendable-continuation?"): New
test.
| Andy Wingo | 2016-12-12 | 1 | -0/+3 |
* | 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.
| Andy Wingo | 2016-12-05 | 1 | -1/+1 |
* | scm_spawn_thread uses call-with-new-thread...* libguile/throw.h (scm_i_make_catch_body_closure)
(scm_i_make_catch_handler_closure): Add scm_i_ prefix and make
available for internal use.
* libguile/throw.c: Adapt.
* libguile/threads.c (scm_spawn_thread): Rewrite in terms of
scm_call_with_new_thread.
| Andy Wingo | 2016-11-14 | 1 | -10/+12 |
* | Remove scm_puts_unlocked....* libguile/ports.h (scm_puts_unlocked): Remove.
* libguile/ports.c (scm_puts): Replace implementation with
scm_puts_unlocked's implementation.
* libguile/arbiters.c:
* libguile/backtrace.c:
* libguile/bitvectors.c:
* libguile/continuations.c:
* libguile/deprecation.c:
* libguile/dynl.c:
* libguile/eval.c:
* libguile/filesys.c:
* libguile/fluids.c:
* libguile/foreign.c:
* libguile/fports.c:
* libguile/frames.c:
* libguile/guardians.c:
* libguile/hashtab.c:
* libguile/hooks.c:
* libguile/load.c:
* libguile/macros.c:
* libguile/mallocs.c:
* libguile/print.c:
* libguile/programs.c:
* libguile/promises.c:
* libguile/smob.c:
* libguile/srcprop.c:
* libguile/srfi-14.c:
* libguile/stackchk.c:
* libguile/struct.c:
* libguile/threads.c:
* libguile/throw.c:
* libguile/values.c:
* libguile/variable.c:
* libguile/vm.c:
* libguile/weak-set.c:
* libguile/weak-table.c: Use scm_puts instead of scm_puts_unlocked.
| Andy Wingo | 2016-04-26 | 1 | -1/+1 |
* | VM stack grows downward...Adapt VM stack to grow downward. This will make native compilation look
more like the VM code, as we will be able to use native CALL
instructions, taking proper advantage of the return address buffer.
* libguile/continuations.c (scm_i_continuation_to_frame): Record offsets
from stack top.
* libguile/control.c (scm_i_prompt_pop_abort_args_x): Adapt for reversed
order of arguments, and instead of relying on the abort to push on the
number of arguments, make the caller save the stack depth, which
allows us to compute the number of arguments ourselves.
(reify_partial_continuation, scm_c_abort): Adapt to reversed stack
order.
* libguile/dynstack.c (scm_dynstack_wind_prompt): Since we wind the
stack in a downward direction, subtract the reloc instead of adding
it.
* libguile/dynstack.h (SCM_F_DYNSTACK_PROMPT_ESCAPE_ONLY): Remove flag;
instead rely on prompt-establishing code to save the stack depth.
* libguile/eval.c (eval): Remove extraneous "volatile" declarations for
variables that are not re-set between the setjmp and any longjmp.
Adapt to save stack depth before instating the prompt.
* libguile/foreign.c (scm_i_foreign_call): Adapt to receive arguments in
reverse order.
* libguile/frames.c (frame_stack_top, scm_i_frame_stack_top): Adapt to
compute stack top instead of stack bottom.
(scm_c_frame_closure): Adapt to stack growth change.
(scm_frame_num_locals, scm_frame_local_ref, scm_frame_set_x): Use
union data type to access stack.
(RELOC): Reformat.
(scm_c_frame_previous): Adapt to stack growth change.
* libguile/frames.h: Adapt stack diagram to indicate that the stack
grows up.
(union scm_vm_stack_element): New data type used to access items on
the stack.
(SCM_FRAME_PREVIOUS_SP)
(SCM_FRAME_RETURN_ADDRESS, SCM_FRAME_SET_RETURN_ADDRESS)
(SCM_FRAME_DYNAMIC_LINK, SCM_FRAME_SET_DYNAMIC_LINK)
(SCM_FRAME_LOCAL, SCM_FRAME_NUM_LOCALS): Adapt to stack representation
change.
(SCM_FRAME_SLOT): New helper.
(SCM_VM_FRAME_FP, SCM_VM_FRAME_SP): Adapt to stack growth change.
* libguile/stacks.c (scm_make_stack): Record offsets from top of stack.
* libguile/throw.c (catch): Adapt to scm_i_prompt_pop_abort_args_x
change.
* libguile/vm-engine.c (ALLOC_FRAME, RESET_FRAME):
(FRAME_LOCALS_COUNT_FROM): Adapt to stack growth change.
(LOCAL_ADDRESS): Use SCM_FRAME_SLOT to get the address as the proper
data type.
(RETURN_ONE_VALUE, RETURN_VALUE_LIST): Adapt to stack growth change.
(apply): Shuffling up the SMOB apply args can cause the stack to
expand, so use ALLOC_FRAME instead of RESET_FRAME.
(vm_engine): Adapt for stack growth change.
* libguile/vm.c (vm_increase_sp, vm_push_sp, vm_restore_sp): Adapt to
stack representation change.
(scm_i_vm_cont_to_frame): Adapt to take offsets from the top.
(scm_i_vm_capture_stack): Adapt to capture from the top.
(vm_return_to_continuation_inner): Adapt for data type changes.
(vm_return_to_continuation): Likewise, and instead of looping, just
splat the saved arguments on with memcpy.
(vm_dispatch_hook): Adapt to receive arguments in the reverse order.
Adapt callers.
(vm_abort): There is never a tail argument. Adapt to stack
representation change.
(vm_reinstate_partial_continuation)
(vm_reinstate_partial_continuation_inner): Adapt to stack growth
change.
(allocate_stack, free_stack): Adapt to data type change.
(expand_stack): Don't try to mremap(), as you can't grow a mapping
from the bottom. Without knowing that there's a free mapping space
right below the old stack, which there usually isn't on Linux, we have
to copy. We can't use MAP_GROWSDOWN because Linux is buggy.
(make_vm): Adapt to stack representation changes.
(return_unused_stack_to_os): Round down instead of up, as the stack
grows down.
(scm_i_vm_mark_stack): Adapt to walk up the stack.
(scm_i_vm_free_stack): Adapt to scm_vm changes.
(vm_expand_stack_inner, reset_stack_limit, vm_expand_stack): Adapt to
the stack growing down.
(scm_call_n): Adapt to the stack growing down. Don't allow argv to
point into the stack.
* libguile/vm.h (struct scm_vm, struct scm_vm_cont): Adapt to hold the
stack top and bottom.
| Andy Wingo | 2015-10-21 | 1 | -5/+4 |
* | Fix compile warnings...* libguile/throw.c (catch): Fix bad declarations.
* libguile/stackchk.c (reset_scm_stack_checking_enabled_p): Remove
unused static function.
| Andy Wingo | 2014-03-22 | 1 | -1/+2 |
* | Out-of-memory situations raise exceptions instead of aborting...* libguile/gc.c (scm_oom_fn, scm_init_gc): Install an out-of-memory
handler that raises an unwind-only out-of-memory exception.
(scm_gc_warn_proc, scm_init_gc): Install a warning proc that tries to
print to the current warning port, if the current warning port is a
file port.
(scm_gc_after_nonlocal_exit): New interface. Should be called after a
nonlocal return to potentially collect memory; otherwise allocations
could try to expand again when they should collect.
* libguile/continuations.c (scm_i_make_continuation):
* libguile/eval.c (eval):
* libguile/throw.c (catch):
* libguile/vm.c (scm_call_n): Call scm_gc_after_nonlocal_exit after
nonlocal returns.
* libguile/throw.c (abort_to_prompt, throw_without_pre_unwind): Rework
to avoid allocating memory.
(scm_report_out_of_memory): New interface.
(scm_init_throw): Pre-allocate the arguments for stack-overflow and
out-of-memory errors.
* module/ice-9/boot-9.scm: Add an out-of-memory exception printer.
* module/system/repl/error-handling.scm (call-with-error-handling): Add
out-of-memory to the report-keys set.
* libguile/gc-malloc.c (scm_realloc): Call scm_report_out_of_memory if
realloc fails.
* libguile/error.h:
* libguile/error.c:
* libguile/deprecated.h:
* libguile/deprecated.c (scm_memory_error): Deprecate.
* test-suite/standalone/Makefile.am:
* test-suite/standalone/test-out-of-memory: New test case.
| Andy Wingo | 2014-03-22 | 1 | -14/+73 |
* | Refine unwind-only exception message....* libguile/throw.c (throw_without_pre_unwind): Refine warning message.
| Andy Wingo | 2014-03-16 | 1 | -2/+8 |
* | Add stack overflow test...* libguile/throw.c (throw_without_pre_unwind): Newline after the
unwind-only warning.
* test-suite/standalone/Makefile.am:
* test-suite/standalone/test-stack-overflow: New test to handle
mmap/malloc failure.
| Andy Wingo | 2014-03-15 | 1 | -1/+1 |
* | Unwind-only stack overflow exceptions...* module/ice-9/boot-9.scm (catch): Signal an early error if the handler
or pre-unwind handler types aren't right. This is more important than
it was, given that we dispatch on type now when finding matching catch
clauses.
* libguile/vm.c (vm_expand_stack): Use the standard
scm_report_stack_overflow to signal stack overflow. This will avoid
running pre-unwind handlers.
* libguile/throw.h: Move scm_report_stack_overflow here.
* libguile/throw.c (catch): Define a version of catch in C.
(throw_without_pre_unwind): New helper. Besides serving as the
pre-boot "throw" binding, it allows stack overflow to throw without
running pre-unwind handlers.
(scm_catch, scm_catch_with_pre_unwind_handler)
(scm_with_throw_handler): Use the new catch in C.
(scm_report_stack_overflow): Moved from stackchk.c; throws an
unwind-only exception.
* libguile/stackchk.h:
* libguile/stackchk.c: Remove the scm_report_stack_overflow bits.
| Andy Wingo | 2014-02-20 | 1 | -118/+161 |
* | %exception-handler fluid refactor...* libguile/throw.c (scm_init_throw): Define %exception-handler here.
* module/ice-9/boot-9.scm (%eh): Use the incoming %exception-handler,
and then delete it. This way we should be able to do unwind-only
exceptions from C.
| Andy Wingo | 2014-02-19 | 1 | -1/+8 |
* | Merge commit '60617d819d77a1b92ed6c557a0b49b8e9a8e97b9'...Conflicts:
libguile/continuations.c
libguile/eval.c
libguile/goops.c
libguile/instructions.c
| Andy Wingo | 2014-02-07 | 1 | -26/+22 |
|\ |
|
| * | Fix thread-unsafe lazy initializations....* libguile/backtrace.c (print_exception_var): New static variable.
(init_print_exception_var): New static function.
(scm_print_exception): Remove thread-unsafe lazy initialization.
Call 'init_print_exception_var' using 'scm_i_pthread_once'.
Use 'print_exception_var'.
* libguile/continuations.c (call_cc): New static variable.
(init_call_cc): New static function.
(scm_i_call_with_current_continuation): Remove thread-unsafe lazy
initialization. Call 'init_call_cc' using 'scm_i_pthread_once'.
* libguile/debug.c (local_eval_var): New static variable.
(init_local_eval_var): New static function.
(scm_local_eval): Remove lazy initialization using mutexes.
Call 'init_local_eval_var' using 'scm_i_pthread_once'.
Use 'scm_variable_ref' instead of 'SCM_VARIABLE_REF'.
* libguile/eval.c (map_var, for_each_var): New static variables.
(init_map_var, init_for_each_var): New static functions.
(scm_map, scm_for_each): Remove thread-unsafe lazy initializations.
Call 'init_map_var' (or 'init_for_each_var') using 'scm_i_pthread_once'.
Use 'map_var' (or 'for_each_var').
* libguile/frames.c (frame_arguments_var): New static variable.
(init_frame_arguments_var): New static function.
(scm_frame_arguments): Remove thread-unsafe lazy initialization.
Call 'init_frame_arguments_var' using 'scm_i_pthread_once'.
Use 'frame_arguments_var'. Use 'scm_variable_ref' instead of
'SCM_VARIABLE_REF'.
* libguile/goops.c (delayed_compile_var): New static variable.
(init_delayed_compile_var): New static function.
(make_dispatch_procedure): Remove thread-unsafe lazy initialization.
Call 'init_delayed_compile_var' using 'scm_i_pthread_once'.
Use 'delayed_compile_var'. Use 'scm_variable_ref' instead of
'SCM_VARIABLE_REF'.
* libguile/instructions.c (instructions_by_name): New static variable.
(init_instructions_by_name): New static function.
(scm_lookup_instruction_by_name): Remove thread-unsafe lazy
initialization. Call 'init_instructions_by_name' using
'scm_i_pthread_once'.
* libguile/ports.c (current_warning_port_var)
(current_warning_port_once): New static variables.
(init_current_warning_port_var): New static function.
(scm_current_warning_port): Remove lazy initialization using mutexes.
Call 'init_current_warning_port_var' using 'scm_i_pthread_once'.
Use 'current_warning_port_var'.
(scm_set_current_warning_port): Remove thread-unsafe lazy initialization.
Call 'init_current_warning_port_var' using 'scm_i_pthread_once'.
Use 'current_warning_port_var'.
* libguile/strings.c (null_stringbuf): New static variable.
(init_null_stringbuf): New static function.
(scm_i_make_string): Remove thread-unsafe lazy initialization.
Call 'init_null_stringbuf' using 'scm_i_pthread_once'.
* libguile/strports.c (eval_string_var, k_module): New static variables.
(init_eval_string_var_and_k_module): New static function.
(scm_eval_string_in_module): Remove lazy initialization using mutexes.
Call 'init_eval_string_var_and_k_module' using 'scm_i_pthread_once'.
Use 'eval_string_var'.
* libguile/throw.c (CACHE_VAR): Remove incorrect macro.
(catch_var, throw_var, with_throw_handler_var): New static variables.
(scm_catch, scm_catch_with_pre_unwind_handler): Remove thread-unsafe
lazy initialization. Use 'catch_var'.
(init_with_throw_handler_var): New static function.
(scm_with_throw_handler): Remove thread-unsafe lazy initialization.
Call 'init_with_throw_handler_var' using 'scm_i_pthread_once'.
Use 'with_throw_handler_var'.
(scm_throw): Remove thread-unsafe lazy initialization.
Use 'throw_var'.
(scm_init_throw): Initialize 'catch_var' and 'throw_var'.
| Mark H Weaver | 2014-01-23 | 1 | -26/+22 |
* | | Merge commit '750ac8c592e792e627444f476877f282525b132e'...Conflicts:
.gitignore
libguile/deprecated.c
| Andy Wingo | 2013-11-28 | 1 | -1/+1 |
|\| |
|
| * | Don't use the identifier 'noreturn'....Fixes <http://bugs.gnu.org/15798>.
Reported by Matt Sicker <boards@gmail.com>.
* libguile/__scm.h (SCM_NORETURN): Use ((__noreturn__)) instead of
((noreturn)).
* libguile/throw.h (scm_ithrow): Rename formal parameter from 'noreturn'
to 'no_return'.
* libguile/throw.c (scm_ithrow): Rename formal parameter from 'noreturn'
to 'no_return'.
| Mark H Weaver | 2013-11-04 | 1 | -1/+1 |
* | | scm_the_vm now returns raw struct scm_vm pointer...* libguile/vm.h (scm_the_vm): Return struct scm_vm*.
(scm_c_vm_run): Remove.
* libguile/control.c:
* libguile/eval.c:
* libguile/throw.c:
* libguile/vm.c: Adapt.
| Andy Wingo | 2013-11-21 | 1 | -2/+2 |
* | | scm_i_prompt_pop_abort_args_x takes struct scm_vm* as arg...* libguile/control.h:
* libguile/control.c (scm_i_prompt_pop_abort_args_x): Change to take VP
as an arg, not VM.
* libguile/eval.c (eval):
* libguile/throw.c (pre_init_catch): Adapt.
| Andy Wingo | 2013-11-21 | 1 | -6/+10 |
* | | The dynamic stack records SP and FP values as offsets...* libguile/dynstack.h:
* libguile/dynstack.c (PROMPT_FP, PROMPT_SP):
(scm_dynstack_push_prompt, scm_dynstack_find_prompt): Prompts on the
dynstack are recorded as offsets from the base stack address in this
thread.
* libguile/control.c (scm_c_abort):
* libguile/eval.c (eval):
* libguile/stacks.c (find_prompt, narrow_stack):
* libguile/throw.c (pre_init_catch):
* libguile/vm-engine.c (prompt): Adapt.
| Andy Wingo | 2013-11-21 | 1 | -2/+2 |
* | | Add SCM_F_DYNSTACK_PROMPT_PUSH_NARGS prompt flag...* libguile/dynstack.h (scm_t_dynstack_prompt_flags): New flag,
SCM_F_DYNSTACK_PROMPT_PUSH_NARGS, set if the continuation expects the
number of args to be pushed on the top of the stack.
* libguile/control.c (scm_c_abort): Only push nargs if requested.
* libguile/eval.c (eval):
* libguile/throw.c (pre_init_catch):
* libguile/vm-i-system.c (prompt): Set
SCM_F_DYNSTACK_PROMPT_PUSH_NARGS.
| Andy Wingo | 2013-10-14 | 1 | -1/+2 |
* | | Remove @prompt memoizer...* libguile/memoize.h:
* libguile/memoize.c (MAKMEMO_CALL_WITH_PROMPT, memoize, unmemoize):
Remove the @prompt memoizer in favor of recognizing call-with-prompt
primcalls. Rename SCM_M_PROMPT to SCM_M_CALL_WITH_PROMPT, and pass a
thunk instead of an expression so that it has normal applicative
order.
* libguile/expand.c (PRIMITIVE_REF, PRIMCALL, expand): Produce primcalls
from forms whose car is a primitive.
(expand_atat): Recognize (@@ primitive FOO) as being a primitive-ref.
* module/ice-9/boot-9.scm (call-with-prompt): Instead of dispatching to
the wonky @prompt memoizer, residualize a primcall to
call-with-prompt. The memoizer will DTRT to allow call-with-prompt to
be interpreted correctly without needing an additional binding.
* module/ice-9/eval.scm (primitive-eval): Change the 'prompt clause to a
call to call-with-prompt.
* module/language/tree-il/primitives.scm: No more need to recognize
@prompt.
* libguile/eval.c (eval): Adapt to SCM_M_PROMPT renaming to
SCM_M_CALL_WITH_PROMPT, and apply the thunk.
* libguile/throw.c (pre_init_throw): Adapt to scm_abort_to_prompt_star
rename.
| Andy Wingo | 2013-06-27 | 1 | -2/+2 |
* | | dynstack: pushing a prompt no longer allocates memory...* libguile/control.h: Remove scm_t_prompt_registers and
scm_c_make_prompt_registers.
(scm_c_abort): Take a pointer to a jmpbuf instead of a cookie. It
will serve the same purpose.
* libguile/control.c (reify_partial_continuation, scm_at_abort): Adapt
to new prompt representation.
* libguile/dynstack.h:
* libguile/dynstack.c (scm_dynstack_push_prompt): Prompts now have 5
words instead of 2, as they now push the fp, sp, ip, and jmpbuf on the
stack separately. This avoids allocation.
(scm_dynstack_find_prompt): Likewise, add return values for fp, sp,
etc.
(scm_dynstack_wind_prompt): Replaces scm_dynstack_relocate_prompt.
* libguile/eval.c (eval):
* libguile/stacks.c (find_prompt):
* libguile/throw.c (pre_init_catch): Adapt to the new prompt mechanism.
* libguile/vm-engine.c (vm_engine): Setjmp an on-stack jmpbuf every time
the VM enters. We can then re-use that jmpbuf for all prompts in that
invocation.
* libguile/vm-i-system.c (partial_cont_call): Adapt to change in prompt
representation. We don't need to wind here any more, since we pass in
the prompt's jmpbuf.
(prompt): Adapt to scm_dynstack_push_prompt change.
(abort): Adapt to vm_abort change.
* libguile/vm.h (struct scm_vm): No more cookie.
* libguile/vm.c (vm_abort): Adapt to scm_c_abort change.
(vm_reinstate_partial_continuation): Rewind the dynamic stack here,
now that we do have a valid jmpbuf.
(make_vm): No need to initialize a cookie.
| Andy Wingo | 2012-03-07 | 1 | -11/+12 |
* | | the dynamic stack is really a stack now, instead of a list...* libguile/dynstack.h:
* libguile/dynstack.c: New files, implementing the dynamic stack as a
true stack instead of a linked list. This lowers the cost of
dynwinds: frames, winders, prompts, with-fluids, and dynamic-wind.
For the most part, we allocate these items directly on the stack.
* libguile/dynwinds.h:
* libguile/dynwinds.c: Adapt all manipulators of the wind stack to use
interfaces from dynstack.c. Remove heap-allocated winder and frame
object types.
(scm_dowinds, scm_i_dowinds): Remove these. The first was exported,
but it was not a public interface.
* libguile/continuations.c:
* libguile/continuations.h (scm_t_contregs): Continuation objects
reference scm_t_dynstack* values now. Adapt to the new interfaces.
* libguile/control.c:
* libguile/control.h: There is no longer a scm_tc7_prompt kind of object
that can be allocated on the heap. Instead, the prompt flags, key,
and registers are pushed on the dynwind stack. (The registers are
still on the heap.) Also, since the vm_cont will reference the
dynwinds, make the partial continuation stub take just one extra arg,
instead of storing the intwinds separately in the object table.
* libguile/fluids.c:
* libguile/fluids.h: No more with-fluids objects; instead, the fluids go
on the dynstack. The values still have to be on the heap, though.
(scm_prepare_fluids, scm_swap_fluids): New internal functions,
replacing scm_i_make_with_fluids and scm_i_swap_with_fluids.
* libguile/print.c: Remove prompt and with-fluids printers.
* libguile/tags.h: Revert prompt and with-fluids tc7 values to what they
were before they were allocated.
* libguile/vm-i-system.c (partial_cont_call): Just pop the vmcont, the
intwinds will not be passed as a second arg. Rewind the dynamic stack
from within the VM, so that any rewinder sees valid prompt entries.
(call_cc, tail_call_cc): Adapt to pass the dynstack to
scm_i_vm_capture_stack.
(prompt, wind, unwind, wind_fluids, unwind_fluids): Adapt to the new
interfaces.
* libguile/vm.h (scm_i_capture_current_stack): Rename from
scm_i_vm_capture_continuation.
(scm_i_vm_capture_stack): Take a dynstack as an argument.
* libguile/vm.c (vm_reinstate_partial_continuation): Don't wind here, as
that could result in winders seeing invalid prompts.
* libguile/eval.c:
* libguile/root.c:
* libguile/stacks.c:
* libguile/threads.c:
* libguile/threads.h:
* libguile/throw.c: Adapt other users of dynwinds to use the dynstack.
| Andy Wingo | 2012-03-03 | 1 | -17/+23 |
* | | locking for putc, puts...* libguile/ports.c (scm_putc, scm_puts):
* libguile/ports.h (scm_putc_unlocked, scm_puts_unlocked): Separate into
_unlocked and locked variants. Change all callers to use the
_unlocked versions.
| Andy Wingo | 2011-11-08 | 1 | -1/+1 |
* | | more robust scm_exit_status...* libguile/throw.c (scm_exit_status): In one of my bogus patches, I
managed to make #<unspecified> reach this function, causing a segfault
on SCM_CAR. Refactor to be more robust.
| Andy Wingo | 2011-11-04 | 1 | -2/+8 |
* | | use of EXIT_SUCCESS and EXIT_FAILURE...* libguile/threads.c (scm_init_guile):
* libguile/throw.c (scm_exit_status): Use EXIT_SUCCESS and EXIT_FAILURE
instead of 0 and 1.
| Andy Wingo | 2011-05-15 | 1 | -2/+2 |
|/ |
|
* | fix prompt and abort with the boot evaluator...* libguile/control.h:
* libguile/control.c (scm_i_prompt_pop_abort_args_x): Take a VM instead
of a prompt, given that it's the VM's registers that record the abort
arguments, not the prompt registers (which actually point right below
the abort values).
* libguile/eval.c (eval):
* libguile/throw.c (pre_init_catch): Pass the vm instead of a prompt.
| Andy Wingo | 2011-03-29 | 1 | -1/+1 |
* | better narrowing in catch-all handlers in throw.c...* libguile/throw.c (handler_message): Narrow away the catch-closure and
throw frames.
| Andy Wingo | 2011-02-11 | 1 | -1/+7 |
* | pre-boot lookup of print-exception works...* libguile/backtrace.c (scm_print_exception): Use scm_module_variable to
look up print-exception so that it works before boot-9 is loaded.
* libguile/throw.c (CACHE_VAR): Tweak to use scm_from_latin1_symbol.
| Andy Wingo | 2011-02-11 | 1 | -1/+1 |
* | scm_handle_by_message uses scm_print_exception...* libguile/throw.c (handler_message, should_print_backtrace): Use
scm_print_exception. Add a helper function to determine when to print
a backtrace; don't do so on read or syntax errors.
| Andy Wingo | 2011-02-11 | 1 | -95/+23 |
* | more robust fallback error printer...* libguile/throw.c (pre_init_throw): Deal with errors printing the
exception.
| Andy Wingo | 2011-02-09 | 1 | -2/+22 |
* | abort on pre-boot throw without catch...* libguile/throw.c (pre_init_throw): Abort instead of exit in the error
case. Print out a message.
| Andy Wingo | 2011-02-09 | 1 | -1/+3 |
* | fix a couple of (system vm frame) accesses on boot errors...* libguile/backtrace.c (display_error_body): Don't look up the
frame-source if Guile isn't initialized yet. Fixes display-error
before boot has finished.
* libguile/throw.c (handler_message): Likewise, don't backtrace before
boot has finished, because we can't load (system vm frame).
| Andy Wingo | 2011-02-09 | 1 | -1/+1 |
* | fix recursive throws if an error occurs at boot-time...* libguile/throw.c (find_pre_init_catch): New internal helper.
(pre_init_throw): If we don't find a catch, print out a message and
abort.
(scm_init_throw): Declare pre-init-throw as taking at least one arg.
| Andy Wingo | 2011-02-09 | 1 | -3/+25 |
* | use scm_from_latin1_symboln for string literals and load-symbol...* libguile/bytevectors.c:
* libguile/eval.c:
* libguile/goops.c:
* libguile/i18n.c:
* libguile/load.c:
* libguile/memoize.c:
* libguile/modules.c:
* libguile/ports.c:
* libguile/print.c:
* libguile/procs.c:
* libguile/programs.c:
* libguile/read.c:
* libguile/script.c:
* libguile/srfi-14.c:
* libguile/stacks.c:
* libguile/strings.c:
* libguile/throw.c:
* libguile/vm.c: Use scm_from_latin1_symboln to make symbols from string
literals, because they aren't in the user's locale -- they are in
ASCII, and we can optimize this case.
* libguile/vm-i-loader.c: Also use scm_from_latin1_symboln when loading
narrow symbols.
| Andy Wingo | 2011-01-07 | 1 | -4/+4 |
* | fix the C syntax-error pretty-printer...* libguile/throw.c (handler_message): Fix up a bit.
| Andy Wingo | 2010-11-16 | 1 | -2/+4 |
* | add proper pretty-printing for syntax errors...* module/system/repl/repl.scm (display-syntax-error): New helper,
displays a syntax error.
(abort-on-error, run-repl): Use it.
* libguile/throw.c (handler_message): Re-code the same thing in C.
| Andy Wingo | 2010-11-16 | 1 | -1/+54 |
* | a number of doc fixes...* doc/ref/api-control.texi (Handling Errors): Update docs for
display-error.
* libguile/backtrace.h (scm_i_display_error): Change prototype to
s/stack/frame/.
* libguile/throw.c (handler_message): Change invocation of
scm_i_display_error to pass a frame.
* doc/ref/api-deprecated.texi (Deprecation): Update wording.
* doc/ref/api-evaluation.texi (Local Evaluation): Remove section on
local-eval.
* doc/ref/api-macros.texi: Fix a couple typos.
* doc/ref/api-memory.texi (Objects): Remove terrible section.
* doc/ref/api-procedures.texi (Procedure Properties): Remove docs for
closure?.
(Compiled Procedures): Update wording.
* doc/ref/guile.texi (API Reference): Remove reference to "Objects".
| Andy Wingo | 2010-08-16 | 1 | -1/+3 |
* | deprecate the-last-stack...* libguile/backtrace.h (scm_the_last_stack_fluid_var)
* libguile/backtrace.c (scm_init_backtrace): No more
scm_the_last_stack_fluid_var. The replacement is to resolve
`the-last-stack' in (ice-9 stack-catch).
(scm_backtrace_with_highlights): Accordingly, instead of backtracing
the last stack, backtrace the current stack.
* libguile/throw.h:
* libguile/throw.c:
* libguile/deprecated.h:
* libguile/deprecated.c (scm_internal_stack_catch): Deprecate this
function.
* module/ice-9/save-stack.scm (the-last-stack): Move here from boot-9.
* module/ice-9/debug.scm:
* module/ice-9/debugger.scm: Use (ice-9 save-stack) for the-last-stack.
* module/ice-9/deprecated.scm (the-last-stack): Add deprecated shim.
| Andy Wingo | 2010-06-19 | 1 | -44/+0 |
* | remove libguile/lang.h, deprecate %nil (in favor of #nil)...* libguile/Makefile.am:
* libguile/init.c:
* libguile/lang.c:
* libguile/lang.h: Remove lang.c and lang.h.
* libguile/pairs.h (SCM_NIL_P, SCM_NULL_OR_NIL_P): Moved here.
* module/ice-9/deprecated.scm (%nil): %nil definition moved here.
* libguile/alist.c:
* libguile/async.c:
* libguile/backtrace.c:
* libguile/boolean.c:
* libguile/dynl.c:
* libguile/eval.c:
* libguile/filesys.c:
* libguile/fluids.c:
* libguile/list.c:
* libguile/load.c:
* libguile/options.c:
* libguile/posix.c:
* libguile/print.c:
* libguile/promises.c:
* libguile/sort.c:
* libguile/throw.c:
* libguile/trees.c:
* libguile/vectors.c:
* libguile/vm.c:
* libguile/weaks.c:
* srfi/srfi-1.c: <libguile/lang.h> references removed.
| Andy Wingo | 2010-04-09 | 1 | -1/+0 |
* | remove internal treatment of default prompt tag, it seems there was no need...* libguile/control.h (scm_sys_default_prompt_tag):
* libguile/control.c (scm_init_control): Remove the logic that defined
%default-prompt-tag.
(scm_c_abort): Remove check for default prompt tag, it wasn't useful.
* libguile/throw.c (sym_pre_init_catch_tag): Define as the pre-init
prompt tag.
(pre_init_catch, pre_init_throw): Use sym_pre_init_catch_tag.
* module/ice-9/boot-9.scm (default-prompt-tag): Define as a simple
value, not a fluid. Perhaps we can expose it as a fluid later.
| Andy Wingo | 2010-03-11 | 1 | -2/+5 |
* | rewinding prompts works...* libguile/control.h (SCM_PROMPT_HANDLER): Remove, it was unused.
(SCM_PROMPT_DYNWINDS): Rename from SCM_PROMPT_DYNENV.
* libguile/control.c: (scm_c_make_prompt): Take another arg, the winds
that are to be in place for the prompt. Fix allocation to be 4 words
instead of 5 (the handler was never used).
* libguile/eval.c (eval):
* libguile/throw.c (pre_init_catch): Adapt to scm_c_make_prompt change.
* libguile/vm-i-system.c (partial-cont-call): Grovel the new elements of
the wind list in order to call setjmp() on the new prompts. Pass
cookie to vm_reinstate_partial_continuation.
(prompt): Adapt to scm_c_make_prompt change.
* libguile/vm.c (vm_reinstate_partial_continuation): Take a cookie arg,
used when winding captured prompts onto the stack. Winding a prompt
implies making a new prompt, actually -- with new registers, a new
jump buffer, new winds, etc.
* test-suite/tests/control.test ("rewinding prompts"): Add a test for
rewinding prompts.
| Andy Wingo | 2010-02-26 | 1 | -2/+2 |
* | catch, throw, with-throw-handler implemented in Scheme...* libguile/throw.c (tc16_jmpbuffer, tc16_pre_unwind_data): Remove these
smob types, and associated constructors and accessors (all internal).
(scm_catch, scm_catch_with_pre_unwind_handler):
(scm_with_throw_handler, scm_throw): Simply dispatch to scheme.
Lovely.
(tc16_catch_closure): Introduce a new applicable smob type, for use by
the C catch interface. All constructors and accessors are internal.
(scm_c_catch, scm_internal_catch, scm_c_with_throw_handler): Build
applicable smobs out of the C procedure arguments, so we can then
dispatch through scm_catch et al.
(scm_ithrow): Dispatch to scm_throw.
(pre_init_catch, pre_init_throw): Restricted catch/throw
implementation for use before boot-9 runs.
(scm_init_throw): Bind the pre-init catch and throw definitions.
* module/ice-9/boot-9.scm (prompt, abort): Move these definitions up in
the file.
(catch, throw, with-throw-handler): Implement in Scheme. Whee!
| Andy Wingo | 2010-02-26 | 1 | -467/+149 |
* | deprecate lazy-catch...* libguile/deprecated.h:
* libguile/deprecated.c (scm_internal_lazy_catch, scm_lazy_catch):
Deprecate, and print out a nasty warning that people should change to
with-throw-handler.
* libguile/throw.h:
* libguile/throw.c (scm_c_with_throw_handler): Deprecate the use of the
lazy_catch_p argument, printing out a nasty warning if someone
actually passes 1 as that argument. The combination of the pre-unwind
and post-unwind handlers should be sufficient.
* test-suite/tests/exceptions.test: Remove lazy-catch tests, as they are
deprecated. Two of them fail:
* throw/catch: effect of lazy-catch unwinding on throw to another key
* throw/catch: repeat of previous test but with lazy-catch
Hopefully people are not depending on this behavior, and the warning is
sufficiently nasty for people to switch. We will see.
* test-suite/tests/eval.test ("promises"): Use with-throw-handler
instead of lazy-catch.
* doc/ref/api-debug.texi:
* doc/ref/api-control.texi: Update to remove references to lazy-catch,
folding in the useful bits to with-throw-handler.
| Andy Wingo | 2010-02-26 | 1 | -64/+19 |
* | SCM_CELL in throw.c...* libguile/throw.c (JBACTIVE, ACTIVATEJB, DEACTIVATEJB, JBJMPBUF)
(SETJBJMPBUF, SCM_JBPREUNWIND, SCM_SETJBPREUNWIND)
(pre_unwind_data_print, scm_ithrow): Fix SCM_CELL macro usage.
| Andy Wingo | 2009-12-08 | 1 | -12/+10 |
* | remove debug frames...* libguile/debug.h (scm_t_debug_frame): Remove this type, as it was
internal to the old evaluator.
(SCM_EVALFRAME, SCM_APPLYFRAME, SCM_VOIDFRAME, SCM_MACROEXPF)
(SCM_TAILREC, SCM_TRACED_FRAME, SCM_ARGS_READY, SCM_DOVERFLOW)
(SCM_MAX_FRAME_SIZE, SCM_FRAMETYPE)
(SCM_EVALFRAMEP, SCM_APPLYFRAMEP, SCM_VOIDFRAMEP, SCM_MACROEXPFP)
(SCM_TAILRECP, SCM_TRACED_FRAME_P, SCM_ARGS_READY_P, SCM_OVERFLOWP)
(SCM_SET_MACROEXP, SCM_SET_TAILREC, SCM_SET_TRACED_FRAME)
(SCM_SET_ARGSREADY, SCM_SET_OVERFLOW)
(SCM_CLEAR_MACROEXP, SCM_CLEAR_TRACED_FRAME, SCM_CLEAR_ARGSREADY):
Remove macro accessors to scm_t_debug_frame.
(SCM_DEBUGOBJP, SCM_DEBUGOBJ_FRAME, SCM_SET_DEBUGOBJ_FRAME):
(scm_debug_object_p, scm_make_debugobj): Remove debugobj accessors.
(scm_i_unmemoize_expr): Remove unused declaration.
* libguile/debug.c (scm_debug_options): No more max limit on frame
sizes.
(scm_start_stack): Just call out to scm_vm_call_with_new_stack.
(scm_debug_object_p, scm_make_debugobj, scm_init_debug): No more
debugobj smob type.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_i_deprecated_last_debug_frame)
(scm_last_debug_frame): Remove deprecated debug-frame bits.
* libguile/stacks.c (scm_make_stack): Rework this function and its
dependents to only walk VM frames.
(scm_stack_id): Call out to the holder of the VM frame in question,
which should be a VM or a VM continuation, for the stack ID. Currently
this bit is stubbed out.
(scm_last_stack_frame): Removed. It seems this is mainly useful for a
debugger, and we need to rewrite the debugger to work on the Scheme
level.
* test-suite/tests/continuations.test ("continuations"): Remove test for
last-stack-frame.
* libguile/continuations.h (struct scm_t_contregs):
* libguile/continuations.c (scm_make_continuation):
(copy_stack_and_call, scm_i_with_continuation_barrier): No need to
save and restore debug frames.
* libguile/threads.h (scm_i_thread): Don't track debug frames.
(scm_i_last_debug_frame, scm_i_set_last_debug_frame): Remove macro
accessors.
* libguile/threads.c (guilify_self_1): Don't track debug frames.
* libguile/throw.c: No need to track debug frames in a jmpbuf.
* libguile/vm-engine.c (vm_engine, VM_PUSH_DEBUG_FRAMES): Don't push
debug frames.
* libguile/vm.h:
* libguile/vm.c (scm_vm_call_with_new_stack): New function. Currently
stubbed out though.
| Andy Wingo | 2009-12-03 | 1 | -4/+0 |
* | Remove remaining uses of discouraged constructs, really....* libguile/throw.c, libguile/vm-engine.h, libguile/vm-i-system.c,
libguile/vm.c: Replace uses of discouraged constructs by their
current counterparts.
| Ludovic Courtès | 2009-11-28 | 1 | -2/+2 |
* | Remove remaining uses of discouraged constructs....* libguile/frames.c, libguile/instructions.c, libguile/objcodes.c,
libguile/programs.c, libguile/throw.c, libguile/vm-i-scheme.c,
libguile/vm.c: Replace uses of discouraged constructs by their
current counterparts.
| Ludovic Courtès | 2009-11-28 | 1 | -2/+2 |
* | Fix spurious `throw from within critical section' errors...The crux of this problem was that the thread doing a throw, and so
checking scm_i_critical_section_level, was different from the thread
that was in a critical section.
* libguile/async.h (scm_i_critical_section_level): Removed, replaced
by per-thread critical_section_level.
(SCM_CRITICAL_SECTION_START, SCM_CRITICAL_SECTION_END): Use
per-thread critical_section_level.
* libguile/continuations.c (scm_dynthrow): Check per-thread
critical_section_level.
* libguile/threads.c (guilify_self_1): Init per-thread
critical_section_level.
(scm_i_critical_section_level): Removed.
* libguile/threads.h (scm_i_thread): New critical_section_level field.
* libguile/throw.c (scm_ithrow): Check per-thread critical_section_level.
| Neil Jerram | 2009-09-30 | 1 | -1/+1 |