1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-29 19:30:36 +02:00
Commit graph

70 commits

Author SHA1 Message Date
Michael Käppler
08e26836f1
Fix setjmp/longjmp-related crashes on Windows
* libguile/Makefile.am: add new header file setjump-win.h
* libguile/continuations.h, libguile/dynstack.c, libguile/dynstack.h,
  libguile/intrinsics.h, libguile/vm.h:
  supply custom `setjmp` macro on Windows

Mingw implements `setjmp (env)` as a macro that expands to

 _setjmp (env, faddr)

where `faddr` is set to the current frame address.

This address is then stored as first element in the jump buffer `env`.
When `longjmp` is called, it tries to unwind the stack up
to the saved address by calling `RtlUnwindEx` from MSVCRT,
which will fail, if the stack frames are interwoven with
JIT-generated code, that violate the Windows x64 calling conventions.

Thus implement the macro ourselves as

_setjmp (env, NULL)

which will toggle a code path in `longjmp` that does no unwinding.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-20 12:14:21 +02:00
Andy Wingo
a20feea43e Continuations capture machine code address
* libguile/continuations.c (scm_i_continuation_to_frame): Adapt to vra
  field renaming.
  (scm_i_reinstate_continuation, grow_stack, copy_stack_and_call)
  (scm_dynthrow): Take mra of continuation.  Set on the vp before the
  longjmp.
* libguile/continuations.h: Update scm_i_reinstate_continuation
  prototype.
* libguile/dynstack.h:
* libguile/control.c (scm_suspendable_continuation_p):
* libguile/dynstack.c (PROMPT_WORDS, PROMPT_VRA, PROMPT_MRA):
  (PROMPT_JMPBUF, scm_dynstack_push_prompt, scm_dynstack_find_prompt)
  (scm_dynstack_wind_prompt): Store both virtual and machine return
  addresses on the dynstack, for prompts.
* libguile/eval.c (eval): Pass NULL for mra.
* libguile/intrinsics.c (push_prompt): Add mra arg, and pass it to the
  dynstack.
* libguile/intrinsics.h: Update prototypes so that continuation-related
  intrinsics can save and restore the MRA.
* libguile/jit.h:
* libguile/jit.c: Return VRA when JIT code needs to tier down.
* libguile/stacks.c (find_prompt, scm_make_stack)
* libguile/throw.c (catch): Adapt find-prompt calls.
* libguile/vm-engine.c (instrument-entry, instrument-loop): Add logic to
  continue with vcode after the mcode finishes.
  (compose-continuation, capture-continuation, abort, prompt): Add logic
  to pass NULL as captured MRA, but continue with mcode from new
  continuations, if appropriate.
* libguile/vm.c (scm_i_vm_cont_to_frame, capture_stack)
  (scm_i_capture_current_stack, reinstate_continuation_x)
  (capture_continuation, compose_continuation_inner, compose_continuation)
  (capture_delimited_continuation, abort_to_prompt): Adapt to plumb
  around machine code continuations.
  (scm_call_n): Check "mra_after_abort" field for machine code
  continuation, if any.
* libguile/vm.h (struct scm_vm): Add "mra_after_abort" field.
  (struct scm_vm_cont): Rename "ra" field to "vra" and add "mra" field.
2018-08-12 15:57:53 +02:00
Andy Wingo
64d114817a Intrinsics take registers from thread
* libguile/continuations.c (scm_i_make_continuation): Remove registers
  argument; instead get from thread.
* libguile/vm-engine.c (vm_engine): Adapt VM engine to not receive a
  registers argument, and thus to not pass it to intrinsics either.
* libguile/intrinsics.h:
* libguile/intrinsics.c (push_prompt):
* libguile/vm.c (capture_continuation, compose_continuation)
  (abort_to_prompt): Refactor these intrinsics to not take a registers
  argument; it's not necessary.
  (scm_call_n): Don't pass registers argument.
2018-06-27 18:42:21 +02:00
Andy Wingo
5804c977d7 Rename scm_i_thread to scm_thread
* libguile/scm.h (struct scm_thread, scm_thread): Rename from
  scm_i_thread.
* libguile/deprecated.h (scm_i_thread): Add deprecated typedef.
* libguile/threads.h: Adapt to renaming.
* libguile/intrinsics.h:
* libguile/scmsigs.h:
* libguile/cache-internal.h: Remove threads.h includes; unnecessary with
  the forward decl.
* libguile/continuations.h:
* libguile/gc-inline.h:
* libguile/async.h: Adapt scm_thread type name change.
* libguile/async.c:
* libguile/continuations.c:
* libguile/control.c:
* libguile/dynstack.c:
* libguile/dynwind.c:
* libguile/eval.c:
* libguile/finalizers.c:
* libguile/fluids.c:
* libguile/gc.c:
* libguile/intrinsics.c:
* libguile/load.c:
* libguile/memoize.c:
* libguile/print.c:
* libguile/read.c:
* libguile/scmsigs.c:
* libguile/script.c:
* libguile/stackchk.c:
* libguile/stacks.c:
* libguile/symbols.c:
* libguile/threads.c:
* libguile/throw.c:
* libguile/vm-engine.c:
* libguile/vm.c: Adapt to type name change, and add additional includes
  as needed.
2018-06-26 11:40:22 +02:00
Andy Wingo
51e35158ba Refactor continuation capture in VM
* libguile/continuations.h:
* libguile/continuations.c (scm_i_make_continuation): Refactor to expect
  registers to already be captured.
* libguile/scm.h (scm_i_thread): Add forward decl.
* libguile/threads.h (struct scm_i_thread): Just fill in the struct
  type.
* libguile/vm-engine.c (call/cc); Use the registers already captured
  before entering the VM.
2018-06-26 11:25:07 +02:00
Andy Wingo
5e8e816c61 Reinstating undelimited continuations uses intrinsic
* libguile/continuations.h (scm_t_contregs): Remove "struct vm*" member;
  unneeded.
* libguile/continuations.c (scm_i_make_continuation): No need to store
  continuation->vp.
  (scm_i_contregs): New internal function, replaces scm_i_contregs_vp
  and scm_i_contregs_vm_cont.
  (scm_i_check_continuation): Remove; moved to vm.c.
  (scm_i_reinstate_continuation): Add an abort(), to satisfy
  SCM_NORETURN.
* libguile/intrinsics.h: Add new "reinstate-continuation!" intrinsic.
* libguile/vm-engine.c (continuation-call): Use new
  reinstate-continuation! intrinsic.
* libguile/vm.c (vm_return_to_continuation_inner): Move later in the
  file.
  (reinstate_continuation_x): New intrinsic.
  (scm_bootstrap_vm): Init new intrinsic.
2018-06-26 11:09:36 +02:00
Andy Wingo
3b6bf20ef5 Most header files use forward decl for union scm_vm_stack_element
* libguile.h: Add includes for frames.h and vm.h.  Probably need to
  revisit these includes.
* libguile/scm.h (struct scm_frame, union scm_vm_stack_element)
  (struct scm_vm): Add forward declarations.
* libguile/vm.h: Remove frames.h include.
* libguile/foreign.h:
* libguile/gsubr.h: Remove forward decls of union scm_vm_stack_element.
* libguile/control.c:
* libguile/eval.c:
* libguile/print.c: Add frames.h includes.
* libguile/threads.h: Remove continuations.h.
* libguile/vm.c: Add continuations.h.
* libguile/control.h: Swap vm.h include for scm.h include.
* libguile/continuations.h: Add programs.h include for SCM_PROGRAM_P.
2018-06-26 10:55:02 +02:00
Andy Wingo
6ad1fc9ce0 Use ptrdiff_t instead of scm_t_ptrdiff
* libguile/continuations.h:
* libguile/control.c:
* libguile/control.h:
* libguile/dynstack.c:
* libguile/dynstack.h:
* libguile/eval.c:
* libguile/foreign.c:
* libguile/frames.h:
* libguile/gen-scmconfig.c:
* libguile/gsubr.c:
* libguile/gsubr.h:
* libguile/loader.c:
* libguile/numbers.h:
* libguile/stacks.c:
* libguile/throw.c:
* libguile/vm-engine.c:
* libguile/vm.c:
* libguile/vm.h: Use ptrdiff_t from stddef.h.
2018-06-21 20:20:01 +02:00
Andy Wingo
1234bb1850 Update license notices in all C files
Update to newest recommended license notices from the FSF.  Everything
stays LGPLv3+ except guile-readline which is GPLv3+.
2018-06-20 20:07:34 +02:00
Andy Wingo
791eb0c01a Remove (C) from copyright statements
As the FSF advises, 'There is no legal significance to using the
three-character sequence “(C)”, but it does no harm.'  It does take up
space though!  For that reason, we remove it here from our C files.
2018-06-20 19:17:06 +02:00
Andy Wingo
97cc65fee4 Rename __scm.h to scm.h
* libguile/scm.h: Rename.  Update all includers.
2018-06-20 16:33:33 +02:00
Andy Wingo
c495b44714 Remove Emacs local variables comments in Guile source
The .dir-locals.el file in the repository is sufficient for Emacs
users.

* libguile/__scm.h:
* libguile/alist.c:
* libguile/alist.h:
* libguile/array-handle.c:
* libguile/array-handle.h:
* libguile/array-map.c:
* libguile/array-map.h:
* libguile/arrays.c:
* libguile/arrays.h:
* libguile/async.c:
* libguile/async.h:
* libguile/backtrace.c:
* libguile/backtrace.h:
* libguile/bitvectors.c:
* libguile/bitvectors.h:
* libguile/boolean.c:
* libguile/boolean.h:
* libguile/chars.c:
* libguile/chars.h:
* libguile/chooks.c:
* libguile/chooks.h:
* libguile/continuations.c:
* libguile/continuations.h:
* libguile/control.c:
* libguile/conv-integer.i.c:
* libguile/debug-malloc.h:
* libguile/debug.c:
* libguile/debug.h:
* libguile/deprecation.c:
* libguile/deprecation.h:
* libguile/dynl.c:
* libguile/dynl.h:
* libguile/dynstack.c:
* libguile/dynstack.h:
* libguile/dynwind.c:
* libguile/dynwind.h:
* libguile/eq.c:
* libguile/eq.h:
* libguile/error.c:
* libguile/error.h:
* libguile/eval.c:
* libguile/eval.h:
* libguile/evalext.c:
* libguile/evalext.h:
* libguile/expand.c:
* libguile/expand.h:
* libguile/extensions.c:
* libguile/extensions.h:
* libguile/feature.c:
* libguile/feature.h:
* libguile/filesys.c:
* libguile/filesys.h:
* libguile/fluids.c:
* libguile/fluids.h:
* libguile/foreign.c:
* libguile/fports.c:
* libguile/fports.h:
* libguile/frames.c:
* libguile/frames.h:
* libguile/gc-inline.h:
* libguile/gc.c:
* libguile/gc.h:
* libguile/generalized-arrays.c:
* libguile/generalized-arrays.h:
* libguile/generalized-vectors.c:
* libguile/generalized-vectors.h:
* libguile/gettext.c:
* libguile/gettext.h:
* libguile/goops.c:
* libguile/goops.h:
* libguile/gsubr.c:
* libguile/gsubr.h:
* libguile/guardians.c:
* libguile/guardians.h:
* libguile/guile.c:
* libguile/hash.c:
* libguile/hash.h:
* libguile/hashtab.c:
* libguile/hashtab.h:
* libguile/hooks.c:
* libguile/hooks.h:
* libguile/i18n.c:
* libguile/i18n.h:
* libguile/init.c:
* libguile/init.h:
* libguile/instructions.c:
* libguile/instructions.h:
* libguile/intrinsics.c:
* libguile/intrinsics.h:
* libguile/ioext.c:
* libguile/ioext.h:
* libguile/iselect.h:
* libguile/keywords.c:
* libguile/keywords.h:
* libguile/list.c:
* libguile/list.h:
* libguile/load.c:
* libguile/load.h:
* libguile/loader.c:
* libguile/loader.h:
* libguile/macros.c:
* libguile/macros.h:
* libguile/mallocs.c:
* libguile/mallocs.h:
* libguile/memmove.c:
* libguile/memoize.c:
* libguile/memoize.h:
* libguile/modules.c:
* libguile/modules.h:
* libguile/net_db.c:
* libguile/net_db.h:
* libguile/null-threads.c:
* libguile/null-threads.h:
* libguile/numbers.c:
* libguile/numbers.h:
* libguile/objprop.c:
* libguile/objprop.h:
* libguile/options.c:
* libguile/options.h:
* libguile/pairs.c:
* libguile/pairs.h:
* libguile/poll.c:
* libguile/poll.h:
* libguile/ports.c:
* libguile/ports.h:
* libguile/posix.c:
* libguile/posix.h:
* libguile/print.c:
* libguile/print.h:
* libguile/procprop.c:
* libguile/procprop.h:
* libguile/procs.c:
* libguile/procs.h:
* libguile/programs.c:
* libguile/programs.h:
* libguile/promises.c:
* libguile/promises.h:
* libguile/pthread-threads.h:
* libguile/random.c:
* libguile/random.h:
* libguile/rdelim.c:
* libguile/rdelim.h:
* libguile/read.c:
* libguile/read.h:
* libguile/regex-posix.c:
* libguile/regex-posix.h:
* libguile/rw.c:
* libguile/rw.h:
* libguile/scmsigs.c:
* libguile/scmsigs.h:
* libguile/script.c:
* libguile/script.h:
* libguile/simpos.c:
* libguile/simpos.h:
* libguile/smob.c:
* libguile/smob.h:
* libguile/snarf.h:
* libguile/socket.c:
* libguile/socket.h:
* libguile/sort.c:
* libguile/sort.h:
* libguile/srcprop.c:
* libguile/srcprop.h:
* libguile/stackchk.c:
* libguile/stackchk.h:
* libguile/stacks.c:
* libguile/stacks.h:
* libguile/stime.c:
* libguile/stime.h:
* libguile/strerror.c:
* libguile/strings.c:
* libguile/strings.h:
* libguile/strorder.c:
* libguile/strorder.h:
* libguile/strports.c:
* libguile/strports.h:
* libguile/struct.c:
* libguile/struct.h:
* libguile/symbols.c:
* libguile/symbols.h:
* libguile/syntax.c:
* libguile/syscalls.h:
* libguile/tags.h:
* libguile/threads.c:
* libguile/threads.h:
* libguile/throw.c:
* libguile/throw.h:
* libguile/trees.h:
* libguile/unicode.c:
* libguile/unicode.h:
* libguile/uniform.c:
* libguile/uniform.h:
* libguile/values.c:
* libguile/values.h:
* libguile/variable.c:
* libguile/variable.h:
* libguile/vectors.c:
* libguile/vectors.h:
* libguile/version.c:
* libguile/vm-engine.c:
* libguile/vm-expand.h:
* libguile/vm.c:
* libguile/vm.h:
* libguile/vports.c:
* libguile/vports.h:
* libguile/weak-list.h:
* libguile/weak-set.c:
* libguile/weak-set.h:
* libguile/weak-table.c:
* libguile/weak-table.h:
* libguile/weak-vector.c:
* libguile/weak-vector.h: Remove needless trailing comments.
2018-06-20 14:32:28 +02:00
Andy Wingo
5534c2817e Remove useless "classes: h_files" from Guile headers.
* libguile/__scm.h:
* libguile/alist.h:
* libguile/array-handle.h:
* libguile/array-map.h:
* libguile/arrays.h:
* libguile/async.h:
* libguile/backtrace.h:
* libguile/bitvectors.h:
* libguile/boolean.h:
* libguile/chars.h:
* libguile/chooks.h:
* libguile/continuations.h:
* libguile/debug-malloc.h:
* libguile/debug.h:
* libguile/deprecation.h:
* libguile/dynl.h:
* libguile/dynstack.h:
* libguile/dynwind.h:
* libguile/eq.h:
* libguile/error.h:
* libguile/eval.h:
* libguile/evalext.h:
* libguile/expand.h:
* libguile/extensions.h:
* libguile/feature.h:
* libguile/filesys.h:
* libguile/fluids.h:
* libguile/fports.h:
* libguile/gc-inline.h:
* libguile/gc.h:
* libguile/generalized-arrays.h:
* libguile/generalized-vectors.h:
* libguile/gettext.h:
* libguile/goops.h:
* libguile/gsubr.h:
* libguile/guardians.h:
* libguile/hash.h:
* libguile/hashtab.h:
* libguile/hooks.h:
* libguile/i18n.h:
* libguile/init.h:
* libguile/inline.h:
* libguile/ioext.h:
* libguile/iselect.h:
* libguile/keywords.h:
* libguile/list.h:
* libguile/load.h:
* libguile/macros.h:
* libguile/mallocs.c:
* libguile/mallocs.h:
* libguile/memoize.h:
* libguile/modules.h:
* libguile/net_db.h:
* libguile/null-threads.h:
* libguile/numbers.h:
* libguile/objprop.h:
* libguile/options.h:
* libguile/pairs.h:
* libguile/poll.h:
* libguile/ports.h:
* libguile/posix-w32.h:
* libguile/posix.h:
* libguile/print.h:
* libguile/procprop.h:
* libguile/procs.h:
* libguile/promises.h:
* libguile/pthread-threads.h:
* libguile/random.h:
* libguile/rdelim.h:
* libguile/read.h:
* libguile/regex-posix.h:
* libguile/rw.h:
* libguile/scmsigs.h:
* libguile/script.h:
* libguile/simpos.h:
* libguile/smob.h:
* libguile/snarf.h:
* libguile/socket.h:
* libguile/sort.h:
* libguile/srcprop.h:
* libguile/stackchk.h:
* libguile/stacks.h:
* libguile/stime.h:
* libguile/strings.h:
* libguile/strorder.h:
* libguile/strports.h:
* libguile/struct.h:
* libguile/symbols.h:
* libguile/syscalls.h:
* libguile/tags.h:
* libguile/threads.h:
* libguile/throw.h:
* libguile/trees.h:
* libguile/unicode.h:
* libguile/uniform.h:
* libguile/values.h:
* libguile/variable.h:
* libguile/vectors.h:
* libguile/vports.h:
* libguile/weak-list.h:
* libguile/weak-set.h:
* libguile/weak-table.h:
* libguile/weak-vector.h: Remove "classes: h_files".  Reformat
  copyrights if needed.
2018-06-20 14:26:16 +02:00
Andy Wingo
1ddf42dae0 Devolve threads.h from _scm.h.
* libguile/__scm.h (scm_print_state, scm_t_dynstack): Add forward
  declarations.
* libguile/_scm.h: Remove threads.h.
* libguile/atomic.c:
* libguile/bitvectors.h:
* libguile/bytevectors.c:
* libguile/continuations.h:
* libguile/control.c:
* libguile/deprecation.c:
* libguile/dynl.c:
* libguile/dynstack.h:
* libguile/dynwind.c:
* libguile/extensions.c:
* libguile/fdes-finalizers.c:
* libguile/foreign-object.c:
* libguile/frames.c:
* libguile/guardians.c:
* libguile/hashtab.c:
* libguile/list.c:
* libguile/loader.c:
* libguile/macros.c:
* libguile/memoize.c:
* libguile/net_db.c:
* libguile/pairs.c:
* libguile/procprop.c:
* libguile/rdelim.c:
* libguile/simpos.c:
* libguile/srfi-14.c:
* libguile/srfi-60.c:
* libguile/strings.c:
* libguile/strports.c:
* libguile/syntax.c:
* libguile/syntax.h:
* libguile/unicode.c:
* libguile/variable.c:
* libguile/vectors.c:
* libguile/weak-set.c:
* libguile/weak-set.h:
* libguile/weak-table.c:
* libguile/weak-table.h:
* libguile/weak-vector.c: Add threads.h as appropriate, or possible
  other headers that threads.h pulled in.
2018-06-20 11:52:29 +02:00
Andy Wingo
f84ce5442e Refactor handling of auxiliary stacks and setjmp/longjmp
* libguile/__scm.h (scm_i_jmp_buf): Remove definition, which was a shim
  for ia64.  Instead, always use setjmp/longjmp and jmp_buf.
* libguile/_scm.h (SCM_I_SETJMP, SCM_I_LONGJMP): Remove; instead use
  setjmp and longjmp.
* libguile/continuations.c (capture_auxiliary_stack):
  (restore_auxiliary_stack): New helpers.
  (scm_i_make_continuation): Use capture_auxiliary_stack.
  (copy_stack_and_call): Use restore_auxiliary_stack.  No need to stash
  the aux stack on the thread, either.
* libguile/continuations.h (scm_t_contregs): Use
  SCM_HAVE_AUXILIARY_STACK to flag when to have an auxiliary_stack
  member.
* libguile/control.h:
* libguile/control.c (reify_partial_continuation, scm_c_abort):
  (scm_suspendable_continuation_p): Adapt to use setjmp/longjmp
  directly.
* libguile/deprecated.h: Add deprecated scm_i_jmp_buf define.
* libguile/dynstack.h:
* libguile/dynstack.c (PROMPT_JMPBUF):
  (scm_dynstack_push_prompt, scm_dynstack_find_prompt):
  (scm_dynstack_wind_prompt): Adapt to jmp_buf type.
* libguile/eval.c (eval): Use jmp_buf and setjmp directly.
* libguile/gc-malloc.c: No need for ia64-specific things.
* libguile/gc.c: No need for ia64-specific things.
* libguile/gc.h: No need to declare scm_ia64_ar_bsp.
* libguile/init.c: Remove typedef of setjmp_type for Cray, unused.
* libguile/threads.c (guilify_self_1): No more pending_rbs_continuation
  in scm_i_thread, and register_backing_store_base is handled by libgc.
  (scm_ia64_ar_bsp): Remove definitions; inlined into continuations.c's
  capture_auxiliary_stack.
* libguile/threads.h (scm_i_thread): jmpbuf member is plain jmp_buf.
* libguile/throw.c (catch): Just use jmp_buf and setjmp.
* libguile/vm-engine.c (VM_NAME): Adapt prototype to take jmp_buf
  pointer.
* libguile/vm.c (vm_abort): Adapt jmp_buf types.
  (scm_call_n): Use setjmp.
2018-06-17 13:41:03 +02:00
Andy Wingo
3b14dd2f27 Optimize make-stack
* libguile/continuations.h:
* libguile/continuations.c (scm_i_continuation_to_frame): Operate on
  low-level C structures instead of heap objects.

* libguile/frames.h:
* libguile/frames.c (frame_offset, frame_stack_base): Const args.
  (scm_c_frame_closure): New helper.
  (scm_frame_procedure): Use the new helper.

* libguile/stacks.c (stack_depth, narrow_stack, scm_make_stack): Rework
  to avoid allocating frames as we traverse the stack, and to avoid an
  n**2 case where there are outer cuts.
2014-04-14 16:31:02 +02:00
Andy Wingo
796e54a74c One more SCM vm user: continuations.
* libguile/continuations.c:
* libguile/continuations.h (struct scm_t_contregs): Rename SCM vm member
  to struct scm_vm *vp.
  (scm_i_make_continuation): Take vp instead of vm.
  (scm_i_contregs_vp): Rename from scm_i_contregs_vm, return vp.

* libguile/vm-engine.c (continuation-call, call/cc): Fix remaining SCM
  vm user.

* libguile/vm.c (vm_return_to_continuation): Adapt prototype.
2013-11-21 17:50:33 +01:00
Andy Wingo
d798a895cc Remove RTL_ infix from macros
* libguile/programs.h (SCM_PROGRAM_P):
  (SCM_PROGRAM_CODE):
  (SCM_PROGRAM_FREE_VARIABLES):
  (SCM_PROGRAM_FREE_VARIABLE_REF):
  (SCM_PROGRAM_FREE_VARIABLE_SET):
  (SCM_PROGRAM_NUM_FREE_VARIABLES):
  (SCM_VALIDATE_PROGRAM): Remove RTL_ infix.

* libguile/continuations.c:
* libguile/continuations.h:
* libguile/control.c:
* libguile/foreign.c:
* libguile/frames.c:
* libguile/gsubr.c:
* libguile/gsubr.h:
* libguile/procprop.c:
* libguile/procs.c:
* libguile/programs.c:
* libguile/stacks.c:
* libguile/vm-engine.c: Adapt.
2013-11-19 18:28:19 +01:00
Andy Wingo
486013d67c VM has "builtins": primitives addressable by emitted RTL code
* libguile/Makefile.am:
* libguile/vm-builtins.h: New header, declaring stubs needed by the
  compiler like values, apply, and abort-to-prompt.

* libguile/vm.c: Adapt the apply and values stubs to conform to a
  standard interface.  Add an abort-to-prompt stub.  Add call/cc and
  call-with-values stubs.
  (scm_vm_builtin_ref): New helper, for the builtin-ref opcode.
  (scm_vm_builtin_name_to_index)
  (scm_vm_builtin_index_to_name): New helpers, for the compiler and
  disassembler, respectively.
  (scm_init_vm_builtins, scm_bootstrap_vm): Allow the compiler helpers
  to be loaded later into a module.
* module/language/rtl.scm: Export builtin-index->name and
  builtin-name->index.

* libguile/vm-engine.c (RETURN_VALUE_LIST): Update to use new names of
  "apply" and "values".
  (tail-call/shuffle): New opcode.
  (abort): Update to be a tail VM op, and reorder and renumber other
  ops.
  (builtin-ref): New opcode.

* libguile/continuations.h:
* libguile/continuations.c (scm_i_call_with_current_continuation):
  Move this to vm.[ch], implemented as a builtin.

* module/language/tree-il/compile-cps.scm (convert): Convert to
  'abort-to-prompt calls, possibly with 'apply, effectively undoing the
  tree-il transformation.

* module/language/cps/reify-primitives.scm (builtin-ref): New helper.
  (reify-primitives): Convert builtin primitives to builtin-ref.

* module/language/cps/dfg.scm (constant-needs-allocation?):
* module/language/cps/compile-rtl.scm (emit-rtl-sequence): Add support
  for compiling builtin-ref.

* module/system/vm/disassembler.scm (code-annotation): Add annotation
  for builtin-ref.
2013-10-27 20:09:01 +01:00
Andy Wingo
d691ac2069 Continuations are RTL stubs
* libguile/continuations.h:
* libguile/continuations.c: Reimplement continuations and the call_cc
  stub as RTL programs.

* libguile/programs.c (scm_i_rtl_program_minimum_arity): Add a case for
  continuations.

* libguile/vm-engine.c (rtl_vm_debug_engine): Always call the abort
  continuation hook with the number of non-procedure locals.  Fix
  compose-continuation argument count.  Enable call/cc.
2013-10-18 18:47:49 +02:00
Andy Wingo
9ede013f68 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.
2012-03-03 17:06:02 +01:00
Andy Wingo
d8873dfe47 continuations return multiple values on the stack
* libguile/vm.h (struct scm_vm_cont): Instead of saving the "IP", save
  "RA" and "MVRA". That is, save singly-valued and multiply-valued
  return addresses, so that we can return multiple values on the stack.
  (scm_i_vm_reinstate_continuation): Remove.
* libguile/vm.c (vm_capture_continuation): Rename from capture_vm_cont,
  and change the prototype so we can capture the RA and MVRA, and so
  that tail calls to call/cc can capture a continuation without the
  call/cc application frame.
  (vm_return_to_continuation): Rename from reinstate_vm_cont, and take
  arguments to return to the continuation. Handles returning to single
  or multiple-value RA.
  (scm_i_vm_capture_continuation): Change to invoke
  vm_capture_continuation. Kept around for the benefit of make-stack.

* libguile/vm-i-system.c (continuation-call): Handle reinstatement of
  the VM stack, with arguments.
  (call/cc, tail-call/cc): Adapt to new vm_capture_continuation
  prototype. tail-call/cc captures tail continuations.

* libguile/stacks.c (scm_make_stack): Update for scm_vm_cont structure
  change.

* libguile/continuations.h (struct scm_contregs): Remove throw_value
  member, which was used to return a value to a continuation.
  (scm_i_check_continuation): New internal function, checks that a
  continuation may be reinstated.
  (scm_i_reinstate_continuation): Replaces scm_i_continuation_call; just
  reinstates the C stack.
  (scm_i_contregs_vm, scm_i_contregs_vm_cont): New internal accessors.
* libguile/continuations.c (scm_i_make_continuation): Return
  SCM_UNDEFINED if we are returning again.
  (grow_stack, copy_stack_and_call, scm_dynthrow): Remove extra arg, as
  vm opcodes handle value returns.
  (copy_stack): No need to instate VM continuation.
  (scm_i_reinstate_continuation): Adapt.
2010-02-08 22:59:25 +01:00
Andy Wingo
269479e31f scm_i_make_continuation takes vm and vm_cont args explicitly
* libguile/continuations.h:
* libguile/continuations.c (scm_i_make_continuation): Take VM and VM
  continuation arguments as well; I'm not convinced that saving all VM
  continuations was the right thing, and in any case we only ever saved
  the latest. Running a new VM should create a continuation barrier.

* libguile/stacks.c (scm_make_stack):
* libguile/vm-i-system.c (call/cc, tail-call/cc): Adapt callers.

* libguile/vm.h (scm_i_vm_capture_continuation)
  (scm_i_vm_reinstate_continuation): Change to be internal, and to only
  capture and reinstate continuations for a particular VM.
2010-02-08 13:35:42 +01:00
Andy Wingo
997659f898 make scm_make_continuation internal
* libguile/continuations.h:
* libguile/continuations.c (scm_i_make_continuation): Change from
  scm_make_continuation, and make internal.

* libguile/vm-i-system.c (call/cc, tail-call/cc): Adapt callers.

* test-suite/standalone/test-unwind.c (check_cont_body): Adapt a test.

* doc/ref/api-control.texi (Continuations): Update docs.
2010-02-08 13:35:06 +01:00
Andy Wingo
babfc7b2c3 eval.c uses scm_i_call_with_current_continuation
* libguile/continuations.h
* libguile/continuations.c (scm_i_call_with_current_continuation): New
  internal function. Not exported because I'm not sure whether or not
  this should have a continuation barrier in the future. Uses a
  hand-coded VM procedure.

* libguile/eval.c (eval): Use scm_i_call_with_current_continuation.
2010-02-08 13:34:26 +01:00
Andy Wingo
1d1cae0e2e continuations are vm procedures
* libguile/vm-i-system.c (continuation-call): New op, like subr-call or
  foreign-call, but for continuations.

* libguile/continuations.h: Add scm_i_continuation_call internal
  declaration.
  (SCM_CONTINUATIONP): Reimplement in terms of
  SCM_PROGRAM_IS_CONTINUATION.
  (scm_tc16_continuation, SCM_CONTREGS, SCM_CONTINUATION_LENGTH)
  (SCM_SET_CONTINUATION_LENGTH, SCM_JMPBUF, SCM_DYNENV, SCM_THROW_VALUE)
  (SCM_CONTINUATION_ROOT, SCM_DFRAME): Remove these from the exposed
  API.
  (scm_i_continuation_to_frame): New internal declaration.
* libguile/continuations.c
* libguile/continuations.c: Add trickery like in foreign.c, smob.c, and
  gsubr.c, so that we can make procedural trampolines for continuations.
  (scm_i_continuation_to_frame): New internal function, from stacks.c.

* libguile/programs.h (SCM_F_PROGRAM_IS_CONTINUATION)
  (SCM_PROGRAM_IS_CONTINUATION): Add a flag for programs that are
  continuations. Probably should add flags for the other trampoline
  types too.
* libguile/programs.c (scm_i_program_print): Print continuations as
  before.

* libguile/stacks.c (scm_stack_id, scm_make_stack): Use
  scm_i_continuation_to_frame in the continuation case.
2010-02-08 13:00:54 +01:00
Andy Wingo
0236bc683d fix SCM_CELL macro usage in continuations.[ch]
* libguile/continuations.h (SCM_CONTREGS):
* libguile/continuations.c (continuation_print): Fix SCM_CELL macro
  usage.
2009-12-08 23:13:07 +01:00
Andy Wingo
14aa25e410 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.
2009-12-03 11:03:39 +01:00
Neil Jerram
a4dbe1ac3d Avoid clash with system setjmp/longjmp on IA64
Problem was that if an application includes both libguile.h and the
system's setjmp.h, and is compiled on IA64, it gets compile errors
because of jmp_buf, setjmp and longjmp being multiply defined.

* libguile/__scm.h (__ia64__): Define scm_i_jmp_buf, SCM_I_SETJMP and
  SCM_I_LONGJMP instead of jmp_buf, setjmp and longjmp.

  (all other platforms): Map scm_i_jmp_buf, SCM_I_SETJMP and
  SCM_I_LONGJMP to jmp_buf, setjmp and longjmp.

* libguile/continuations.c (scm_make_continuation): Use `SCM_I_SETJMP'
  instead of `setjmp'.
  (copy_stack_and_call): Use `SCM_I_LONJMP' instead of `longjmp'.
  (scm_ia64_longjmp): Use type `scm_i_jmp_buf' instead of `jmp_buf'.

* libguile/continuations.h (scm_t_contregs): Use type `scm_i_jmp_buf'
  instead of `jmp_buf'.

* libguile/threads.c (suspend): Use `SCM_I_SETJMP' instead of
  `setjmp'.

* libguile/threads.h (scm_i_thread): Use type `scm_i_jmp_buf' instead
  of `jmp_buf'.

* libguile/throw.c (JBJMPBUF, make_jmpbuf, jmp_buf_and_retval): Use
  type `scm_i_jmp_buf' instead of `jmp_buf'.
  (scm_c_catch): Use `SCM_I_SETJMP' instead of `setjmp'.
  (scm_ithrow): Use `SCM_I_LONGJMP' instead of `longjmp'.
2009-08-21 23:29:08 +01:00
Neil Jerram
53befeb700 Change Guile license to LGPLv3+
(Not quite finished, the following will be done tomorrow.
   module/srfi/*.scm
   module/rnrs/*.scm
   module/scripts/*.scm
   testsuite/*.scm
   guile-readline/*
)
2009-06-17 00:22:09 +01:00
Andy Wingo
bfffd2583c make call/cc capture and restore the vm stacks
* libguile/continuations.c (scm_make_continuation): Capture VM
  continuations as well, as their stack is outside the C stack.
  (copy_stack): Reinstate VM stacks with the C stack.

* libguile/continuations.h (scm_t_contregs): Add a pointer for VM stacks.
  A binary-incompatible change -- hopefully not too many people were
  messing around with this struct, though.

* libguile/vm-engine.c (vm_run): Add a note about possibly maintaining a
  stack of vms.

* libguile/vm.c (struct scm_vm_cont): New struct, distinct from scm_vm.
  (vm_cont_mark, vm_cont_free, capture_vm_cont, reinstate_vm_cont):
  Reorder some code, and fix some bad assumptions about what part of the
  stack to copy; obviously this code was never used.

* libguile/vm.h:
* libguile/vm.c (scm_vm_capture_continuations)
  (scm_vm_reinstate_continuations): New public functions, used by
  continuations.c.
2008-09-24 17:04:14 +02:00
Ludovic Courtès
102dbb6f6c Add `SCM_INTERNAL' macro, use it. 2008-05-31 23:21:02 +02:00
Neil Jerram
346e4402a4 Fix continuation problems on IA64.
* Specific problems in IA64 make check

** test-unwind

Representation of the relevant dynamic context:

                  non-rewindable
           catch      frame       make cont.
  o----o-----a----------b-------------c
        \
         \             call cont.
          o-----o-----------d

A continuation is captured at (c), with a non-rewindable frame in the
dynamic context at (b).  If a rewind through that frame was attempted,
Guile would throw to the catch at (a).  Then the context unwinds back
past (a), then winds forwards again, and the captured continuation is
called at (d).

We should end up at the catch at (a).  On ia64, we get an "illegal
instruction".

The problem is that Guile does not restore the ia64 register backing
store (RBS) stack (which is saved off when the continuation is
captured) until all the unwinding and rewinding is done.  Therefore,
when the rewind code (scm_i_dowinds) hits the non-rewindable frame at
(b), the RBS stack hasn't yet been restored.  The throw finds the
jmp_buf (for the catch at (a)) correctly from the dynamic context, and
jumps back to (a), but the RBS stack is invalid, hence the illegal
instruction.

This could be fixed by restoring the RBS stack earlier, at the same
point (copy_stack) where the normal stack is restored.  But that
causes a problem in the next test...

** continuations.test

The dynamic context diagram for this case is similar:

                   non-rewindable
  catch                 frame       make cont.
    a----x-----o----------b-------------c
          \
           \    call cont.
            o-------d

The only significant difference is that the catch point (a) is
upstream of where the dynamic context forks.  This means that the RBS
stack at (d) already contains the correct RBS contents for throwing
back to (a), so it doesn't matter whether the RBS stack that was saved
off with the continuation gets restored.

This test passes with the Guile 1.8.4 code, but fails (with an
"illegal instruction") when the code is changed to restore the RBS
stack earlier as described above.

The problem now is that the RBS stack is being restored _too_ early;
specifically when there is still stuff to do that relies on the old
RBS contents.  When a continuation is called, the sequence of relevant
events is:

  (1) Grow the (normal) stack until it is bigger than the (normal)
      stack saved off in the continuation.  (scm_dynthrow, grow_stack)

  (2) scm_i_dowinds calls itself recursively, such that

      (2.1) for each rewind (from (x) to (c)) that will be needed,
            another frame is added to the stack (both normal and RBS),
            with local variables specifying the required rewind; the
            rewinds don't actually happen yet, they will happen when
            the stack unwinds again through these frames

      (2.2) required unwinds - back from where the continuation was
            called (d) to the fork point (x) - are done immediately.

  (3) The normal (i.e. non-RBS) stack that was stored in the
      continuation is restored (i.e. copied on top of the actual
      stack).

      Note that this doesn't overwrite the frames that were added in
      (2.1), because the growth in (1) ensures that the added frames
      are beyond the end of the restored stack.

  (4) ? Restore the RBS stack here too ?

  (5) Return (from copy_stack) through the (2.1) frames, which means
      that the rewinds now happen.

  (6) setcontext (or longjmp) to the context (c) where the
      continuation was captured.

The trouble is that step (1) does not create space in the RBS stack in
the same kind of way that it does for the normal stack.  Therefore, if
the saved (in the continuation) RBS stack is big enough, it can
overwrite the RBS of the (2.1) frames that still need to complete.
This causes an illegal instruction when we return through those frames
and try to perform the rewinds.

* Fix

The key to the fix is that the saved RBS stack only needs to be
restored at some point before the next setcontext call, and that doing
it as close to the setcontext call as possible will avoid bad
interactions with the pre-setcontext stack.  Therefore we do the
restoration at the last possible point, immediately before the next
setcontext call.

The situation is complicated by there being two ways that the next
setcontext call can happen.

  - If the unwinding and rewinding is all successful, the next
    setcontext will be the one from step (6) above.  This is the
    "normal" continuation invocation case.

  - If one of the rewinds throws an error, the next setcontext will
    come from the throw implementation code.  (And the one in step (6)
    will never happen.)  This is the rewind error case.

In the rewind error case, the code calling setcontext knows nothing
about the continuation.  So to cover both cases, we:

  - copy (in step (4) above) the address and length of the
    continuation's saved RBS stack to the current thread state
    (SCM_I_CURRENT_THREAD)

  - modify all setcontext callers so that they check the current
    thread state for a saved RBS stack, and restore it if so before
    calling setcontext.

* Notes

** I think rewinders cannot rely on using any stack data

Unless it can be guaranteed that the data won't go into a register.
I'm not 100% sure about this, but I think it follows from the fact
that the RBS stack is not restored until after the rewinds have
happened.

Note that this isn't a regression caused by the current fix.  In Guile
1.8.4, the RBS stack was restored _after_ the rewinds, and this is
still the case now.

** Most setcontext calls for `throw' don't need to change the RBS stack

In the absence of continuation invocation, the setcontext call in the
throw implementation code always sets context to a place higher up the
same stack (both normal and RBS), hence no stack restoration is
needed.

* Other changes

** Using setcontext for all non-local jumps (for __ia64__)

Along the way, I read a claim somewhere that setcontext was more
reliable than longjmp, in cases where the stack has been manipulated.

I don't now have any reason to believe this, but it seems reasonable
anyway to leave the __ia64__ code using getcontext/setcontext, instead
of setjmp/longjmp.

(I think the only possible argument against this would be performance -
if getcontext was significantly slower than setjmp.  It that proves to
be the case, we should revisit this.)

** Capping RBS base for non-main threads

Somewhere else along the way, I hit a problem in GC, involving the RBS
stack of a non-main thread.  The problem was, in
SCM_MARK_BACKING_STORE, that scm_ia64_register_backing_store_base was
returning a value that was massively greater than the value of
scm_ia64_ar_bsp, leading to a seg fault.  This is because the
implementation of scm_ia64_register_backing_store_base is only valid
for the main thread.  I couldn't find a neat way of getting the true
RBS base of a non-main thread, but one idea is simply to call
scm_ia64_ar_bsp when guilifying a thread, and use the value returned
as an upper bound for that thread's RBS base.  (Note that the RBS
stack grows upwards.)

(Were it not for scm_init_guile, we could be much more definitive
about this.  We could take the value of scm_ia64_ar_bsp as a
definitive base address for the part of the RBS stack that Guile cares
about.  We could also then discard
scm_ia64_register_backing_store_base.)
2008-05-12 23:24:28 +01:00
Neil Jerram
9a5fa6e98a * configure.in: New check for uca lib (needed for IA64 on HP-UX).
* threads.c (SCM_MARK_BACKING_STORE): Use scm_ia64_ar_bsp() and
scm_ia64_register_backing_store_base() instead of Linux-specific
implementations.

* gc.h (scm_ia64_register_backing_store_base, scm_ia64_ar_bsp):
New declarations.

* gc.c (__libc_ia64_register_backing_store_base): Declaration
removed.
(scm_ia64_register_backing_store_base, scm_ia64_ar_bsp): New, with
implementations for Linux and HP-UX.

* coop-pthreads.c (SCM_MARK_BACKING_STORE): Use scm_ia64_ar_bsp()
and scm_ia64_register_backing_store_base() instead of
Linux-specific implementations.

* continuations.h (__libc_ia64_register_backing_store_base):
Declaration removed.
(scm_t_contregs): New "fresh" field.

* continuations.c (ia64_getcontext): Removed.
(scm_make_continuation): Use continuation fresh field instead of
interpreting getcontext return values (which isn't portable).  Use
scm_ia64_ar_bsp() and scm_ia64_register_backing_store_base()
instead of Linux-specific implementations.
(copy_stack_and_call): Use scm_ia64_register_backing_store_base()
instead of Linux-specific implementation.

* _scm.h (__ia64__): Also detect __ia64.
2006-10-25 22:37:24 +00:00
Kevin Ryde
2b829bbb3d merge from 1.8 branch 2006-04-17 00:05:42 +00:00
Neil Jerram
43e01b1ee3 * throw.h (scm_c_catch, scm_c_with_throw_handler,
scm_catch_with_pre_unwind_handler, scm_with_throw_handler): New.

* throw.c (SCM_JBPREUNWIND, SCM_SETJBPREUNWIND): New.
(struct pre_unwind_data): New, replaces struct lazy_catch.
(scm_c_catch): New, replaces scm_internal_catch as the primary
catch API for C code; adds pre-unwind handler support.
(scm_internal_catch): Now just a wrapper for scm_c_catch, for back
compatibility.
(tc16_pre_unwind_data, pre_unwind_data_print,
make_pre_unwind_data, SCM_PRE_UNWIND_DATA_P): Renamed from
"lazy_catch" equivalents.
(scm_c_with_throw_handler): New, replaces scm_internal_lazy_catch
as the primary C API for a "lazy" catch.
(scm_internal_lazy_catch): Now just a wrapper for
scm_c_with_throw_handler, for back compatibility.
(scm_catch_with_pre_unwind_handler): Renamed from scm_catch; adds
pre-unwind handler support.
(scm_catch): Now just a wrapper for
scm_catch_with_pre_unwind_handler, for back compatibility.
(scm_with_throw_handler): New.
(scm_lazy_catch): Update comment to say that the handler can
return, and what happens if it does.
(toggle_pre_unwind_running): New.
(scm_ithrow): When identifying the throw target, take running
flags into account.  In general, change naming of things from
"lazy_catch" to "pre_unwind".  When throwing to a throw handler,
don't unwind the dynamic context first.  Add dynwind framing to
manage the running flag of a throw handler.  If a lazy catch or
throw handler returns, rethrow the same exception again.  Add
pre-unwind support to the normal catch case (SCM_JMPBUFP).

* root.c (scm_internal_cwdr): Add NULL args to
scm_i_with_continuation_barrier call.

* dynwind.c: Change comment mentioning lazy-catch to mention
pre-unwind data and throw handler also.

* continuations.h (scm_i_with_continuation_barrier): Add
pre-unwind handler args.

* continuations.c (scm_i_with_continuation_barrier): Add
pre-unwind handler args, and pass on to scm_c_catch (changed from
scm_internal_catch).
(c_handler): Remove scm_handle_by_message_noexit call.
(scm_c_with_continuation_barrier): Call
scm_i_with_continuation_barrier with scm_handle_by_message_noexit
as the pre-unwind handler.
(scm_handler): Remove scm_handle_by_message_noexit call.
(s_scm_with_continuation_barrier): Call
scm_i_with_continuation_barrier with scm_handle_by_message_noexit
as the pre-unwind handler.
2006-02-04 14:36:24 +00:00
Marius Vollmer
92205699d0 The FSF has a new address. 2005-05-23 19:57:22 +00:00
Marius Vollmer
9de87eea47 See ChangeLog from 2005-03-02. 2005-03-02 20:42:01 +00:00
Marius Vollmer
5c5c27dc0d (scm_t_contregs): New 'offset' member for relocating debug frames.
(scm_make_continuation): Set it.
2004-12-23 15:30:16 +00:00
Stefan Jahn
78b6566ece 2003-06-25 Stefan Jahn <stefan@lkcc.org>
* continuations.c: Redeclaration of getcontext() via the
        __asm__ ("getcontext") directive.

        * continuations.h: Include <ucontext.h> instead of
        <sys/ucontext.h>.
2003-06-25 18:12:35 +00:00
Dirk Herrmann
d0f6ceb84f * Removed uses of DEBUG_EXTENSIONS and DYNAMIC_LINKING to
fix compile errors with --disable-deprecated.
2003-04-20 07:19:38 +00:00
Marius Vollmer
73be1d9e8e Changed license terms to the plain LGPL thru-out. 2003-04-05 19:15:35 +00:00
Stefan Jahn
6a53544072 2002-07-24 Stefan Jahn <stefan@lkcc.org>
* continuations.h: ia64: Include <signal.h> before
        <sys/ucontext.h>.
2002-07-24 09:25:24 +00:00
Han-Wen Nienhuys
34d19ef643 2002-07-20 Han-Wen <hanwen@cs.uu.nl>
* *.c: add space after commas everywhere.

* *.c: use SCM_VECTOR_SET everywhere, where a vector is written.
Document cases where SCM_WRITABLE_VELTS() is used.

* vectors.h (SCM_VELTS): prepare for write barrier, and let
SCM_VELTS() return a const pointer
(SCM_VECTOR_SET): add macro.

* autogen.sh (mscripts): find and check version number of
autoconf. Complain if 2.53 is not found.
2002-07-20 14:08:34 +00:00
Marius Vollmer
87855fa2c4 * __scm.h, alist.h, arbiters.h, async.h, backtrace.h, boolean.h,
chars.h, continuations.h, coop-defs.h, coop-threads.h,
debug-malloc.h, debug.h, deprecation.h, dynl.h, dynwind.h,
environments.h, eq.h, error.h, eval.h, evalext.h, extensions.h,
feature.h, filesys.h, fluids.h, fports.h, gc.h, gdb_interface.h,
gdbint.h, gh.h, goops.h, gsubr.h, guardians.h, hash.h, hashtab.h,
hooks.h, init.h, ioext.h, iselect.h, keywords.h, lang.h, list.h,
load.h, macros.h, mallocs.h, modules.h, net_db.h, numbers.h,
objects.h, objprop.h, options.h, pairs.h, ports.h, posix.h, print.h,
procprop.h, procs.h, properties.h, ramap.h, random.h, rdelim.h,
read.h, regex-posix.h, root.h, rw.h, scmsigs.h, script.h, simpos.h,
smob.h, socket.h, sort.h, srcprop.h, stackchk.h, stacks.h, stime.h,
strings.h, strop.h, strorder.h, strports.h, struct.h, symbols.h,
tags.h, threads.h, throw.h, unif.h, values.h, variable.h, vectors.h,
vports.h, weaks.h:
Prefixed each each exported symbol with SCM_API.

* continuations.c: Added comment about the use of the extern
declarations of {get,set}context() functions used in the ia64 port.

* continuations.h, gc.c: `__libc_ia64_register_backing_store_base'
is meant to be a `unsigned long *'.
2001-11-02 00:08:41 +00:00
Rob Browning
766c5eaf49 * continuations.h: support ia64 register backing store.
(struct scm_t_contregs): add ia64 register backing store.
2001-10-09 03:33:06 +00:00
Gary Houston
2dbec7b5fc * continuations.h, unif.h: in the descriptions of the bit patterns
of the heap cells, make bit 0 the least significant.
2001-10-03 20:45:44 +00:00
Dirk Herrmann
b29058ffee * Remove deprecated macros and typenames.
* Rename header macros to SCM_<filename>_H.
* Prefer !SCM_<foo> over SCM_N<foo>.
2001-08-31 11:17:06 +00:00
Martin Grabmüller
58ade1022c * alist.c, arbiters.c, async.h, backtrace.h, boolean.c, chars.c,
chars.h, continuations.h, debug-malloc.h, dynl.c, feature.c,
	feature.h, filesys.h, fluids.h, fports.h, gc_os_dep.c,
	gdb_interface.h, gh_eval.c, gh_funcs.c, gh_io.c, gh_list.c,
	gh_predicates.c, gsubr.c, gsubr.h, guardians.h,
	guile-func-name-check.in, guile-snarf-docs-texi.in,
	guile-snarf-docs.in, guile-snarf.awk.in, guile-snarf.in,
	hashtab.h, iselect.h, keywords.h, lang.c, list.h, load.h,
	objprop.c, objprop.h, options.c, options.h, random.h,
	regex-posix.h, root.c, root.h, script.c, snarf.h, stackchk.c,
	strerror.c, strop.h, strports.h, threads.h, values.c, values.h,
	version.c, version.h: Updated copyright notice.
2001-07-19 21:08:49 +00:00
Marius Vollmer
92c2555f69 replace "scm_*_t" with "scm_t_*". 2001-06-14 19:50:43 +00:00