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

95 commits

Author SHA1 Message Date
Andy Wingo
745b67c04a Add frame-local-ref / frame-local-set! support for type 'ptr
* libguile/frames.c (enum stack_item_representation):
(scm_to_stack_item_representation):
(scm_frame_local_ref):
(scm_frame_local_set_x): Add support for "ptr" representations.
2021-10-01 11:28:22 +02:00
Andy Wingo
6cd9b3114f Fix use of uninstalled header by installed headers
* libguile/Makefile.am (libpath.h): Remove definition of
  SCM_EFFECTIVE_VERSION, which is defined in version.h.
* libguile/extensions.h: Remove libpath.h inclusion, as it's not
  installed.
* libguile/atomic.c:
* libguile/bytevectors.c:
* libguile/control.c:
* libguile/fdes-finalizers.c:
* libguile/foreign-object.c:
* libguile/foreign.c:
* libguile/fports.c:
* libguile/frames.c:
* libguile/goops.c:
* libguile/i18n.c:
* libguile/instructions.c:
* libguile/intrinsics.c:
* libguile/ioext.c:
* libguile/load.c:
* libguile/loader.c:
* libguile/poll.c:
* libguile/ports.c:
* libguile/posix.c:
* libguile/programs.c:
* libguile/r6rs-ports.c:
* libguile/srfi-1.c:
* libguile/srfi-60.c:
* libguile/threads.c:
* libguile/unicode.c:
* libguile/vm.c:
* libguile/weak-vector.c: Include version.h for the
  SCM_EFFECTIVE_VERSION definition.
2018-10-07 15:15:02 +02:00
Andy Wingo
f4c50447dd Remove push continuation hook; return hook runs before FP pop
* libguile/frames.c (scm_frame_return_values): New function, for use
  when a frame is at "return-values".
  (scm_init_frames_builtins): Register frame-return-values.
* libguile/vm-engine.c (RETURN_HOOK): Rename from POP_CONTINUATION_HOOK.
  (call, call-label): Remove PUSH_CONTINUATION_HOOK; it's unneeded, as
  you can always check the FP from an apply hook.
  (return-values): Run return hook before popping frame.
* libguile/vm.c (vm_dispatch_return_hook): Rename from
  vm_dispatch_pop_continuation_hook.  Remove push continuation hook.
  (scm_vm_return_hook):
* libguile/vm.h (SCM_VM_PUSH_CONTINUATION_HOOK): Remove.
  (SCM_VM_RETURN_HOOK): Rename from SCM_VM_POP_CONTINUATION_HOOK.
* module/system/vm/frame.scm (frame-return-values): Export.
* module/system/vm/trace.scm (print-return, trace-calls-to-procedure)
  (trace-calls-in-procedure): Adapt to not receiving values as
  arguments.
* module/system/vm/traps.scm (trap-in-procedure, trap-frame-finish):
  Adapt to return hook coming from returning frame.
  (program-sources-by-line): Update to use match instead of pmatch.
* module/system/vm/traps.scm (trap-in-dynamic-extent)
  (trap-calls-to-procedure): Adapt to return hook not receiving values.
* module/system/vm/vm.scm: Remove push continuation hook and rename
  return hook.
2018-08-06 17:00:45 +02:00
Andy Wingo
b1705bd0f0 Prepare for frames having separate virtual and machine return addrs
* libguile/frames.c (scm_frame_return_address): Use
  SCM_FRAME_VIRTUAL_RETURN_ADDRESS.
  (scm_c_frame_previous): Likewise.
* libguile/frames.h: Update diagram for new names.
  (union scm_vm_stack_element): Rename "as_ip" to "as_vcode", and
  add "as_mcode" for machine code pointers.
  (SCM_FRAME_VIRTUAL_RETURN_ADDRESS)
  (SCM_FRAME_SET_VIRTUAL_RETURN_ADDRESS): Rename to these, from
  SCM_FRAME_RETURN_ADDRESS and SCM_FRAME_SET_RETURN_ADDRESS.
* libguile/vm-engine.c (halt, call, call-label, return-values)
  (return-from-interrupt): Adapt to renamings.  Make "halt" have frame
  size as a parameter.
* libguile/vm.c (scm_i_vm_mark_stack): Adapt to renaming.
  (push_interrupt_frame): Take mRA as additional argument.  In future we
  will set it as frame mRA.
  (capture_continuation): Adapt to renaming.
  (scm_call_n): Adapt to renaming and make frame size adjustable.
  (push_interrupt_frame, reinstate_continuation_x): Make frame size
  adjustable.
* module/language/cps/slot-allocation.scm (allocate-slots): Make frame
  size adjustable.
* libguile/intrinsics.h (scm_t_thread_mra_intrinsic): New type; use for
  push_interrupt_frame.
  (scm_t_thread_u8_scm_sp_vra_intrinsic): Rename from the same but was
  "ra" instead of "vra", and change type to uint32_t*.
* module/system/vm/disassembler.scm (define-clobber-parser):
  Parameterize clobber set for calls by frame size.
2018-07-20 11:42:30 +02:00
Andy Wingo
16879cabed Replace uses of scm_t_int8, scm_t_uintmax, etc with stdint types
* libguile/bitvectors.c:
* libguile/bitvectors.h:
* libguile/bytevectors.c:
* libguile/bytevectors.h:
* libguile/chars.c:
* libguile/continuations.c:
* libguile/control.c:
* libguile/conv-integer.i.c:
* libguile/conv-uinteger.i.c:
* libguile/dynstack.c:
* libguile/dynstack.h:
* libguile/foreign.c:
* libguile/frames.c:
* libguile/frames.h:
* libguile/gc-inline.h:
* libguile/gc.h:
* libguile/gsubr.c:
* libguile/gsubr.h:
* libguile/hash.c:
* libguile/i18n.c:
* libguile/instructions.c:
* libguile/intrinsics.c:
* libguile/intrinsics.h:
* libguile/loader.c:
* libguile/loader.h:
* libguile/numbers.c:
* libguile/numbers.h:
* libguile/pairs.c:
* libguile/ports-internal.h:
* libguile/ports.c:
* libguile/ports.h:
* libguile/posix.c:
* libguile/print.c:
* libguile/print.h:
* libguile/programs.c:
* libguile/programs.h:
* libguile/r6rs-ports.c:
* libguile/random.c:
* libguile/random.h:
* libguile/scm.h:
* libguile/socket.c:
* libguile/srfi-4.c:
* libguile/srfi-4.h:
* libguile/stacks.c:
* libguile/stime.c:
* libguile/strings.c:
* libguile/struct.c:
* libguile/struct.h:
* libguile/symbols.c:
* libguile/threads.c:
* libguile/threads.h:
* libguile/uniform.c:
* libguile/vm-engine.c:
* libguile/vm.c:
* libguile/vm.h:
* libguile/vports.c:
* test-suite/standalone/test-conversion.c:
* test-suite/standalone/test-ffi-lib.c:
* test-suite/standalone/test-scm-take-u8vector.c:
* test-suite/standalone/test-srfi-4.c: Replace e.g. scm_t_uint8 with
  uint8_t.
2018-06-21 20:18:54 +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
dd8add2fa0 Make .c copyright headers uniform 2018-06-20 18:48:30 +02:00
Andy Wingo
b8d757732f Rationalize include order in C files
Include config.h first, then system includes, then libguile includes, in
alphabetical order, then the include for the file in question.
2018-06-20 18:31:24 +02:00
Andy Wingo
3068bc7384 Make libguile header inclusion consistent within libguile c files
Change from '#include "libguile/foo.h"' and '#include <libguile/foo.h>'
to '#include "foo.h"'.
2018-06-20 17:19:31 +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
40ade0886e Remove _scm.h
* libguile/_scm.h: Remove.  An internal header, never installed.
* libguile/__scm.h: Remove horrible documentation.
* libguile/Makefile.am (EXTRA_libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES):
  Remove _scm.h.
* libguile/alist.c:
* libguile/array-handle.c:
* libguile/array-map.c:
* libguile/arrays.c:
* libguile/async.c:
* libguile/atomic.c:
* libguile/backtrace.c:
* libguile/bitvectors.c:
* libguile/boolean.c:
* libguile/bytevectors.c:
* libguile/chars.c:
* libguile/continuations.c:
* libguile/control.c:
* libguile/debug-malloc.c:
* libguile/debug.c:
* libguile/deprecated.c:
* libguile/deprecation.c:
* libguile/dynl.c:
* libguile/dynstack.c:
* libguile/dynwind.c:
* libguile/eq.c:
* libguile/error.c:
* libguile/eval.c:
* libguile/evalext.c:
* libguile/expand.c:
* libguile/extensions.c:
* libguile/fdes-finalizers.c:
* libguile/feature.c:
* libguile/filesys.c:
* libguile/finalizers.c:
* libguile/fluids.c:
* libguile/foreign-object.c:
* libguile/foreign.c:
* libguile/fports.c:
* libguile/frames.c:
* libguile/gc-malloc.c:
* libguile/gc.c:
* libguile/gen-scmconfig.c:
* libguile/generalized-arrays.c:
* libguile/generalized-vectors.c:
* libguile/gettext.c:
* libguile/goops.c:
* libguile/gsubr.c:
* libguile/guardians.c:
* libguile/hash.c:
* libguile/hashtab.c:
* libguile/hooks.c:
* libguile/i18n.c:
* libguile/init.c:
* libguile/instructions.c:
* libguile/intrinsics.c:
* libguile/ioext.c:
* libguile/keywords.c:
* libguile/list.c:
* libguile/load.c:
* libguile/loader.c:
* libguile/macros.c:
* libguile/mallocs.c:
* libguile/memoize.c:
* libguile/modules.c:
* libguile/net_db.c:
* libguile/null-threads.c:
* libguile/numbers.c:
* libguile/objprop.c:
* libguile/options.c:
* libguile/pairs.c:
* libguile/poll.c:
* libguile/ports-internal.h:
* libguile/ports.c:
* libguile/posix.c:
* libguile/print.c:
* libguile/procprop.c:
* libguile/procs.c:
* libguile/programs.c:
* libguile/promises.c:
* libguile/r6rs-ports.c:
* libguile/random.c:
* libguile/rdelim.c:
* libguile/read.c:
* libguile/regex-posix.c:
* libguile/rw.c:
* libguile/scmsigs.c:
* libguile/script.c:
* libguile/simpos.c:
* libguile/smob.c:
* libguile/socket.c:
* libguile/sort.c:
* libguile/srcprop.c:
* libguile/srfi-1.c:
* libguile/srfi-13.c:
* libguile/srfi-14.c:
* libguile/srfi-4.c:
* libguile/srfi-60.c:
* libguile/stackchk.c:
* libguile/stacks.c:
* libguile/stime.c:
* libguile/strings.c:
* libguile/strorder.c:
* libguile/strports.c:
* libguile/struct.c:
* libguile/symbols.c:
* libguile/syntax.c:
* libguile/threads.c:
* libguile/throw.c:
* libguile/trees.c:
* libguile/unicode.c:
* libguile/uniform.c:
* libguile/values.c:
* libguile/variable.c:
* libguile/vectors.c:
* libguile/version.c:
* libguile/vm.c:
* libguile/vports.c:
* libguile/weak-set.c:
* libguile/weak-table.c:
* libguile/weak-vector.c: Remove _scm.h includes.
2018-06-20 14:26:01 +02:00
Andy Wingo
a7bcd66f6f Devolve symbols.h from _scm.h
* libguile/_scm.h: Remove symbols.h.
* libguile/array-handle.c:
* libguile/array-map.c:
* libguile/backtrace.c:
* libguile/bytevectors.c:
* libguile/chars.c:
* libguile/continuations.c:
* libguile/error.c:
* libguile/eval.c:
* libguile/evalext.c:
* libguile/expand.c:
* libguile/feature.c:
* libguile/filesys.c:
* libguile/foreign.c:
* libguile/fports.c:
* libguile/frames.c:
* libguile/gc.c:
* libguile/goops.c:
* libguile/gsubr.c:
* libguile/i18n.c:
* libguile/instructions.c:
* libguile/intrinsics.c:
* libguile/keywords.c:
* libguile/load.c:
* libguile/macros.c:
* libguile/memoize.c:
* libguile/modules.c:
* libguile/net_db.c:
* libguile/options.c:
* libguile/ports.c:
* libguile/posix.c:
* libguile/print.c:
* libguile/procprop.c:
* libguile/procs.c:
* libguile/r6rs-ports.c:
* libguile/random.c:
* libguile/read.c:
* libguile/socket.c:
* libguile/srcprop.c:
* libguile/srfi-13.c:
* libguile/srfi-14.c:
* libguile/stacks.c:
* libguile/strings.c:
* libguile/strports.c:
* libguile/struct.c:
* libguile/threads.c:
* libguile/throw.c:
* libguile/vm.c: Add symbols.h.
2018-06-20 12:19:12 +02:00
Andy Wingo
f043d0c3dc Remove modules.h from _scm.h.
* libguile/_scm.h: Remove modules.h.
* libguile/arrays.c:
* libguile/backtrace.c:
* libguile/feature.c:
* libguile/filesys.c:
* libguile/foreign-object.c:
* libguile/foreign.c:
* libguile/fports.c:
* libguile/frames.c:
* libguile/gc.c:
* libguile/gsubr.c:
* libguile/i18n.c:
* libguile/intrinsics.c:
* libguile/macros.c:
* libguile/numbers.c:
* libguile/poll.c:
* libguile/ports.c:
* libguile/posix.c:
* libguile/random.c:
* libguile/read.c:
* libguile/regex-posix.c:
* libguile/scmsigs.c:
* libguile/script.c:
* libguile/socket.c:
* libguile/srcprop.c:
* libguile/srfi-14.c:
* libguile/srfi-4.c:
* libguile/stime.c:
* libguile/struct.c:
* libguile/syntax.c:
* libguile/threads.c:
* libguile/throw.c: Add modules.h.
2018-06-20 12:18:24 +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
3c48c87784 Devolve variable.h from _scm.h.
* libguile/_scm.h: Remove variable.h.
* libguile/backtrace.c:
* libguile/debug.c:
* libguile/dynstack.c:
* libguile/dynwind.c:
* libguile/eval.c:
* libguile/evalext.c:
* libguile/expand.c:
* libguile/feature.c:
* libguile/fluids.c:
* libguile/foreign-object.c:
* libguile/fports.c:
* libguile/frames.c:
* libguile/goops.c:
* libguile/i18n.c:
* libguile/load.c:
* libguile/macros.c:
* libguile/memoize.c:
* libguile/ports.c:
* libguile/print.c:
* libguile/programs.c:
* libguile/random.c:
* libguile/read.c:
* libguile/scmsigs.c:
* libguile/srfi-4.c:
* libguile/strports.c:
* libguile/syntax.c:
* libguile/threads.c:
* libguile/throw.c: Add variable.h.
2018-06-20 11:00:29 +02:00
Andy Wingo
bf15afa6bf Move subr snarfing macros to gsubr.h.
* libguile/snarf.h: Remove gsubr include and subr snarfers.
* libguile/gsubr.h (SCM_DEFINE_GSUBR, SCM_DEFINE, SCM_PRIMITIVE_GENERIC):
  (SCM_DEFINE_PUBLIC, SCM_PROC, SCM_REGISTER_PROC, SCM_GPROC): Move
  here.
* libguile/alist.c:
* libguile/array-map.c:
* libguile/arrays.c:
* libguile/async.c:
* libguile/atomic.c:
* libguile/backtrace.c:
* libguile/bitvectors.c:
* libguile/boolean.c:
* libguile/bytevectors.c:
* libguile/chars.c:
* libguile/continuations.c:
* libguile/control.c:
* libguile/debug-malloc.c:
* libguile/debug.c:
* libguile/deprecation.c:
* libguile/dynl.c:
* libguile/eq.c:
* libguile/error.c:
* libguile/error.h:
* libguile/eval.c:
* libguile/evalext.c:
* libguile/expand.c:
* libguile/extensions.c:
* libguile/fdes-finalizers.c:
* libguile/feature.c:
* libguile/filesys.c:
* libguile/finalizers.c:
* libguile/fluids.c:
* libguile/foreign-object.c:
* libguile/foreign.c:
* libguile/fports.c:
* libguile/frames.c:
* libguile/gc.c:
* libguile/generalized-arrays.c:
* libguile/generalized-vectors.c:
* libguile/gettext.c:
* libguile/guardians.c:
* libguile/hash.c:
* libguile/hashtab.c:
* libguile/hooks.c:
* libguile/i18n.c:
* libguile/instructions.c:
* libguile/intrinsics.c:
* libguile/ioext.c:
* libguile/keywords.c:
* libguile/list.c:
* libguile/load.c:
* libguile/loader.c:
* libguile/macros.c:
* libguile/memoize.c:
* libguile/modules.c:
* libguile/net_db.c:
* libguile/numbers.c:
* libguile/objprop.c:
* libguile/pairs.c:
* libguile/poll.c:
* libguile/ports.c:
* libguile/posix.c:
* libguile/print.c:
* libguile/procs.c:
* libguile/programs.c:
* libguile/promises.c:
* libguile/r6rs-ports.c:
* libguile/random.c:
* libguile/rdelim.c:
* libguile/read.c:
* libguile/regex-posix.c:
* libguile/rw.c:
* libguile/scmsigs.c:
* libguile/simpos.c:
* libguile/smob.c:
* libguile/socket.c:
* libguile/sort.c:
* libguile/srcprop.c:
* libguile/srfi-1.c:
* libguile/srfi-13.c:
* libguile/srfi-14.c:
* libguile/srfi-4.c:
* libguile/srfi-60.c:
* libguile/stackchk.c:
* libguile/stacks.c:
* libguile/stime.c:
* libguile/strings.c:
* libguile/strorder.c:
* libguile/strports.c:
* libguile/struct.c:
* libguile/symbols.c:
* libguile/syntax.c:
* libguile/threads.c:
* libguile/throw.c:
* libguile/trees.c:
* libguile/unicode.c:
* libguile/values.c:
* libguile/variable.c:
* libguile/vectors.c:
* libguile/version.c:
* libguile/vm.c:
* libguile/vports.c:
* libguile/weak-table.c:
* libguile/weak-vector.c: Add gsubr includes.
2018-06-20 09:04:55 +02:00
Andy Wingo
d3cfabd89b Devolve numbers.h from _scm.h.
* libguile/_scm.h: Remove numbers.h.
* libguile/array-handle.c:
* libguile/array-map.c:
* libguile/arrays.c:
* libguile/backtrace.c:
* libguile/bitvectors.c:
* libguile/bytevectors.c:
* libguile/chars.c:
* libguile/continuations.c:
* libguile/debug-malloc.c:
* libguile/error.c:
* libguile/eval.c:
* libguile/filesys.c:
* libguile/foreign-object.c:
* libguile/foreign.c:
* libguile/fports.c:
* libguile/frames.c:
* libguile/gc.c:
* libguile/generalized-arrays.c:
* libguile/gettext.c:
* libguile/goops.c:
* libguile/gsubr.c:
* libguile/guardians.c:
* libguile/hash.c:
* libguile/hashtab.c:
* libguile/hooks.c:
* libguile/i18n.c:
* libguile/instructions.c:
* libguile/intrinsics.c:
* libguile/ioext.c:
* libguile/list.c:
* libguile/memoize.c:
* libguile/net_db.c:
* libguile/options.c:
* libguile/ports.c:
* libguile/posix-w32.c:
* libguile/posix.c:
* libguile/procprop.c:
* libguile/programs.c:
* libguile/r6rs-ports.c:
* libguile/random.c:
* libguile/rdelim.c:
* libguile/read.c:
* libguile/regex-posix.c:
* libguile/rw.c:
* libguile/scmsigs.c:
* libguile/simpos.c:
* libguile/smob.c:
* libguile/socket.c:
* libguile/srcprop.c:
* libguile/srfi-13.c:
* libguile/srfi-14.c:
* libguile/srfi-4.c:
* libguile/stackchk.c:
* libguile/stacks.c:
* libguile/stime.c:
* libguile/strings.c:
* libguile/struct.c:
* libguile/symbols.c:
* libguile/threads.c:
* libguile/throw.c:
* libguile/vectors.c:
* libguile/version.c:
* libguile/vm.c:
* libguile/vports.c:
* libguile/weak-table.c: Add numbers.h.
2018-06-19 15:37:23 +02:00
Andy Wingo
e56d22153b Remove ports.h from inline.h
* libguile/inline.h: Remove ports.h.
* libguile/bitvectors.c:
* libguile/bytevectors.c:
* libguile/foreign.c:
* libguile/frames.c:
* libguile/goops.h:
* libguile/programs.c:
* libguile/smob.c:
* libguile/srfi-14.c:
* libguile/vm.c: Add ports.h.
2018-06-19 12:01:38 +02:00
Andy Wingo
1a99bd10f8 Devolve boolean.h include.
* libguile/_scm.h: Remove boolean.h include.
* libguile/alist.c:
* libguile/array-map.c:
* libguile/arrays.c:
* libguile/backtrace.c:
* libguile/bitvectors.c:
* libguile/chars.c:
* libguile/continuations.c:
* libguile/dynwind.c:
* libguile/eq.c:
* libguile/eval.c:
* libguile/expand.c:
* libguile/fdes-finalizers.c:
* libguile/filesys.c:
* libguile/foreign.c:
* libguile/fports.c:
* libguile/frames.c:
* libguile/generalized-arrays.h:
* libguile/goops.c:
* libguile/goops.h:
* libguile/guardians.c:
* libguile/hooks.c:
* libguile/i18n.c:
* libguile/intrinsics.c:
* libguile/list.c:
* libguile/load.c:
* libguile/loader.c:
* libguile/macros.c:
* libguile/memoize.c:
* libguile/modules.c:
* libguile/net_db.c:
* libguile/numbers.c:
* libguile/options.c:
* libguile/ports.c:
* libguile/print.c:
* libguile/procprop.c:
* libguile/procs.h:
* libguile/programs.c:
* libguile/r6rs-ports.c:
* libguile/read.c:
* libguile/scmsigs.c:
* libguile/sort.c:
* libguile/srcprop.h:
* libguile/srfi-1.c:
* libguile/srfi-13.c:
* libguile/srfi-14.c:
* libguile/srfi-14.h:
* libguile/srfi-4.c:
* libguile/stacks.c:
* libguile/stime.c:
* libguile/strorder.c:
* libguile/struct.c:
* libguile/struct.h:
* libguile/symbols.c:
* libguile/threads.c:
* libguile/throw.c:
* libguile/vports.c: Add boolean.h includes.
2018-06-18 21:38:44 +02:00
Andy Wingo
83584ef231 Fix libguile subcomponent headers not to include <libguile.h>
* libguile/bytevectors.h: Include uniform.h, for use in the macros.
* libguile/extensions.h: Include libpath.h, for the
  SCM_EFFECTIVE_VERSION, which is almost always used with these
  routines.
* libguile/frames.h:
* libguile/instructions.h:
* libguile/intrinsics.h:
* libguile/loader.h:
* libguile/programs.h:
* libguile/vm.h: Include <libguile/__scm.h> instead of <libguile.h>.
  Cuts a circular include, but also precipitates a lot of maintenance in
  the .c files.

* libguile/*.c: Update C files to add needed all needed includes that
  before were getting automatically pulled in by the indirect inclusion
  of libguile.h.
2018-06-14 22:20:47 +02:00
Andy Wingo
00ed4043c2 VM continuations store FP/SP by offset
* libguile/continuations.c (scm_i_continuation_to_frame):
* libguile/stacks.c (scm_make_stack):
* libguile/vm.c (scm_i_vm_cont_to_frame, scm_i_vm_capture_stack):
  (vm_return_to_continuation_inner)
  (struct vm_reinstate_partial_continuation_data):
  (vm_reinstate_partial_continuation_inner):
  (vm_reinstate_partial_continuation):
* libguile/vm.h (sstruct scm_vm_cont): Simplify VM continuations by
  recording the top FP by offset, not value + reloc.
* libguile/frames.c (frame_offset, scm_i_vm_frame_offset): Remove unused
  functions.
* libguile/frames.h (SCM_VALIDATE_VM_FRAME, scm_i_vm_frame_offset):
  Remove.
* libguile/control.c (reify_partial_continuation): Once we know the
  base_fp, relocate the dynamic stack.
* libguile/dynstack.h:
* libguile/dynstack.c (scm_dynstack_relocate_prompts): New function.
  (scm_dynstack_wind_prompt): Adapt to add new fp offset.
2017-02-12 20:31:14 +01:00
Andy Wingo
105e36543f 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.
2016-04-26 23:07:28 +02:00
Andy Wingo
206b3f6e03 Remove scm_putc_unlocked.
* libguile/ports.h (scm_putc_unlocked): Remove.
* libguile/ports.c (scm_putc): Replace implementation with
  scm_putc_unlocked's implementation.
  (scm_port_print): Use scm_putc.
* libguile/arbiters.c:
* libguile/arrays.c:
* libguile/bitvectors.c:
* libguile/bytevectors.c:
* libguile/continuations.c:
* libguile/dynl.c:
* libguile/eval.c:
* libguile/filesys.c:
* libguile/fluids.c:
* libguile/foreign.c:
* libguile/fports.c:
* libguile/frames.c:
* libguile/hashtab.c:
* libguile/hooks.c:
* libguile/macros.c:
* libguile/mallocs.c:
* libguile/print.c:
* libguile/programs.c:
* libguile/promises.c:
* libguile/r6rs-ports.c:
* libguile/smob.c:
* libguile/srcprop.c:
* libguile/struct.c:
* libguile/variable.c:
* libguile/weak-set.c:
* libguile/weak-table.c: Use scm_putc instead of scm_putc_unlocked.
2016-04-26 23:01:14 +02:00
Andy Wingo
67e8aa85e8 Remove frame-local-ref, frame-local-set!
* libguile/frames.h (scm_frame_num_locals, scm_frame_local_ref)
  (scm_frame_local_set_x): Remove.  As long as we are changing the
  interface in a backward-incompatible way, we might as well remove
  these.
* libguile/frames.c (scm_frame_num_locals, scm_frame_local_ref)
  (scm_frame_local_set_x, scm_init_frames_builtins, scm_init_frames):
  Arrange to make frame-local-ref et al private to frames.scm.

* module/system/vm/frame.scm: Load scm_init_frames_builtins extensions.
  (frame-instruction-pointer-or-primitive-procedure-name): New public
  function.
  (frame-binding-ref, frame-binding-set!): Allow binding objects as
  vars.

* module/system/repl/debug.scm (print-locals): Pass binding directly to
  frame-binding-ref.

* module/statprof.scm (sample-stack-procs, count-call): Use new
  frame-instruction-pointer-or-primitive-procedure-name function.
2016-01-31 10:45:02 +01:00
Andy Wingo
8bf77f7192 Add support for unboxed s64 values
* libguile/frames.c (enum stack_item_representation):
  (scm_to_stack_item_representation):
  (scm_frame_local_ref, scm_frame_local_set_x): Support for S64
  representations.

* libguile/frames.h (union scm_vm_stack_element): Add signed 64-bit
  integer field.

* libguile/vm-engine.c (scm->s64, s64->scm, load-s64): New
  instructions.

* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/cse.scm (compute-equivalent-subexpressions):
* module/language/cps/effects-analysis.scm:
* module/language/cps/slot-allocation.scm (compute-var-representations)
  (compute-needs-slot, allocate-slots):
* module/language/cps/utils.scm (compute-constant-values):
* module/language/cps/specialize-primcalls.scm (specialize-primcalls):
  Add support for new primcalls.

* module/language/cps/types.scm (&s64): New type.
  (&s64-min, &s64-max, &u64-max): New convenience definitions.
  (&range-min, &range-max): Use &s64-min and &u64-max names.
  (scm->s64, load-s64, s64->scm): Add support for new primcalls.

* module/system/vm/assembler.scm (emit-scm->s64, emit-s64->scm)
  (emit-load-s64): New exports.
* module/system/vm/assembler.scm (write-arities): Support for s64
  slots.

* module/system/vm/debug.scm (arity-definitions): Support for s64
  slots.
2015-12-01 15:42:19 +01:00
Andy Wingo
dfbe869e24 Add low-level support for unboxed 64-bit unsigned ints
* libguile/frames.c (enum stack_item_representation)
* libguile/frames.c (scm_to_stack_item_representation):
  (scm_frame_local_ref, scm_frame_local_set_x): Support 'u64 slots.
* libguile/frames.h (union scm_vm_stack_element): Add as_u64 member.

* libguile/vm-engine.c (SP_REF_U64, SP_SET_U64): New helpers.
  (scm->u64, u64->scm): New instructions.

* module/language/cps/cse.scm (compute-equivalent-subexpressions):
  Scalar replacement for u64->scm and scm->u64.

* module/language/cps/effects-analysis.scm (scm->u64, u64->scm): Add
  cases.

* module/language/cps/slot-allocation.scm (compute-var-representations):
  (allocate-slots): Represent the result of scm->u64 as a "u64" slot.

* module/language/cps/types.scm (&u64): New type.
  (scm->u64, u64->scm): Add support for these ops.

* module/system/vm/assembler.scm (write-arities):
* module/system/vm/debug.scm (arity-definitions): Support u64
  representations.
2015-12-01 11:30:54 +01:00
Andy Wingo
58153e3a08 Remove frame-procedure
* libguile/frames.h:
* libguile/frames.c (scm_frame_procedure): Remove.
* test-suite/tests/eval.test ("stacks"): Adapt test.
* NEWS: Add news item.
* doc/ref/api-debug.texi (Frames): Document frame-procedure-name instead
  of frame-procedure.
2015-12-01 11:30:54 +01:00
Andy Wingo
9a8c2995ae More robust low-level frame printer
* libguile/frames.c (scm_i_frame_print): Print using
  frame-procedure-name, not frame-procedure.
2015-12-01 11:30:54 +01:00
Andy Wingo
39090e677e Add frame-procedure-name
* libguile/frames.c (frame_procedure_name_var): New static definition.
  (init_frame_procedure_name_var): New helper.
  (scm_frame_procedure_name): New function that returns the name of the
  frame's procedure, as frame-procedure is to be deprecated.

* libguile/frames.h (scm_frame_procedure_name): Export.

* module/ice-9/boot-9.scm (exception-printers): Use frame-procedure-name
  instead of procedure-name on frame-procedure.

* module/system/vm/frame.scm (frame-procedure-name): New private
  function, implementing scm_frame_procedure_name.
  (frame-call-representation): Use frame-procedure-name to get the
  procedure name to print.
2015-12-01 11:30:54 +01:00
Andy Wingo
02fc5a772b Identify boot continuations by code, not closure
* libguile/vm.h:
* libguile/vm.c (scm_i_vm_is_boot_continuation_code): New internal
  procedure.
* libguile/stacks.c (scm_make_stack):
* libguile/frames.c (scm_c_frame_previous): Use new helper to identify
  boot frames.
2015-12-01 10:57:20 +01:00
Andy Wingo
fc87033bf0 Stack slots can hold a double
* libguile/frames.h (union scm_vm_stack_element): Add double member.
* libguile/frames.c (scm_frame_local_ref, scm_frame_local_set_x): Wire
  up f64 support.
2015-10-28 17:47:48 +00:00
Andy Wingo
e3cc0eeb3a Reflection support for unboxed f64 slots
* module/system/vm/assembler.scm (emit-definition): Add representation
  field.
  (write-arities): Emit representations into the arities section.

* module/system/vm/debug.scm (arity-definitions): Read representations.

* module/system/vm/frame.scm (<binding>): Add representation field and
  binding-representation getter.
  (available-bindings): Pass representation to make-binding.
  (frame-binding-set!, frame-binding-ref, frame-call-representation):
  Pass representation to frame-local-ref / frame-local-set!.

* test-suite/tests/rtl.test: Update definition instructions.

* module/language/cps/slot-allocation.scm ($allocation): Add
  representations field.
  (lookup-representation): New public function.
  (allocate-slots): Pass representations to make-$allocation.

* module/language/cps/compile-bytecode.scm (compile-function): Adapt to
  emit-definition change.

* libguile/frames.h:
* libguile/frames.c (scm_frame_local_ref, scm_frame_local_set_x): Take
  representation argument.
  (scm_to_stack_item_representation): New internal helper.
2015-10-28 17:43:55 +00:00
Andy Wingo
72353de77d Replace dynamic link on stack with previous frame size
* libguile/frames.h (SCM_FRAME_DYNAMIC_LINK)
  (SCM_FRAME_SET_DYNAMIC_LINK): Instead of storing the absolute value of
  the previous FP, store its offset from the current FP.  This allows us
  to avoid relinking when composing continuations or when relocating the
  stack.

* libguile/frames.c (scm_frame_dynamic_link, scm_c_frame_previous): No
  need to relocate the dynamic link.

* libguile/vm.c (vm_return_to_continuation_inner):
  (vm_reinstate_partial_continuation_inner, vm_expand_stack_inner):
  Don't relocate the frame pointer chain.
  (scm_i_vm_mark_stack): Terminate when FP is above stack_top, not when
  0.
  (make_vm): Init FP to stack_top.
2015-10-21 11:49:20 +02:00
Andy Wingo
0007507340 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.
2015-10-21 11:49:20 +02:00
Andy Wingo
7c080187bc frame-address, frame-stack-pointer return offsets
* libguile/frames.c (scm_frame_address, scm_frame_stack_pointer): Return
  offsets instead of absolute pointers.  This is robust in the presence
  of stack relocation.

* module/system/repl/debug.scm (print-registers): Adapt to print sp and
  fp as integers.
2014-05-04 11:46:18 +02:00
Andy Wingo
deb2df5323 frame-previous, frame-procedure robustness
* libguile/frames.c (scm_c_frame_closure): Don't use SCM_FRAME_PROGRAM,
  as we don't know if the frame actually has any locals.
  (scm_c_frame_previous): More robustly detect end-of-stack.  Allows
  scm_c_frame_previous to work on partial continuations.
2014-04-16 19:17:38 +02:00
Andy Wingo
4819276185 Better backtraces from C, especially for optimized closures
* libguile/frames.h:
* libguile/frames.c (scm_frame_call_representation): New interface;
  dispatches to Scheme.

* libguile/backtrace.c (display_application): Use
  scm_frame_call_representation.  This should be monotonically better,
  given that scm_frame_arguments (which was previously called) also
  dispatched to Scheme and actually ended up calling
  frame-call-representation.
2014-04-16 14:33:20 +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
8de051da47 scm_c_make_frame takes struct scm_frame as arg
* libguile/frames.h:
* libguile/frames.c (scm_c_make_frame): Adapt to take a const struct
  scm_frame as the argument.  Adapt callers.

* libguile/continuations.c:
* libguile/stacks.c: Adapt callers.
2014-04-14 15:14:26 +02:00
Andy Wingo
44d9705464 Refactor to frames code
* libguile/frames.h:
* libguile/frames.c (scm_c_frame_previous): New internal helper.
  (scm_frame_previous): Use the helper.
  (RELOC): Take kind and low-level frame args separately.  Adapt
  callers.
  (frame_stack_base, frame_offset): New helpers.
  (scm_i_frame_offset, scm_i_frame_stack_base): Use low-level helpers.
2014-04-14 14:54:14 +02:00
Andy Wingo
dc7a33fa87 Merge commit '60617d819d'
Conflicts:
	libguile/continuations.c
	libguile/eval.c
	libguile/goops.c
	libguile/instructions.c
2014-02-07 15:03:17 +01:00
Mark H Weaver
60617d819d 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'.
2014-01-23 23:44:11 -05:00
Andy Wingo
5515edc5f2 Heap frame "stack holders" are raw scm_vm / scm_vm_cont pointers
* libguile/frames.h (struct scm_frame): stack_holder is a void*.
* libguile/frames.c (scm_i_frame_stack_base, scm_i_frame_offset): Expect
  stack_holder to be the raw struct scm_vm or scm_vm_cont.

* libguile/continuations.c (scm_i_continuation_to_frame):
* libguile/stacks.c (scm_make_stack)
* libguile/vm.c (vm_dispatch_hook): Adapt creators.
2013-11-21 17:21:37 +01:00
Andy Wingo
050a40db5b Heap frames have a "frame kind" bit
* libguile/frames.h (enum scm_vm_frame_kind, SCM_VM_FRAME_KIND)
  (scm_c_make_frame): Add a "frame kind" bit to the first word.  This
  will allow the "stack holder" to be a non-SCM object.

* libguile/continuations.c (scm_i_continuation_to_frame):
* libguile/frames.c (scm_c_make_frame, scm_frame_previous)
* libguile/stacks.c (scm_make_stack):
* libguile/vm.c (vm_dispatch_hook): Adapt frame creators to set the
  frame kind bit.
2013-11-21 17:13:18 +01:00
Andy Wingo
89b235afd3 Scheme frame objects hold relative stack offsets
* libguile/frames.h: Wrap the C interface to VM frames in
  BUILDING_LIBGUILE.  Change VM frames to record relative offsets into a
  stack held by some other object, so that if the stack moves they will
  remain valid.
* libguile/frames.c (scm_c_make_frame): Remove offset argument.
  (scm_i_frame_offset): Instead, compute the offset from the stack
  holder.
  (scm_i_frame_stack_base): New helper.
  (scm_frame_previous): Adapt.

* libguile/stacks.c (scm_make_stack)
* libguile/vm.c (vm_dispatch_hook):
* libguile/continuations.c (scm_i_continuation_to_frame): Adapt.
2013-11-21 11:20:19 +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
9121d9f1ac All instruction pointers are now scm_t_uint32*
* libguile/frames.h (SCM_FRAME_RTL_RETURN_ADDRESS)
  (SCM_FRAME_SET_RTL_RETURN_ADDRESS): Remove.  The variants without _RTL
  now work fine.
  (struct scm_vm_frame): Change the return address to be a
  scm_t_uint32*.
  (struct scm_frame): Change IP to be scm_t_uint32*.

* libguile/frames.c (scm_c_make_frame)
* libguile/control.c (reify_partial_continuation, scm_c_abort)
* libguile/dynstack.c (PROMPT_IP)
  (scm_dynstack_push_prompt, scm_dynstack_find_prompt)
* libguile/dynstack.h:
* libguile/vm-engine.c (SYNC_IP, RETURN_ONE_VALUE)
  (call, return-values, prompt): Adapt.
2013-11-19 18:09:34 +01:00
Andy Wingo
b636cdb0f3 Frame pointer points to local 0 instead of local 1
* libguile/frames.h: Change so that fp points at local 0 instead of
  local 1, and clean up a bit.
  (struct scm_vm_frame): Remove program, and rename stack to locals.
  (SCM_FRAME_DATA_ADDRESS): Remove; it was redundant with
  SCM_FRAME_LOWER_ADDRESS.
  (SCM_FRAME_STACK_ADDRESS): Remove; replace with the new
  SCM_FRAME_LOCALS_ADDRESS.
  (SCM_FRAME_UPPER_ADDRESS): Remove; unused.
  (SCM_FRAME_NUM_LOCALS, SCM_FRAME_PREVIOUS_SP): New defines.
  (SCM_FRAME_BYTE_CAST, SCM_FRAME_STACK_CAST): Remove; unused;
  (SCM_FRAME_LOCAL): New define, replaces SCM_FRAME_VARIABLE.
  (SCM_FRAME_PROGRAM): Add cautionary commentary.

* libguile/frames.c: Adapt static asserts.
  (scm_frame_num_locals, scm_frame_local_ref, scm_frame_local_set_x):
  Adapt.  This means that frame-local-ref 0 now returns the procedure.

* libguile/vm-engine.c (ALLOC_FRAME, RESET_FRAME)
  (FRAME_LOCALS_COUNT, LOCAL_REF, LOCAL_SET, RETURN_VALUE_LIST): Adapt
  to change in fp.
  (LOCAL_ADDRESS): New helper.
  (POP_CONTINUATION_HOOK): Reimplement, taking the previous FP as an
  argument.
  (ABORT_CONTINUATION_HOOK): Reimplement, taking no arguments.
  (RETURN_ONE_VALUE): Reimplement.
  (RETURN_VALUE_LIST): Adapt to FP change.
  (halt, return-values, subr-call, foreign-call, prompt)
  (continuation-call, compose-continuation, call/cc, abort): Adapt to FP
  change, mostly via using LOCAL_ADDRESS, etc abstractions instead of
  using the raw frame pointer.

* libguile/control.c (reify_partial_continuation): Update for fp
  change.

* libguile/vm.c (vm_reinstate_partial_continuation): Adapt to removal of
  SCM_FRAME_UPPER_ADDRESS.

* module/system/vm/frame.scm (frame-call-representation): Adapt to
  frame-local-ref change.

* module/system/vm/trace.scm (print-return): Remove unused
  frame-num-locals call.
2013-11-17 22:07:44 +01:00
Andy Wingo
f8085163d6 Remove MVRA from VM frames
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump for frame layout
  change.

* libguile/frames.c: Update some static checks.
  (scm_frame_num_locals, scm_frame_local_ref, scm_frame_local_set_x):
  Update to not skip over uninitialized frames, as that's not a thing
  any more.

* libguile/frames.h: Update to remove MVRA.  Woo!

* libguile/vm-engine.c (ALLOC_FRAME, RETURN_ONE_VALUE):
  (rtl_vm_engine): Update for 3 words per frame instead of 4.

* libguile/vm.c (vm_return_to_continuation): Likewise.

* module/language/cps/slot-allocation.scm (allocate-slots): 3 words per
  frame, not 4.

* module/system/vm/assembler.scm (*bytecode-minor-version*): Bump.  Also
  remove a couple of tc7's that aren't around any more.
2013-11-15 17:13:27 +01:00